babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4483. static readonly GEQUAL: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Defines if the texture contains multiview data
  6287. */
  6288. isMultiview: boolean;
  6289. /**
  6290. * Gets the URL used to load this texture
  6291. */
  6292. url: string;
  6293. /**
  6294. * Gets the sampling mode of the texture
  6295. */
  6296. samplingMode: number;
  6297. /**
  6298. * Gets a boolean indicating if the texture needs mipmaps generation
  6299. */
  6300. generateMipMaps: boolean;
  6301. /**
  6302. * Gets the number of samples used by the texture (WebGL2+ only)
  6303. */
  6304. samples: number;
  6305. /**
  6306. * Gets the type of the texture (int, float...)
  6307. */
  6308. type: number;
  6309. /**
  6310. * Gets the format of the texture (RGB, RGBA...)
  6311. */
  6312. format: number;
  6313. /**
  6314. * Observable called when the texture is loaded
  6315. */
  6316. onLoadedObservable: Observable<InternalTexture>;
  6317. /**
  6318. * Gets the width of the texture
  6319. */
  6320. width: number;
  6321. /**
  6322. * Gets the height of the texture
  6323. */
  6324. height: number;
  6325. /**
  6326. * Gets the depth of the texture
  6327. */
  6328. depth: number;
  6329. /**
  6330. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseWidth: number;
  6333. /**
  6334. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseHeight: number;
  6337. /**
  6338. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6339. */
  6340. baseDepth: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture is inverted on Y axis
  6343. */
  6344. invertY: boolean;
  6345. /**
  6346. * Gets or set the previous tracker in the list
  6347. */
  6348. previous: Nullable<IInternalTextureTracker>;
  6349. /**
  6350. * Gets or set the next tracker in the list
  6351. */
  6352. next: Nullable<IInternalTextureTracker>;
  6353. /** @hidden */
  6354. _invertVScale: boolean;
  6355. /** @hidden */
  6356. _initialSlot: number;
  6357. /** @hidden */
  6358. _designatedSlot: number;
  6359. /** @hidden */
  6360. _dataSource: number;
  6361. /** @hidden */
  6362. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6363. /** @hidden */
  6364. _bufferView: Nullable<ArrayBufferView>;
  6365. /** @hidden */
  6366. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6367. /** @hidden */
  6368. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */
  6370. _size: number;
  6371. /** @hidden */
  6372. _extension: string;
  6373. /** @hidden */
  6374. _files: Nullable<string[]>;
  6375. /** @hidden */
  6376. _workingCanvas: HTMLCanvasElement;
  6377. /** @hidden */
  6378. _workingContext: CanvasRenderingContext2D;
  6379. /** @hidden */
  6380. _framebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6385. /** @hidden */
  6386. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6387. /** @hidden */
  6388. _attachments: Nullable<number[]>;
  6389. /** @hidden */
  6390. _cachedCoordinatesMode: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapU: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedWrapV: Nullable<number>;
  6395. /** @hidden */
  6396. _cachedWrapR: Nullable<number>;
  6397. /** @hidden */
  6398. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6399. /** @hidden */
  6400. _isDisabled: boolean;
  6401. /** @hidden */
  6402. _compression: Nullable<string>;
  6403. /** @hidden */
  6404. _generateStencilBuffer: boolean;
  6405. /** @hidden */
  6406. _generateDepthBuffer: boolean;
  6407. /** @hidden */
  6408. _comparisonFunction: number;
  6409. /** @hidden */
  6410. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6411. /** @hidden */
  6412. _lodGenerationScale: number;
  6413. /** @hidden */
  6414. _lodGenerationOffset: number;
  6415. /** @hidden */
  6416. _colorTextureArray: Nullable<WebGLTexture>;
  6417. /** @hidden */
  6418. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6419. /** @hidden */
  6420. _lodTextureHigh: BaseTexture;
  6421. /** @hidden */
  6422. _lodTextureMid: BaseTexture;
  6423. /** @hidden */
  6424. _lodTextureLow: BaseTexture;
  6425. /** @hidden */
  6426. _isRGBD: boolean;
  6427. /** @hidden */
  6428. _webGLTexture: Nullable<WebGLTexture>;
  6429. /** @hidden */
  6430. _references: number;
  6431. private _engine;
  6432. /**
  6433. * Gets the Engine the texture belongs to.
  6434. * @returns The babylon engine
  6435. */
  6436. getEngine(): Engine;
  6437. /**
  6438. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6439. */
  6440. readonly dataSource: number;
  6441. /**
  6442. * Creates a new InternalTexture
  6443. * @param engine defines the engine to use
  6444. * @param dataSource defines the type of data that will be used
  6445. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6446. */
  6447. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6448. /**
  6449. * Increments the number of references (ie. the number of Texture that point to it)
  6450. */
  6451. incrementReferences(): void;
  6452. /**
  6453. * Change the size of the texture (not the size of the content)
  6454. * @param width defines the new width
  6455. * @param height defines the new height
  6456. * @param depth defines the new depth (1 by default)
  6457. */
  6458. updateSize(width: int, height: int, depth?: int): void;
  6459. /** @hidden */
  6460. _rebuild(): void;
  6461. /** @hidden */
  6462. _swapAndDie(target: InternalTexture): void;
  6463. /**
  6464. * Dispose the current allocated resources
  6465. */
  6466. dispose(): void;
  6467. }
  6468. }
  6469. declare module "babylonjs/Animations/easing" {
  6470. /**
  6471. * This represents the main contract an easing function should follow.
  6472. * Easing functions are used throughout the animation system.
  6473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6474. */
  6475. export interface IEasingFunction {
  6476. /**
  6477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6478. * of the easing function.
  6479. * The link below provides some of the most common examples of easing functions.
  6480. * @see https://easings.net/
  6481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6482. * @returns the corresponding value on the curve defined by the easing function
  6483. */
  6484. ease(gradient: number): number;
  6485. }
  6486. /**
  6487. * Base class used for every default easing function.
  6488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6489. */
  6490. export class EasingFunction implements IEasingFunction {
  6491. /**
  6492. * Interpolation follows the mathematical formula associated with the easing function.
  6493. */
  6494. static readonly EASINGMODE_EASEIN: number;
  6495. /**
  6496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6497. */
  6498. static readonly EASINGMODE_EASEOUT: number;
  6499. /**
  6500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6501. */
  6502. static readonly EASINGMODE_EASEINOUT: number;
  6503. private _easingMode;
  6504. /**
  6505. * Sets the easing mode of the current function.
  6506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6507. */
  6508. setEasingMode(easingMode: number): void;
  6509. /**
  6510. * Gets the current easing mode.
  6511. * @returns the easing mode
  6512. */
  6513. getEasingMode(): number;
  6514. /**
  6515. * @hidden
  6516. */
  6517. easeInCore(gradient: number): number;
  6518. /**
  6519. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6520. * of the easing function.
  6521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6522. * @returns the corresponding value on the curve defined by the easing function
  6523. */
  6524. ease(gradient: number): number;
  6525. }
  6526. /**
  6527. * Easing function with a circle shape (see link below).
  6528. * @see https://easings.net/#easeInCirc
  6529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6530. */
  6531. export class CircleEase extends EasingFunction implements IEasingFunction {
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a ease back shape (see link below).
  6537. * @see https://easings.net/#easeInBack
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class BackEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the amplitude of the function */
  6542. amplitude: number;
  6543. /**
  6544. * Instantiates a back ease easing
  6545. * @see https://easings.net/#easeInBack
  6546. * @param amplitude Defines the amplitude of the function
  6547. */
  6548. constructor(
  6549. /** Defines the amplitude of the function */
  6550. amplitude?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a bouncing shape (see link below).
  6556. * @see https://easings.net/#easeInBounce
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class BounceEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of bounces */
  6561. bounces: number;
  6562. /** Defines the amplitude of the bounce */
  6563. bounciness: number;
  6564. /**
  6565. * Instantiates a bounce easing
  6566. * @see https://easings.net/#easeInBounce
  6567. * @param bounces Defines the number of bounces
  6568. * @param bounciness Defines the amplitude of the bounce
  6569. */
  6570. constructor(
  6571. /** Defines the number of bounces */
  6572. bounces?: number,
  6573. /** Defines the amplitude of the bounce */
  6574. bounciness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 3 shape (see link below).
  6580. * @see https://easings.net/#easeInCubic
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class CubicEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with an elastic shape (see link below).
  6589. * @see https://easings.net/#easeInElastic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of oscillations*/
  6594. oscillations: number;
  6595. /** Defines the amplitude of the oscillations*/
  6596. springiness: number;
  6597. /**
  6598. * Instantiates an elastic easing function
  6599. * @see https://easings.net/#easeInElastic
  6600. * @param oscillations Defines the number of oscillations
  6601. * @param springiness Defines the amplitude of the oscillations
  6602. */
  6603. constructor(
  6604. /** Defines the number of oscillations*/
  6605. oscillations?: number,
  6606. /** Defines the amplitude of the oscillations*/
  6607. springiness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with an exponential shape (see link below).
  6613. * @see https://easings.net/#easeInExpo
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6617. /** Defines the exponent of the function */
  6618. exponent: number;
  6619. /**
  6620. * Instantiates an exponential easing function
  6621. * @see https://easings.net/#easeInExpo
  6622. * @param exponent Defines the exponent of the function
  6623. */
  6624. constructor(
  6625. /** Defines the exponent of the function */
  6626. exponent?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. /**
  6631. * Easing function with a power shape (see link below).
  6632. * @see https://easings.net/#easeInQuad
  6633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6634. */
  6635. export class PowerEase extends EasingFunction implements IEasingFunction {
  6636. /** Defines the power of the function */
  6637. power: number;
  6638. /**
  6639. * Instantiates an power base easing function
  6640. * @see https://easings.net/#easeInQuad
  6641. * @param power Defines the power of the function
  6642. */
  6643. constructor(
  6644. /** Defines the power of the function */
  6645. power?: number);
  6646. /** @hidden */
  6647. easeInCore(gradient: number): number;
  6648. }
  6649. /**
  6650. * Easing function with a power of 2 shape (see link below).
  6651. * @see https://easings.net/#easeInQuad
  6652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6653. */
  6654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 4 shape (see link below).
  6660. * @see https://easings.net/#easeInQuart
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 5 shape (see link below).
  6669. * @see https://easings.net/#easeInQuint
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a sin shape (see link below).
  6678. * @see https://easings.net/#easeInSine
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class SineEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a bezier shape (see link below).
  6687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6691. /** Defines the x component of the start tangent in the bezier curve */
  6692. x1: number;
  6693. /** Defines the y component of the start tangent in the bezier curve */
  6694. y1: number;
  6695. /** Defines the x component of the end tangent in the bezier curve */
  6696. x2: number;
  6697. /** Defines the y component of the end tangent in the bezier curve */
  6698. y2: number;
  6699. /**
  6700. * Instantiates a bezier function
  6701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6702. * @param x1 Defines the x component of the start tangent in the bezier curve
  6703. * @param y1 Defines the y component of the start tangent in the bezier curve
  6704. * @param x2 Defines the x component of the end tangent in the bezier curve
  6705. * @param y2 Defines the y component of the end tangent in the bezier curve
  6706. */
  6707. constructor(
  6708. /** Defines the x component of the start tangent in the bezier curve */
  6709. x1?: number,
  6710. /** Defines the y component of the start tangent in the bezier curve */
  6711. y1?: number,
  6712. /** Defines the x component of the end tangent in the bezier curve */
  6713. x2?: number,
  6714. /** Defines the y component of the end tangent in the bezier curve */
  6715. y2?: number);
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. }
  6720. declare module "babylonjs/Animations/animationKey" {
  6721. /**
  6722. * Defines an interface which represents an animation key frame
  6723. */
  6724. export interface IAnimationKey {
  6725. /**
  6726. * Frame of the key frame
  6727. */
  6728. frame: number;
  6729. /**
  6730. * Value at the specifies key frame
  6731. */
  6732. value: any;
  6733. /**
  6734. * The input tangent for the cubic hermite spline
  6735. */
  6736. inTangent?: any;
  6737. /**
  6738. * The output tangent for the cubic hermite spline
  6739. */
  6740. outTangent?: any;
  6741. /**
  6742. * The animation interpolation type
  6743. */
  6744. interpolation?: AnimationKeyInterpolation;
  6745. }
  6746. /**
  6747. * Enum for the animation key frame interpolation type
  6748. */
  6749. export enum AnimationKeyInterpolation {
  6750. /**
  6751. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6752. */
  6753. STEP = 1
  6754. }
  6755. }
  6756. declare module "babylonjs/Animations/animationRange" {
  6757. /**
  6758. * Represents the range of an animation
  6759. */
  6760. export class AnimationRange {
  6761. /**The name of the animation range**/
  6762. name: string;
  6763. /**The starting frame of the animation */
  6764. from: number;
  6765. /**The ending frame of the animation*/
  6766. to: number;
  6767. /**
  6768. * Initializes the range of an animation
  6769. * @param name The name of the animation range
  6770. * @param from The starting frame of the animation
  6771. * @param to The ending frame of the animation
  6772. */
  6773. constructor(
  6774. /**The name of the animation range**/
  6775. name: string,
  6776. /**The starting frame of the animation */
  6777. from: number,
  6778. /**The ending frame of the animation*/
  6779. to: number);
  6780. /**
  6781. * Makes a copy of the animation range
  6782. * @returns A copy of the animation range
  6783. */
  6784. clone(): AnimationRange;
  6785. }
  6786. }
  6787. declare module "babylonjs/Animations/animationEvent" {
  6788. /**
  6789. * Composed of a frame, and an action function
  6790. */
  6791. export class AnimationEvent {
  6792. /** The frame for which the event is triggered **/
  6793. frame: number;
  6794. /** The event to perform when triggered **/
  6795. action: (currentFrame: number) => void;
  6796. /** Specifies if the event should be triggered only once**/
  6797. onlyOnce?: boolean | undefined;
  6798. /**
  6799. * Specifies if the animation event is done
  6800. */
  6801. isDone: boolean;
  6802. /**
  6803. * Initializes the animation event
  6804. * @param frame The frame for which the event is triggered
  6805. * @param action The event to perform when triggered
  6806. * @param onlyOnce Specifies if the event should be triggered only once
  6807. */
  6808. constructor(
  6809. /** The frame for which the event is triggered **/
  6810. frame: number,
  6811. /** The event to perform when triggered **/
  6812. action: (currentFrame: number) => void,
  6813. /** Specifies if the event should be triggered only once**/
  6814. onlyOnce?: boolean | undefined);
  6815. /** @hidden */
  6816. _clone(): AnimationEvent;
  6817. }
  6818. }
  6819. declare module "babylonjs/Behaviors/behavior" {
  6820. import { Nullable } from "babylonjs/types";
  6821. /**
  6822. * Interface used to define a behavior
  6823. */
  6824. export interface Behavior<T> {
  6825. /** gets or sets behavior's name */
  6826. name: string;
  6827. /**
  6828. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6829. */
  6830. init(): void;
  6831. /**
  6832. * Called when the behavior is attached to a target
  6833. * @param target defines the target where the behavior is attached to
  6834. */
  6835. attach(target: T): void;
  6836. /**
  6837. * Called when the behavior is detached from its target
  6838. */
  6839. detach(): void;
  6840. }
  6841. /**
  6842. * Interface implemented by classes supporting behaviors
  6843. */
  6844. export interface IBehaviorAware<T> {
  6845. /**
  6846. * Attach a behavior
  6847. * @param behavior defines the behavior to attach
  6848. * @returns the current host
  6849. */
  6850. addBehavior(behavior: Behavior<T>): T;
  6851. /**
  6852. * Remove a behavior from the current object
  6853. * @param behavior defines the behavior to detach
  6854. * @returns the current host
  6855. */
  6856. removeBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Gets a behavior using its name to search
  6859. * @param name defines the name to search
  6860. * @returns the behavior or null if not found
  6861. */
  6862. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6863. }
  6864. }
  6865. declare module "babylonjs/Collisions/intersectionInfo" {
  6866. import { Nullable } from "babylonjs/types";
  6867. /**
  6868. * @hidden
  6869. */
  6870. export class IntersectionInfo {
  6871. bu: Nullable<number>;
  6872. bv: Nullable<number>;
  6873. distance: number;
  6874. faceId: number;
  6875. subMeshId: number;
  6876. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6882. /**
  6883. * Class used to store bounding sphere information
  6884. */
  6885. export class BoundingSphere {
  6886. /**
  6887. * Gets the center of the bounding sphere in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in local space
  6892. */
  6893. radius: number;
  6894. /**
  6895. * Gets the center of the bounding sphere in world space
  6896. */
  6897. readonly centerWorld: Vector3;
  6898. /**
  6899. * Radius of the bounding sphere in world space
  6900. */
  6901. radiusWorld: number;
  6902. /**
  6903. * Gets the minimum vector in local space
  6904. */
  6905. readonly minimum: Vector3;
  6906. /**
  6907. * Gets the maximum vector in local space
  6908. */
  6909. readonly maximum: Vector3;
  6910. private _worldMatrix;
  6911. private static readonly TmpVector3;
  6912. /**
  6913. * Creates a new bounding sphere
  6914. * @param min defines the minimum vector (in local space)
  6915. * @param max defines the maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6919. /**
  6920. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6921. * @param min defines the new minimum vector (in local space)
  6922. * @param max defines the new maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6926. /**
  6927. * Scale the current bounding sphere by applying a scale factor
  6928. * @param factor defines the scale factor to apply
  6929. * @returns the current bounding box
  6930. */
  6931. scale(factor: number): BoundingSphere;
  6932. /**
  6933. * Gets the world matrix of the bounding box
  6934. * @returns a matrix
  6935. */
  6936. getWorldMatrix(): DeepImmutable<Matrix>;
  6937. /** @hidden */
  6938. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6939. /**
  6940. * Tests if the bounding sphere is intersecting the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an intersection
  6943. */
  6944. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if the bounding sphere center is in between the frustum planes.
  6947. * Used for optimistic fast inclusion.
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if the sphere center is in between the frustum planes
  6950. */
  6951. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if a point is inside the bounding sphere
  6954. * @param point defines the point to test
  6955. * @returns true if the point is inside the bounding sphere
  6956. */
  6957. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6958. /**
  6959. * Checks if two sphere intersct
  6960. * @param sphere0 sphere 0
  6961. * @param sphere1 sphere 1
  6962. * @returns true if the speres intersect
  6963. */
  6964. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Culling/boundingBox" {
  6968. import { DeepImmutable } from "babylonjs/types";
  6969. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6970. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6971. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6972. /**
  6973. * Class used to store bounding box information
  6974. */
  6975. export class BoundingBox implements ICullable {
  6976. /**
  6977. * Gets the 8 vectors representing the bounding box in local space
  6978. */
  6979. readonly vectors: Vector3[];
  6980. /**
  6981. * Gets the center of the bounding box in local space
  6982. */
  6983. readonly center: Vector3;
  6984. /**
  6985. * Gets the center of the bounding box in world space
  6986. */
  6987. readonly centerWorld: Vector3;
  6988. /**
  6989. * Gets the extend size in local space
  6990. */
  6991. readonly extendSize: Vector3;
  6992. /**
  6993. * Gets the extend size in world space
  6994. */
  6995. readonly extendSizeWorld: Vector3;
  6996. /**
  6997. * Gets the OBB (object bounding box) directions
  6998. */
  6999. readonly directions: Vector3[];
  7000. /**
  7001. * Gets the 8 vectors representing the bounding box in world space
  7002. */
  7003. readonly vectorsWorld: Vector3[];
  7004. /**
  7005. * Gets the minimum vector in world space
  7006. */
  7007. readonly minimumWorld: Vector3;
  7008. /**
  7009. * Gets the maximum vector in world space
  7010. */
  7011. readonly maximumWorld: Vector3;
  7012. /**
  7013. * Gets the minimum vector in local space
  7014. */
  7015. readonly minimum: Vector3;
  7016. /**
  7017. * Gets the maximum vector in local space
  7018. */
  7019. readonly maximum: Vector3;
  7020. private _worldMatrix;
  7021. private static readonly TmpVector3;
  7022. /**
  7023. * @hidden
  7024. */
  7025. _tag: number;
  7026. /**
  7027. * Creates a new bounding box
  7028. * @param min defines the minimum vector (in local space)
  7029. * @param max defines the maximum vector (in local space)
  7030. * @param worldMatrix defines the new world matrix
  7031. */
  7032. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7033. /**
  7034. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7035. * @param min defines the new minimum vector (in local space)
  7036. * @param max defines the new maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7040. /**
  7041. * Scale the current bounding box by applying a scale factor
  7042. * @param factor defines the scale factor to apply
  7043. * @returns the current bounding box
  7044. */
  7045. scale(factor: number): BoundingBox;
  7046. /**
  7047. * Gets the world matrix of the bounding box
  7048. * @returns a matrix
  7049. */
  7050. getWorldMatrix(): DeepImmutable<Matrix>;
  7051. /** @hidden */
  7052. _update(world: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Tests if the bounding box is intersecting the frustum planes
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. /**
  7060. * Tests if the bounding box is entirely inside the frustum planes
  7061. * @param frustumPlanes defines the frustum planes to test
  7062. * @returns true if there is an inclusion
  7063. */
  7064. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7065. /**
  7066. * Tests if a point is inside the bounding box
  7067. * @param point defines the point to test
  7068. * @returns true if the point is inside the bounding box
  7069. */
  7070. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7071. /**
  7072. * Tests if the bounding box intersects with a bounding sphere
  7073. * @param sphere defines the sphere to test
  7074. * @returns true if there is an intersection
  7075. */
  7076. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7077. /**
  7078. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7079. * @param min defines the min vector to use
  7080. * @param max defines the max vector to use
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if two bounding boxes are intersections
  7086. * @param box0 defines the first box to test
  7087. * @param box1 defines the second box to test
  7088. * @returns true if there is an intersection
  7089. */
  7090. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7091. /**
  7092. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7093. * @param minPoint defines the minimum vector of the bounding box
  7094. * @param maxPoint defines the maximum vector of the bounding box
  7095. * @param sphereCenter defines the sphere center
  7096. * @param sphereRadius defines the sphere radius
  7097. * @returns true if there is an intersection
  7098. */
  7099. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7100. /**
  7101. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7102. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @return true if there is an inclusion
  7105. */
  7106. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an intersection
  7112. */
  7113. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. }
  7115. }
  7116. declare module "babylonjs/Collisions/collider" {
  7117. import { Nullable, IndicesArray } from "babylonjs/types";
  7118. import { Vector3, Plane } from "babylonjs/Maths/math";
  7119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. collisionMask: number;
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. readonly slidePlaneNormal: Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Collider } from "babylonjs/Collisions/collider";
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. readonly minimum: Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. readonly maximum: Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. isLocked: boolean;
  7246. /**
  7247. * Updates the bounding sphere and box
  7248. * @param world world matrix to be used to update
  7249. */
  7250. update(world: DeepImmutable<Matrix>): void;
  7251. /**
  7252. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7253. * @param center New center of the bounding info
  7254. * @param extend New extend of the bounding info
  7255. * @returns the current bounding info
  7256. */
  7257. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7258. /**
  7259. * Scale the current bounding info by applying a scale factor
  7260. * @param factor defines the scale factor to apply
  7261. * @returns the current bounding info
  7262. */
  7263. scale(factor: number): BoundingInfo;
  7264. /**
  7265. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7266. * @param frustumPlanes defines the frustum to test
  7267. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7268. * @returns true if the bounding info is in the frustum planes
  7269. */
  7270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7271. /**
  7272. * Gets the world distance between the min and max points of the bounding box
  7273. */
  7274. readonly diagonalLength: number;
  7275. /**
  7276. * Checks if a cullable object (mesh...) is in the camera frustum
  7277. * Unlike isInFrustum this cheks the full bounding box
  7278. * @param frustumPlanes Camera near/planes
  7279. * @returns true if the object is in frustum otherwise false
  7280. */
  7281. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /** @hidden */
  7283. _checkCollision(collider: Collider): boolean;
  7284. /**
  7285. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param point the point to check intersection with
  7288. * @returns if the point intersects
  7289. */
  7290. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7291. /**
  7292. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param boundingInfo the bounding info to check intersection with
  7295. * @param precise if the intersection should be done using OBB
  7296. * @returns if the bounding info intersects
  7297. */
  7298. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7299. }
  7300. }
  7301. declare module "babylonjs/Misc/smartArray" {
  7302. /**
  7303. * Defines an array and its length.
  7304. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7305. */
  7306. export interface ISmartArrayLike<T> {
  7307. /**
  7308. * The data of the array.
  7309. */
  7310. data: Array<T>;
  7311. /**
  7312. * The active length of the array.
  7313. */
  7314. length: number;
  7315. }
  7316. /**
  7317. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7318. */
  7319. export class SmartArray<T> implements ISmartArrayLike<T> {
  7320. /**
  7321. * The full set of data from the array.
  7322. */
  7323. data: Array<T>;
  7324. /**
  7325. * The active length of the array.
  7326. */
  7327. length: number;
  7328. protected _id: number;
  7329. /**
  7330. * Instantiates a Smart Array.
  7331. * @param capacity defines the default capacity of the array.
  7332. */
  7333. constructor(capacity: number);
  7334. /**
  7335. * Pushes a value at the end of the active data.
  7336. * @param value defines the object to push in the array.
  7337. */
  7338. push(value: T): void;
  7339. /**
  7340. * Iterates over the active data and apply the lambda to them.
  7341. * @param func defines the action to apply on each value.
  7342. */
  7343. forEach(func: (content: T) => void): void;
  7344. /**
  7345. * Sorts the full sets of data.
  7346. * @param compareFn defines the comparison function to apply.
  7347. */
  7348. sort(compareFn: (a: T, b: T) => number): void;
  7349. /**
  7350. * Resets the active data to an empty array.
  7351. */
  7352. reset(): void;
  7353. /**
  7354. * Releases all the data from the array as well as the array.
  7355. */
  7356. dispose(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * @param array defines the data to concatenate with.
  7360. */
  7361. concat(array: any): void;
  7362. /**
  7363. * Returns the position of a value in the active data.
  7364. * @param value defines the value to find the index for
  7365. * @returns the index if found in the active data otherwise -1
  7366. */
  7367. indexOf(value: T): number;
  7368. /**
  7369. * Returns whether an element is part of the active data.
  7370. * @param value defines the value to look for
  7371. * @returns true if found in the active data otherwise false
  7372. */
  7373. contains(value: T): boolean;
  7374. private static _GlobalId;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. * The data in this array can only be present once
  7379. */
  7380. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7381. private _duplicateId;
  7382. /**
  7383. * Pushes a value at the end of the active data.
  7384. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7385. * @param value defines the object to push in the array.
  7386. */
  7387. push(value: T): void;
  7388. /**
  7389. * Pushes a value at the end of the active data.
  7390. * If the data is already present, it won t be added again
  7391. * @param value defines the object to push in the array.
  7392. * @returns true if added false if it was already present
  7393. */
  7394. pushNoDuplicate(value: T): boolean;
  7395. /**
  7396. * Resets the active data to an empty array.
  7397. */
  7398. reset(): void;
  7399. /**
  7400. * Concats the active data with a given array.
  7401. * This ensures no dupplicate will be present in the result.
  7402. * @param array defines the data to concatenate with.
  7403. */
  7404. concatWithNoDuplicate(array: any): void;
  7405. }
  7406. }
  7407. declare module "babylonjs/Materials/multiMaterial" {
  7408. import { Nullable } from "babylonjs/types";
  7409. import { Scene } from "babylonjs/scene";
  7410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7411. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7413. import { Material } from "babylonjs/Materials/material";
  7414. /**
  7415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7416. * separate meshes. This can be use to improve performances.
  7417. * @see http://doc.babylonjs.com/how_to/multi_materials
  7418. */
  7419. export class MultiMaterial extends Material {
  7420. private _subMaterials;
  7421. /**
  7422. * Gets or Sets the list of Materials used within the multi material.
  7423. * They need to be ordered according to the submeshes order in the associated mesh
  7424. */
  7425. subMaterials: Nullable<Material>[];
  7426. /**
  7427. * Function used to align with Node.getChildren()
  7428. * @returns the list of Materials used within the multi material
  7429. */
  7430. getChildren(): Nullable<Material>[];
  7431. /**
  7432. * Instantiates a new Multi Material
  7433. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7434. * separate meshes. This can be use to improve performances.
  7435. * @see http://doc.babylonjs.com/how_to/multi_materials
  7436. * @param name Define the name in the scene
  7437. * @param scene Define the scene the material belongs to
  7438. */
  7439. constructor(name: string, scene: Scene);
  7440. private _hookArray;
  7441. /**
  7442. * Get one of the submaterial by its index in the submaterials array
  7443. * @param index The index to look the sub material at
  7444. * @returns The Material if the index has been defined
  7445. */
  7446. getSubMaterial(index: number): Nullable<Material>;
  7447. /**
  7448. * Get the list of active textures for the whole sub materials list.
  7449. * @returns All the textures that will be used during the rendering
  7450. */
  7451. getActiveTextures(): BaseTexture[];
  7452. /**
  7453. * Gets the current class name of the material e.g. "MultiMaterial"
  7454. * Mainly use in serialization.
  7455. * @returns the class name
  7456. */
  7457. getClassName(): string;
  7458. /**
  7459. * Checks if the material is ready to render the requested sub mesh
  7460. * @param mesh Define the mesh the submesh belongs to
  7461. * @param subMesh Define the sub mesh to look readyness for
  7462. * @param useInstances Define whether or not the material is used with instances
  7463. * @returns true if ready, otherwise false
  7464. */
  7465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7466. /**
  7467. * Clones the current material and its related sub materials
  7468. * @param name Define the name of the newly cloned material
  7469. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7470. * @returns the cloned material
  7471. */
  7472. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7473. /**
  7474. * Serializes the materials into a JSON representation.
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Dispose the material and release its associated resources
  7480. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7481. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7482. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7483. */
  7484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7485. /**
  7486. * Creates a MultiMaterial from parsed MultiMaterial data.
  7487. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7488. * @param scene defines the hosting scene
  7489. * @returns a new MultiMaterial
  7490. */
  7491. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7492. }
  7493. }
  7494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7495. /**
  7496. * Class used to represent data loading progression
  7497. */
  7498. export class SceneLoaderFlags {
  7499. private static _ForceFullSceneLoadingForIncremental;
  7500. private static _ShowLoadingScreen;
  7501. private static _CleanBoneMatrixWeights;
  7502. private static _loggingLevel;
  7503. /**
  7504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7505. */
  7506. static ForceFullSceneLoadingForIncremental: boolean;
  7507. /**
  7508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7509. */
  7510. static ShowLoadingScreen: boolean;
  7511. /**
  7512. * Defines the current logging level (while loading the scene)
  7513. * @ignorenaming
  7514. */
  7515. static loggingLevel: number;
  7516. /**
  7517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7518. */
  7519. static CleanBoneMatrixWeights: boolean;
  7520. }
  7521. }
  7522. declare module "babylonjs/Meshes/transformNode" {
  7523. import { DeepImmutable } from "babylonjs/types";
  7524. import { Observable } from "babylonjs/Misc/observable";
  7525. import { Nullable } from "babylonjs/types";
  7526. import { Camera } from "babylonjs/Cameras/camera";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7529. import { Node } from "babylonjs/node";
  7530. import { Bone } from "babylonjs/Bones/bone";
  7531. /**
  7532. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7533. * @see https://doc.babylonjs.com/how_to/transformnode
  7534. */
  7535. export class TransformNode extends Node {
  7536. /**
  7537. * Object will not rotate to face the camera
  7538. */
  7539. static BILLBOARDMODE_NONE: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the x axis
  7542. */
  7543. static BILLBOARDMODE_X: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the y axis
  7546. */
  7547. static BILLBOARDMODE_Y: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the z axis
  7550. */
  7551. static BILLBOARDMODE_Z: number;
  7552. /**
  7553. * Object will rotate to face the camera
  7554. */
  7555. static BILLBOARDMODE_ALL: number;
  7556. private _forward;
  7557. private _forwardInverted;
  7558. private _up;
  7559. private _right;
  7560. private _rightInverted;
  7561. private _position;
  7562. private _rotation;
  7563. private _rotationQuaternion;
  7564. protected _scaling: Vector3;
  7565. protected _isDirty: boolean;
  7566. private _transformToBoneReferal;
  7567. /**
  7568. * Set the billboard mode. Default is 0.
  7569. *
  7570. * | Value | Type | Description |
  7571. * | --- | --- | --- |
  7572. * | 0 | BILLBOARDMODE_NONE | |
  7573. * | 1 | BILLBOARDMODE_X | |
  7574. * | 2 | BILLBOARDMODE_Y | |
  7575. * | 4 | BILLBOARDMODE_Z | |
  7576. * | 7 | BILLBOARDMODE_ALL | |
  7577. *
  7578. */
  7579. billboardMode: number;
  7580. /**
  7581. * 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
  7582. */
  7583. scalingDeterminant: number;
  7584. /**
  7585. * Sets the distance of the object to max, often used by skybox
  7586. */
  7587. infiniteDistance: boolean;
  7588. /**
  7589. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7590. * By default the system will update normals to compensate
  7591. */
  7592. ignoreNonUniformScaling: boolean;
  7593. /** @hidden */
  7594. _poseMatrix: Matrix;
  7595. /** @hidden */
  7596. _localMatrix: Matrix;
  7597. private _absolutePosition;
  7598. private _pivotMatrix;
  7599. private _pivotMatrixInverse;
  7600. protected _postMultiplyPivotMatrix: boolean;
  7601. private _tempMatrix;
  7602. private _tempMatrix2;
  7603. protected _isWorldMatrixFrozen: boolean;
  7604. /** @hidden */
  7605. _indexInSceneTransformNodesArray: number;
  7606. /**
  7607. * An event triggered after the world matrix is updated
  7608. */
  7609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7611. /**
  7612. * Gets a string identifying the name of the class
  7613. * @returns "TransformNode" string
  7614. */
  7615. getClassName(): string;
  7616. /**
  7617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7618. */
  7619. position: Vector3;
  7620. /**
  7621. * 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)).
  7622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7623. */
  7624. rotation: Vector3;
  7625. /**
  7626. * 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)).
  7627. */
  7628. scaling: Vector3;
  7629. /**
  7630. * 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).
  7631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7632. */
  7633. rotationQuaternion: Nullable<Quaternion>;
  7634. /**
  7635. * The forward direction of that transform in world space.
  7636. */
  7637. readonly forward: Vector3;
  7638. /**
  7639. * The up direction of that transform in world space.
  7640. */
  7641. readonly up: Vector3;
  7642. /**
  7643. * The right direction of that transform in world space.
  7644. */
  7645. readonly right: Vector3;
  7646. /**
  7647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7648. * @param matrix the matrix to copy the pose from
  7649. * @returns this TransformNode.
  7650. */
  7651. updatePoseMatrix(matrix: Matrix): TransformNode;
  7652. /**
  7653. * Returns the mesh Pose matrix.
  7654. * @returns the pose matrix
  7655. */
  7656. getPoseMatrix(): Matrix;
  7657. /** @hidden */
  7658. _isSynchronized(): boolean;
  7659. /** @hidden */
  7660. _initCache(): void;
  7661. /**
  7662. * Flag the transform node as dirty (Forcing it to update everything)
  7663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7664. * @returns this transform node
  7665. */
  7666. markAsDirty(property: string): TransformNode;
  7667. /**
  7668. * Returns the current mesh absolute position.
  7669. * Returns a Vector3.
  7670. */
  7671. readonly absolutePosition: Vector3;
  7672. /**
  7673. * Sets a new matrix to apply before all other transformation
  7674. * @param matrix defines the transform matrix
  7675. * @returns the current TransformNode
  7676. */
  7677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7678. /**
  7679. * Sets a new pivot matrix to the current node
  7680. * @param matrix defines the new pivot matrix to use
  7681. * @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
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7685. /**
  7686. * Returns the mesh pivot matrix.
  7687. * Default : Identity.
  7688. * @returns the matrix
  7689. */
  7690. getPivotMatrix(): Matrix;
  7691. /**
  7692. * Prevents the World matrix to be computed any longer.
  7693. * @returns the TransformNode.
  7694. */
  7695. freezeWorldMatrix(): TransformNode;
  7696. /**
  7697. * Allows back the World matrix computation.
  7698. * @returns the TransformNode.
  7699. */
  7700. unfreezeWorldMatrix(): this;
  7701. /**
  7702. * True if the World matrix has been frozen.
  7703. */
  7704. readonly isWorldMatrixFrozen: boolean;
  7705. /**
  7706. * Retuns the mesh absolute position in the World.
  7707. * @returns a Vector3.
  7708. */
  7709. getAbsolutePosition(): Vector3;
  7710. /**
  7711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7712. * @param absolutePosition the absolute position to set
  7713. * @returns the TransformNode.
  7714. */
  7715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7716. /**
  7717. * Sets the mesh position in its local space.
  7718. * @param vector3 the position to set in localspace
  7719. * @returns the TransformNode.
  7720. */
  7721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7722. /**
  7723. * Returns the mesh position in the local space from the current World matrix values.
  7724. * @returns a new Vector3.
  7725. */
  7726. getPositionExpressedInLocalSpace(): Vector3;
  7727. /**
  7728. * Translates the mesh along the passed Vector3 in its local space.
  7729. * @param vector3 the distance to translate in localspace
  7730. * @returns the TransformNode.
  7731. */
  7732. locallyTranslate(vector3: Vector3): TransformNode;
  7733. private static _lookAtVectorCache;
  7734. /**
  7735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7736. * @param targetPoint the position (must be in same space as current mesh) to look at
  7737. * @param yawCor optional yaw (y-axis) correction in radians
  7738. * @param pitchCor optional pitch (x-axis) correction in radians
  7739. * @param rollCor optional roll (z-axis) correction in radians
  7740. * @param space the choosen space of the target
  7741. * @returns the TransformNode.
  7742. */
  7743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7744. /**
  7745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7746. * This Vector3 is expressed in the World space.
  7747. * @param localAxis axis to rotate
  7748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7749. */
  7750. getDirection(localAxis: Vector3): Vector3;
  7751. /**
  7752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7753. * localAxis is expressed in the mesh local space.
  7754. * result is computed in the Wordl space from the mesh World matrix.
  7755. * @param localAxis axis to rotate
  7756. * @param result the resulting transformnode
  7757. * @returns this TransformNode.
  7758. */
  7759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7760. /**
  7761. * Sets this transform node rotation to the given local axis.
  7762. * @param localAxis the axis in local space
  7763. * @param yawCor optional yaw (y-axis) correction in radians
  7764. * @param pitchCor optional pitch (x-axis) correction in radians
  7765. * @param rollCor optional roll (z-axis) correction in radians
  7766. * @returns this TransformNode
  7767. */
  7768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7769. /**
  7770. * Sets a new pivot point to the current node
  7771. * @param point defines the new pivot point to use
  7772. * @param space defines if the point is in world or local space (local by default)
  7773. * @returns the current TransformNode
  7774. */
  7775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7776. /**
  7777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7778. * @returns the pivot point
  7779. */
  7780. getPivotPoint(): Vector3;
  7781. /**
  7782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7783. * @param result the vector3 to store the result
  7784. * @returns this TransformNode.
  7785. */
  7786. getPivotPointToRef(result: Vector3): TransformNode;
  7787. /**
  7788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7790. */
  7791. getAbsolutePivotPoint(): Vector3;
  7792. /**
  7793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7794. * @param result vector3 to store the result
  7795. * @returns this TransformNode.
  7796. */
  7797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7798. /**
  7799. * Defines the passed node as the parent of the current node.
  7800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7801. * @see https://doc.babylonjs.com/how_to/parenting
  7802. * @param node the node ot set as the parent
  7803. * @returns this TransformNode.
  7804. */
  7805. setParent(node: Nullable<Node>): TransformNode;
  7806. private _nonUniformScaling;
  7807. /**
  7808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7809. */
  7810. readonly nonUniformScaling: boolean;
  7811. /** @hidden */
  7812. _updateNonUniformScalingState(value: boolean): boolean;
  7813. /**
  7814. * Attach the current TransformNode to another TransformNode associated with a bone
  7815. * @param bone Bone affecting the TransformNode
  7816. * @param affectedTransformNode TransformNode associated with the bone
  7817. * @returns this object
  7818. */
  7819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7820. /**
  7821. * Detach the transform node if its associated with a bone
  7822. * @returns this object
  7823. */
  7824. detachFromBone(): TransformNode;
  7825. private static _rotationAxisCache;
  7826. /**
  7827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized.
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @param space Space to rotate in (Default: local)
  7834. * @returns the TransformNode.
  7835. */
  7836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7837. /**
  7838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7840. * The passed axis is also normalized. .
  7841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7842. * @param point the point to rotate around
  7843. * @param axis the axis to rotate around
  7844. * @param amount the amount to rotate in radians
  7845. * @returns the TransformNode
  7846. */
  7847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7848. /**
  7849. * Translates the mesh along the axis vector for the passed distance in the given space.
  7850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7851. * @param axis the axis to translate in
  7852. * @param distance the distance to translate
  7853. * @param space Space to rotate in (Default: local)
  7854. * @returns the TransformNode.
  7855. */
  7856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7857. /**
  7858. * Adds a rotation step to the mesh current rotation.
  7859. * x, y, z are Euler angles expressed in radians.
  7860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7861. * This means this rotation is made in the mesh local space only.
  7862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7864. * ```javascript
  7865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7866. * ```
  7867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7868. * 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.
  7869. * @param x Rotation to add
  7870. * @param y Rotation to add
  7871. * @param z Rotation to add
  7872. * @returns the TransformNode.
  7873. */
  7874. addRotation(x: number, y: number, z: number): TransformNode;
  7875. /**
  7876. * Computes the world matrix of the node
  7877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7878. * @returns the world matrix
  7879. */
  7880. computeWorldMatrix(force?: boolean): Matrix;
  7881. protected _afterComputeWorldMatrix(): void;
  7882. /**
  7883. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7884. * @param func callback function to add
  7885. *
  7886. * @returns the TransformNode.
  7887. */
  7888. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Removes a registered callback function.
  7891. * @param func callback function to remove
  7892. * @returns the TransformNode.
  7893. */
  7894. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7895. /**
  7896. * Gets the position of the current mesh in camera space
  7897. * @param camera defines the camera to use
  7898. * @returns a position
  7899. */
  7900. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7901. /**
  7902. * Returns the distance from the mesh to the active camera
  7903. * @param camera defines the camera to use
  7904. * @returns the distance
  7905. */
  7906. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7907. /**
  7908. * Clone the current transform node
  7909. * @param name Name of the new clone
  7910. * @param newParent New parent for the clone
  7911. * @param doNotCloneChildren Do not clone children hierarchy
  7912. * @returns the new transform node
  7913. */
  7914. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7915. /**
  7916. * Serializes the objects information.
  7917. * @param currentSerializationObject defines the object to serialize in
  7918. * @returns the serialized object
  7919. */
  7920. serialize(currentSerializationObject?: any): any;
  7921. /**
  7922. * Returns a new TransformNode object parsed from the source provided.
  7923. * @param parsedTransformNode is the source.
  7924. * @param scene the scne the object belongs to
  7925. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7926. * @returns a new TransformNode object parsed from the source provided.
  7927. */
  7928. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7929. /**
  7930. * Get all child-transformNodes of this node
  7931. * @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
  7932. * @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
  7933. * @returns an array of TransformNode
  7934. */
  7935. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7936. /**
  7937. * Releases resources associated with this transform node.
  7938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7940. */
  7941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7942. }
  7943. }
  7944. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7945. /**
  7946. * Class used to override all child animations of a given target
  7947. */
  7948. export class AnimationPropertiesOverride {
  7949. /**
  7950. * Gets or sets a value indicating if animation blending must be used
  7951. */
  7952. enableBlending: boolean;
  7953. /**
  7954. * Gets or sets the blending speed to use when enableBlending is true
  7955. */
  7956. blendingSpeed: number;
  7957. /**
  7958. * Gets or sets the default loop mode to use
  7959. */
  7960. loopMode: number;
  7961. }
  7962. }
  7963. declare module "babylonjs/Bones/bone" {
  7964. import { Skeleton } from "babylonjs/Bones/skeleton";
  7965. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7966. import { Nullable } from "babylonjs/types";
  7967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7969. import { Node } from "babylonjs/node";
  7970. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7971. /**
  7972. * Class used to store bone information
  7973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7974. */
  7975. export class Bone extends Node {
  7976. /**
  7977. * defines the bone name
  7978. */
  7979. name: string;
  7980. private static _tmpVecs;
  7981. private static _tmpQuat;
  7982. private static _tmpMats;
  7983. /**
  7984. * Gets the list of child bones
  7985. */
  7986. children: Bone[];
  7987. /** Gets the animations associated with this bone */
  7988. animations: import("babylonjs/Animations/animation").Animation[];
  7989. /**
  7990. * Gets or sets bone length
  7991. */
  7992. length: number;
  7993. /**
  7994. * @hidden Internal only
  7995. * Set this value to map this bone to a different index in the transform matrices
  7996. * Set this value to -1 to exclude the bone from the transform matrices
  7997. */
  7998. _index: Nullable<number>;
  7999. private _skeleton;
  8000. private _localMatrix;
  8001. private _restPose;
  8002. private _baseMatrix;
  8003. private _absoluteTransform;
  8004. private _invertedAbsoluteTransform;
  8005. private _parent;
  8006. private _scalingDeterminant;
  8007. private _worldTransform;
  8008. private _localScaling;
  8009. private _localRotation;
  8010. private _localPosition;
  8011. private _needToDecompose;
  8012. private _needToCompose;
  8013. /** @hidden */
  8014. _linkedTransformNode: Nullable<TransformNode>;
  8015. /** @hidden */
  8016. /** @hidden */
  8017. _matrix: Matrix;
  8018. /**
  8019. * Create a new bone
  8020. * @param name defines the bone name
  8021. * @param skeleton defines the parent skeleton
  8022. * @param parentBone defines the parent (can be null if the bone is the root)
  8023. * @param localMatrix defines the local matrix
  8024. * @param restPose defines the rest pose matrix
  8025. * @param baseMatrix defines the base matrix
  8026. * @param index defines index of the bone in the hiearchy
  8027. */
  8028. constructor(
  8029. /**
  8030. * defines the bone name
  8031. */
  8032. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8033. /**
  8034. * Gets the current object class name.
  8035. * @return the class name
  8036. */
  8037. getClassName(): string;
  8038. /**
  8039. * Gets the parent skeleton
  8040. * @returns a skeleton
  8041. */
  8042. getSkeleton(): Skeleton;
  8043. /**
  8044. * Gets parent bone
  8045. * @returns a bone or null if the bone is the root of the bone hierarchy
  8046. */
  8047. getParent(): Nullable<Bone>;
  8048. /**
  8049. * Returns an array containing the root bones
  8050. * @returns an array containing the root bones
  8051. */
  8052. getChildren(): Array<Bone>;
  8053. /**
  8054. * Sets the parent bone
  8055. * @param parent defines the parent (can be null if the bone is the root)
  8056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8057. */
  8058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8059. /**
  8060. * Gets the local matrix
  8061. * @returns a matrix
  8062. */
  8063. getLocalMatrix(): Matrix;
  8064. /**
  8065. * Gets the base matrix (initial matrix which remains unchanged)
  8066. * @returns a matrix
  8067. */
  8068. getBaseMatrix(): Matrix;
  8069. /**
  8070. * Gets the rest pose matrix
  8071. * @returns a matrix
  8072. */
  8073. getRestPose(): Matrix;
  8074. /**
  8075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8076. */
  8077. getWorldMatrix(): Matrix;
  8078. /**
  8079. * Sets the local matrix to rest pose matrix
  8080. */
  8081. returnToRest(): void;
  8082. /**
  8083. * Gets the inverse of the absolute transform matrix.
  8084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8085. * @returns a matrix
  8086. */
  8087. getInvertedAbsoluteTransform(): Matrix;
  8088. /**
  8089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8090. * @returns a matrix
  8091. */
  8092. getAbsoluteTransform(): Matrix;
  8093. /**
  8094. * Links with the given transform node.
  8095. * The local matrix of this bone is copied from the transform node every frame.
  8096. * @param transformNode defines the transform node to link to
  8097. */
  8098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8099. /** Gets or sets current position (in local space) */
  8100. position: Vector3;
  8101. /** Gets or sets current rotation (in local space) */
  8102. rotation: Vector3;
  8103. /** Gets or sets current rotation quaternion (in local space) */
  8104. rotationQuaternion: Quaternion;
  8105. /** Gets or sets current scaling (in local space) */
  8106. scaling: Vector3;
  8107. /**
  8108. * Gets the animation properties override
  8109. */
  8110. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8111. private _decompose;
  8112. private _compose;
  8113. /**
  8114. * Update the base and local matrices
  8115. * @param matrix defines the new base or local matrix
  8116. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8117. * @param updateLocalMatrix defines if the local matrix should be updated
  8118. */
  8119. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8120. /** @hidden */
  8121. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8122. /**
  8123. * Flag the bone as dirty (Forcing it to update everything)
  8124. */
  8125. markAsDirty(): void;
  8126. private _markAsDirtyAndCompose;
  8127. private _markAsDirtyAndDecompose;
  8128. /**
  8129. * Translate the bone in local or world space
  8130. * @param vec The amount to translate the bone
  8131. * @param space The space that the translation is in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. */
  8134. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8135. /**
  8136. * Set the postion of the bone in local or world space
  8137. * @param position The position to set the bone
  8138. * @param space The space that the position is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. */
  8141. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8142. /**
  8143. * Set the absolute position of the bone (world space)
  8144. * @param position The position to set the bone
  8145. * @param mesh The mesh that this bone is attached to
  8146. */
  8147. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8148. /**
  8149. * Scale the bone on the x, y and z axes (in local space)
  8150. * @param x The amount to scale the bone on the x axis
  8151. * @param y The amount to scale the bone on the y axis
  8152. * @param z The amount to scale the bone on the z axis
  8153. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8154. */
  8155. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8156. /**
  8157. * Set the bone scaling in local space
  8158. * @param scale defines the scaling vector
  8159. */
  8160. setScale(scale: Vector3): void;
  8161. /**
  8162. * Gets the current scaling in local space
  8163. * @returns the current scaling vector
  8164. */
  8165. getScale(): Vector3;
  8166. /**
  8167. * Gets the current scaling in local space and stores it in a target vector
  8168. * @param result defines the target vector
  8169. */
  8170. getScaleToRef(result: Vector3): void;
  8171. /**
  8172. * Set the yaw, pitch, and roll of the bone in local or world space
  8173. * @param yaw The rotation of the bone on the y axis
  8174. * @param pitch The rotation of the bone on the x axis
  8175. * @param roll The rotation of the bone on the z axis
  8176. * @param space The space that the axes of rotation are in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Add a rotation to the bone on an axis in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param amount The amount to rotate the bone
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the rotation of the bone to a particular axis angle in local or world space
  8190. * @param axis The axis to rotate the bone on
  8191. * @param angle The angle that the bone should be rotated to
  8192. * @param space The space that the axis is in
  8193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8194. */
  8195. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Set the euler rotation of the bone in local of world space
  8198. * @param rotation The euler rotation that the bone should be set to
  8199. * @param space The space that the rotation is in
  8200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8201. */
  8202. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8203. /**
  8204. * Set the quaternion rotation of the bone in local of world space
  8205. * @param quat The quaternion rotation that the bone should be set to
  8206. * @param space The space that the rotation is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the rotation matrix of the bone in local of world space
  8212. * @param rotMat The rotation matrix that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8217. private _rotateWithMatrix;
  8218. private _getNegativeRotationToRef;
  8219. /**
  8220. * Get the position of the bone in local or world space
  8221. * @param space The space that the returned position is in
  8222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8223. * @returns The position of the bone
  8224. */
  8225. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8226. /**
  8227. * Copy the position of the bone to a vector3 in local or world space
  8228. * @param space The space that the returned position is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. * @param result The vector3 to copy the position to
  8231. */
  8232. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8233. /**
  8234. * Get the absolute position of the bone (world space)
  8235. * @param mesh The mesh that this bone is attached to
  8236. * @returns The absolute position of the bone
  8237. */
  8238. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8239. /**
  8240. * Copy the absolute position of the bone (world space) to the result param
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @param result The vector3 to copy the absolute position to
  8243. */
  8244. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8245. /**
  8246. * Compute the absolute transforms of this bone and its children
  8247. */
  8248. computeAbsoluteTransforms(): void;
  8249. /**
  8250. * Get the world direction from an axis that is in the local space of the bone
  8251. * @param localAxis The local direction that is used to compute the world direction
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The world direction
  8254. */
  8255. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8258. * @param localAxis The local direction that is used to compute the world direction
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the world direction will be copied to
  8261. */
  8262. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. /**
  8264. * Get the euler rotation of the bone in local or world space
  8265. * @param space The space that the rotation should be in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. * @returns The euler rotation
  8268. */
  8269. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8270. /**
  8271. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8272. * @param space The space that the rotation should be in
  8273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8274. * @param result The vector3 that the rotation should be copied to
  8275. */
  8276. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8277. /**
  8278. * Get the quaternion rotation of the bone in either local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @returns The quaternion rotation
  8282. */
  8283. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8284. /**
  8285. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @param result The quaternion that the rotation should be copied to
  8289. */
  8290. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8291. /**
  8292. * Get the rotation matrix of the bone in local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @returns The rotation matrix
  8296. */
  8297. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8298. /**
  8299. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @param result The quaternion that the rotation should be copied to
  8303. */
  8304. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8305. /**
  8306. * Get the world position of a point that is in the local space of the bone
  8307. * @param position The local position
  8308. * @param mesh The mesh that this bone is attached to
  8309. * @returns The world position
  8310. */
  8311. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8312. /**
  8313. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8314. * @param position The local position
  8315. * @param mesh The mesh that this bone is attached to
  8316. * @param result The vector3 that the world position should be copied to
  8317. */
  8318. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8319. /**
  8320. * Get the local position of a point that is in world space
  8321. * @param position The world position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @returns The local position
  8324. */
  8325. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8326. /**
  8327. * Get the local position of a point that is in world space and copy it to the result param
  8328. * @param position The world position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @param result The vector3 that the local position should be copied to
  8331. */
  8332. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8333. }
  8334. }
  8335. declare module "babylonjs/Misc/iInspectable" {
  8336. /**
  8337. * Enum that determines the text-wrapping mode to use.
  8338. */
  8339. export enum InspectableType {
  8340. /**
  8341. * Checkbox for booleans
  8342. */
  8343. Checkbox = 0,
  8344. /**
  8345. * Sliders for numbers
  8346. */
  8347. Slider = 1,
  8348. /**
  8349. * Vector3
  8350. */
  8351. Vector3 = 2,
  8352. /**
  8353. * Quaternions
  8354. */
  8355. Quaternion = 3,
  8356. /**
  8357. * Color3
  8358. */
  8359. Color3 = 4
  8360. }
  8361. /**
  8362. * Interface used to define custom inspectable properties.
  8363. * This interface is used by the inspector to display custom property grids
  8364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8365. */
  8366. export interface IInspectable {
  8367. /**
  8368. * Gets the label to display
  8369. */
  8370. label: string;
  8371. /**
  8372. * Gets the name of the property to edit
  8373. */
  8374. propertyName: string;
  8375. /**
  8376. * Gets the type of the editor to use
  8377. */
  8378. type: InspectableType;
  8379. /**
  8380. * Gets the minimum value of the property when using in "slider" mode
  8381. */
  8382. min?: number;
  8383. /**
  8384. * Gets the maximum value of the property when using in "slider" mode
  8385. */
  8386. max?: number;
  8387. /**
  8388. * Gets the setp to use when using in "slider" mode
  8389. */
  8390. step?: number;
  8391. }
  8392. }
  8393. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8394. import { Nullable } from "babylonjs/types";
  8395. import { Scene } from "babylonjs/scene";
  8396. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. /**
  8399. * Class for creating a cube texture
  8400. */
  8401. export class CubeTexture extends BaseTexture {
  8402. private _delayedOnLoad;
  8403. /**
  8404. * The url of the texture
  8405. */
  8406. url: string;
  8407. /**
  8408. * Gets or sets the center of the bounding box associated with the cube texture.
  8409. * It must define where the camera used to render the texture was set
  8410. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8411. */
  8412. boundingBoxPosition: Vector3;
  8413. private _boundingBoxSize;
  8414. /**
  8415. * Gets or sets the size of the bounding box associated with the cube texture
  8416. * When defined, the cubemap will switch to local mode
  8417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8418. * @example https://www.babylonjs-playground.com/#RNASML
  8419. */
  8420. /**
  8421. * Returns the bounding box size
  8422. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8423. */
  8424. boundingBoxSize: Vector3;
  8425. protected _rotationY: number;
  8426. /**
  8427. * Sets texture matrix rotation angle around Y axis in radians.
  8428. */
  8429. /**
  8430. * Gets texture matrix rotation angle around Y axis radians.
  8431. */
  8432. rotationY: number;
  8433. /**
  8434. * Are mip maps generated for this texture or not.
  8435. */
  8436. readonly noMipmap: boolean;
  8437. private _noMipmap;
  8438. private _files;
  8439. private _extensions;
  8440. private _textureMatrix;
  8441. private _format;
  8442. private _createPolynomials;
  8443. /** @hidden */
  8444. _prefiltered: boolean;
  8445. /**
  8446. * Creates a cube texture from an array of image urls
  8447. * @param files defines an array of image urls
  8448. * @param scene defines the hosting scene
  8449. * @param noMipmap specifies if mip maps are not used
  8450. * @returns a cube texture
  8451. */
  8452. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8453. /**
  8454. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8455. * @param url defines the url of the prefiltered texture
  8456. * @param scene defines the scene the texture is attached to
  8457. * @param forcedExtension defines the extension of the file if different from the url
  8458. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8459. * @return the prefiltered texture
  8460. */
  8461. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8462. /**
  8463. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8464. * as prefiltered data.
  8465. * @param rootUrl defines the url of the texture or the root name of the six images
  8466. * @param scene defines the scene the texture is attached to
  8467. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8468. * @param noMipmap defines if mipmaps should be created or not
  8469. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8470. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8471. * @param onError defines a callback triggered in case of error during load
  8472. * @param format defines the internal format to use for the texture once loaded
  8473. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8474. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8475. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8478. * @return the cube texture
  8479. */
  8480. 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);
  8481. /**
  8482. * Get the current class name of the texture useful for serialization or dynamic coding.
  8483. * @returns "CubeTexture"
  8484. */
  8485. getClassName(): string;
  8486. /**
  8487. * Update the url (and optional buffer) of this texture if url was null during construction.
  8488. * @param url the url of the texture
  8489. * @param forcedExtension defines the extension to use
  8490. * @param onLoad callback called when the texture is loaded (defaults to null)
  8491. */
  8492. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8493. /**
  8494. * Delays loading of the cube texture
  8495. * @param forcedExtension defines the extension to use
  8496. */
  8497. delayLoad(forcedExtension?: string): void;
  8498. /**
  8499. * Returns the reflection texture matrix
  8500. * @returns the reflection texture matrix
  8501. */
  8502. getReflectionTextureMatrix(): Matrix;
  8503. /**
  8504. * Sets the reflection texture matrix
  8505. * @param value Reflection texture matrix
  8506. */
  8507. setReflectionTextureMatrix(value: Matrix): void;
  8508. /**
  8509. * Parses text to create a cube texture
  8510. * @param parsedTexture define the serialized text to read from
  8511. * @param scene defines the hosting scene
  8512. * @param rootUrl defines the root url of the cube texture
  8513. * @returns a cube texture
  8514. */
  8515. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8516. /**
  8517. * Makes a clone, or deep copy, of the cube texture
  8518. * @returns a new cube texture
  8519. */
  8520. clone(): CubeTexture;
  8521. }
  8522. }
  8523. declare module "babylonjs/Shaders/postprocess.vertex" {
  8524. /** @hidden */
  8525. export var postprocessVertexShader: {
  8526. name: string;
  8527. shader: string;
  8528. };
  8529. }
  8530. declare module "babylonjs/Cameras/targetCamera" {
  8531. import { Nullable } from "babylonjs/types";
  8532. import { Camera } from "babylonjs/Cameras/camera";
  8533. import { Scene } from "babylonjs/scene";
  8534. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8535. /**
  8536. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8537. * This is the base of the follow, arc rotate cameras and Free camera
  8538. * @see http://doc.babylonjs.com/features/cameras
  8539. */
  8540. export class TargetCamera extends Camera {
  8541. private static _RigCamTransformMatrix;
  8542. private static _TargetTransformMatrix;
  8543. private static _TargetFocalPoint;
  8544. /**
  8545. * Define the current direction the camera is moving to
  8546. */
  8547. cameraDirection: Vector3;
  8548. /**
  8549. * Define the current rotation the camera is rotating to
  8550. */
  8551. cameraRotation: Vector2;
  8552. /**
  8553. * When set, the up vector of the camera will be updated by the rotation of the camera
  8554. */
  8555. updateUpVectorFromRotation: boolean;
  8556. private _tmpQuaternion;
  8557. /**
  8558. * Define the current rotation of the camera
  8559. */
  8560. rotation: Vector3;
  8561. /**
  8562. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8563. */
  8564. rotationQuaternion: Quaternion;
  8565. /**
  8566. * Define the current speed of the camera
  8567. */
  8568. speed: number;
  8569. /**
  8570. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8571. * around all axis.
  8572. */
  8573. noRotationConstraint: boolean;
  8574. /**
  8575. * Define the current target of the camera as an object or a position.
  8576. */
  8577. lockedTarget: any;
  8578. /** @hidden */
  8579. _currentTarget: Vector3;
  8580. /** @hidden */
  8581. _initialFocalDistance: number;
  8582. /** @hidden */
  8583. _viewMatrix: Matrix;
  8584. /** @hidden */
  8585. _camMatrix: Matrix;
  8586. /** @hidden */
  8587. _cameraTransformMatrix: Matrix;
  8588. /** @hidden */
  8589. _cameraRotationMatrix: Matrix;
  8590. /** @hidden */
  8591. _referencePoint: Vector3;
  8592. /** @hidden */
  8593. _transformedReferencePoint: Vector3;
  8594. protected _globalCurrentTarget: Vector3;
  8595. protected _globalCurrentUpVector: Vector3;
  8596. /** @hidden */
  8597. _reset: () => void;
  8598. private _defaultUp;
  8599. /**
  8600. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8601. * This is the base of the follow, arc rotate cameras and Free camera
  8602. * @see http://doc.babylonjs.com/features/cameras
  8603. * @param name Defines the name of the camera in the scene
  8604. * @param position Defines the start position of the camera in the scene
  8605. * @param scene Defines the scene the camera belongs to
  8606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8607. */
  8608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8609. /**
  8610. * Gets the position in front of the camera at a given distance.
  8611. * @param distance The distance from the camera we want the position to be
  8612. * @returns the position
  8613. */
  8614. getFrontPosition(distance: number): Vector3;
  8615. /** @hidden */
  8616. _getLockedTargetPosition(): Nullable<Vector3>;
  8617. private _storedPosition;
  8618. private _storedRotation;
  8619. private _storedRotationQuaternion;
  8620. /**
  8621. * Store current camera state of the camera (fov, position, rotation, etc..)
  8622. * @returns the camera
  8623. */
  8624. storeState(): Camera;
  8625. /**
  8626. * Restored camera state. You must call storeState() first
  8627. * @returns whether it was successful or not
  8628. * @hidden
  8629. */
  8630. _restoreStateValues(): boolean;
  8631. /** @hidden */
  8632. _initCache(): void;
  8633. /** @hidden */
  8634. _updateCache(ignoreParentClass?: boolean): void;
  8635. /** @hidden */
  8636. _isSynchronizedViewMatrix(): boolean;
  8637. /** @hidden */
  8638. _computeLocalCameraSpeed(): number;
  8639. /**
  8640. * Defines the target the camera should look at.
  8641. * This will automatically adapt alpha beta and radius to fit within the new target.
  8642. * @param target Defines the new target as a Vector or a mesh
  8643. */
  8644. setTarget(target: Vector3): void;
  8645. /**
  8646. * Return the current target position of the camera. This value is expressed in local space.
  8647. * @returns the target position
  8648. */
  8649. getTarget(): Vector3;
  8650. /** @hidden */
  8651. _decideIfNeedsToMove(): boolean;
  8652. /** @hidden */
  8653. _updatePosition(): void;
  8654. /** @hidden */
  8655. _checkInputs(): void;
  8656. protected _updateCameraRotationMatrix(): void;
  8657. /**
  8658. * 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)
  8659. * @returns the current camera
  8660. */
  8661. private _rotateUpVectorWithCameraRotationMatrix;
  8662. private _cachedRotationZ;
  8663. private _cachedQuaternionRotationZ;
  8664. /** @hidden */
  8665. _getViewMatrix(): Matrix;
  8666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8667. /**
  8668. * @hidden
  8669. */
  8670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8671. /**
  8672. * @hidden
  8673. */
  8674. _updateRigCameras(): void;
  8675. private _getRigCamPositionAndTarget;
  8676. /**
  8677. * Gets the current object class name.
  8678. * @return the class name
  8679. */
  8680. getClassName(): string;
  8681. }
  8682. }
  8683. declare module "babylonjs/Cameras/cameraInputsManager" {
  8684. import { Nullable } from "babylonjs/types";
  8685. import { Camera } from "babylonjs/Cameras/camera";
  8686. /**
  8687. * @ignore
  8688. * This is a list of all the different input types that are available in the application.
  8689. * Fo instance: ArcRotateCameraGamepadInput...
  8690. */
  8691. export var CameraInputTypes: {};
  8692. /**
  8693. * This is the contract to implement in order to create a new input class.
  8694. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8695. */
  8696. export interface ICameraInput<TCamera extends Camera> {
  8697. /**
  8698. * Defines the camera the input is attached to.
  8699. */
  8700. camera: Nullable<TCamera>;
  8701. /**
  8702. * Gets the class name of the current intput.
  8703. * @returns the class name
  8704. */
  8705. getClassName(): string;
  8706. /**
  8707. * Get the friendly name associated with the input class.
  8708. * @returns the input friendly name
  8709. */
  8710. getSimpleName(): string;
  8711. /**
  8712. * Attach the input controls to a specific dom element to get the input from.
  8713. * @param element Defines the element the controls should be listened from
  8714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8715. */
  8716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8717. /**
  8718. * Detach the current controls from the specified dom element.
  8719. * @param element Defines the element to stop listening the inputs from
  8720. */
  8721. detachControl(element: Nullable<HTMLElement>): void;
  8722. /**
  8723. * Update the current camera state depending on the inputs that have been used this frame.
  8724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8725. */
  8726. checkInputs?: () => void;
  8727. }
  8728. /**
  8729. * Represents a map of input types to input instance or input index to input instance.
  8730. */
  8731. export interface CameraInputsMap<TCamera extends Camera> {
  8732. /**
  8733. * Accessor to the input by input type.
  8734. */
  8735. [name: string]: ICameraInput<TCamera>;
  8736. /**
  8737. * Accessor to the input by input index.
  8738. */
  8739. [idx: number]: ICameraInput<TCamera>;
  8740. }
  8741. /**
  8742. * This represents the input manager used within a camera.
  8743. * It helps dealing with all the different kind of input attached to a camera.
  8744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8745. */
  8746. export class CameraInputsManager<TCamera extends Camera> {
  8747. /**
  8748. * Defines the list of inputs attahed to the camera.
  8749. */
  8750. attached: CameraInputsMap<TCamera>;
  8751. /**
  8752. * Defines the dom element the camera is collecting inputs from.
  8753. * This is null if the controls have not been attached.
  8754. */
  8755. attachedElement: Nullable<HTMLElement>;
  8756. /**
  8757. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8758. */
  8759. noPreventDefault: boolean;
  8760. /**
  8761. * Defined the camera the input manager belongs to.
  8762. */
  8763. camera: TCamera;
  8764. /**
  8765. * Update the current camera state depending on the inputs that have been used this frame.
  8766. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8767. */
  8768. checkInputs: () => void;
  8769. /**
  8770. * Instantiate a new Camera Input Manager.
  8771. * @param camera Defines the camera the input manager blongs to
  8772. */
  8773. constructor(camera: TCamera);
  8774. /**
  8775. * Add an input method to a camera
  8776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8777. * @param input camera input method
  8778. */
  8779. add(input: ICameraInput<TCamera>): void;
  8780. /**
  8781. * Remove a specific input method from a camera
  8782. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8783. * @param inputToRemove camera input method
  8784. */
  8785. remove(inputToRemove: ICameraInput<TCamera>): void;
  8786. /**
  8787. * Remove a specific input type from a camera
  8788. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8789. * @param inputType the type of the input to remove
  8790. */
  8791. removeByType(inputType: string): void;
  8792. private _addCheckInputs;
  8793. /**
  8794. * Attach the input controls to the currently attached dom element to listen the events from.
  8795. * @param input Defines the input to attach
  8796. */
  8797. attachInput(input: ICameraInput<TCamera>): void;
  8798. /**
  8799. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8800. * @param element Defines the dom element to collect the events from
  8801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8802. */
  8803. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8804. /**
  8805. * Detach the current manager inputs controls from a specific dom element.
  8806. * @param element Defines the dom element to collect the events from
  8807. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8808. */
  8809. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8810. /**
  8811. * Rebuild the dynamic inputCheck function from the current list of
  8812. * defined inputs in the manager.
  8813. */
  8814. rebuildInputCheck(): void;
  8815. /**
  8816. * Remove all attached input methods from a camera
  8817. */
  8818. clear(): void;
  8819. /**
  8820. * Serialize the current input manager attached to a camera.
  8821. * This ensures than once parsed,
  8822. * the input associated to the camera will be identical to the current ones
  8823. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8824. */
  8825. serialize(serializedCamera: any): void;
  8826. /**
  8827. * Parses an input manager serialized JSON to restore the previous list of inputs
  8828. * and states associated to a camera.
  8829. * @param parsedCamera Defines the JSON to parse
  8830. */
  8831. parse(parsedCamera: any): void;
  8832. }
  8833. }
  8834. declare module "babylonjs/Events/keyboardEvents" {
  8835. /**
  8836. * Gather the list of keyboard event types as constants.
  8837. */
  8838. export class KeyboardEventTypes {
  8839. /**
  8840. * The keydown event is fired when a key becomes active (pressed).
  8841. */
  8842. static readonly KEYDOWN: number;
  8843. /**
  8844. * The keyup event is fired when a key has been released.
  8845. */
  8846. static readonly KEYUP: number;
  8847. }
  8848. /**
  8849. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8850. */
  8851. export class KeyboardInfo {
  8852. /**
  8853. * Defines the type of event (KeyboardEventTypes)
  8854. */
  8855. type: number;
  8856. /**
  8857. * Defines the related dom event
  8858. */
  8859. event: KeyboardEvent;
  8860. /**
  8861. * Instantiates a new keyboard info.
  8862. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8863. * @param type Defines the type of event (KeyboardEventTypes)
  8864. * @param event Defines the related dom event
  8865. */
  8866. constructor(
  8867. /**
  8868. * Defines the type of event (KeyboardEventTypes)
  8869. */
  8870. type: number,
  8871. /**
  8872. * Defines the related dom event
  8873. */
  8874. event: KeyboardEvent);
  8875. }
  8876. /**
  8877. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8878. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8879. */
  8880. export class KeyboardInfoPre extends KeyboardInfo {
  8881. /**
  8882. * Defines the type of event (KeyboardEventTypes)
  8883. */
  8884. type: number;
  8885. /**
  8886. * Defines the related dom event
  8887. */
  8888. event: KeyboardEvent;
  8889. /**
  8890. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8891. */
  8892. skipOnPointerObservable: boolean;
  8893. /**
  8894. * Instantiates a new keyboard pre info.
  8895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8896. * @param type Defines the type of event (KeyboardEventTypes)
  8897. * @param event Defines the related dom event
  8898. */
  8899. constructor(
  8900. /**
  8901. * Defines the type of event (KeyboardEventTypes)
  8902. */
  8903. type: number,
  8904. /**
  8905. * Defines the related dom event
  8906. */
  8907. event: KeyboardEvent);
  8908. }
  8909. }
  8910. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8911. import { Nullable } from "babylonjs/types";
  8912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8913. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8914. /**
  8915. * Manage the keyboard inputs to control the movement of a free camera.
  8916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8917. */
  8918. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8919. /**
  8920. * Defines the camera the input is attached to.
  8921. */
  8922. camera: FreeCamera;
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8925. */
  8926. keysUp: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8929. */
  8930. keysDown: number[];
  8931. /**
  8932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8933. */
  8934. keysLeft: number[];
  8935. /**
  8936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8937. */
  8938. keysRight: number[];
  8939. private _keys;
  8940. private _onCanvasBlurObserver;
  8941. private _onKeyboardObserver;
  8942. private _engine;
  8943. private _scene;
  8944. /**
  8945. * Attach the input controls to a specific dom element to get the input from.
  8946. * @param element Defines the element the controls should be listened from
  8947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8948. */
  8949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8950. /**
  8951. * Detach the current controls from the specified dom element.
  8952. * @param element Defines the element to stop listening the inputs from
  8953. */
  8954. detachControl(element: Nullable<HTMLElement>): void;
  8955. /**
  8956. * Update the current camera state depending on the inputs that have been used this frame.
  8957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8958. */
  8959. checkInputs(): void;
  8960. /**
  8961. * Gets the class name of the current intput.
  8962. * @returns the class name
  8963. */
  8964. getClassName(): string;
  8965. /** @hidden */
  8966. _onLostFocus(): void;
  8967. /**
  8968. * Get the friendly name associated with the input class.
  8969. * @returns the input friendly name
  8970. */
  8971. getSimpleName(): string;
  8972. }
  8973. }
  8974. declare module "babylonjs/Lights/shadowLight" {
  8975. import { Camera } from "babylonjs/Cameras/camera";
  8976. import { Scene } from "babylonjs/scene";
  8977. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8979. import { Light } from "babylonjs/Lights/light";
  8980. /**
  8981. * Interface describing all the common properties and methods a shadow light needs to implement.
  8982. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8983. * as well as binding the different shadow properties to the effects.
  8984. */
  8985. export interface IShadowLight extends Light {
  8986. /**
  8987. * The light id in the scene (used in scene.findLighById for instance)
  8988. */
  8989. id: string;
  8990. /**
  8991. * The position the shdow will be casted from.
  8992. */
  8993. position: Vector3;
  8994. /**
  8995. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8996. */
  8997. direction: Vector3;
  8998. /**
  8999. * The transformed position. Position of the light in world space taking parenting in account.
  9000. */
  9001. transformedPosition: Vector3;
  9002. /**
  9003. * The transformed direction. Direction of the light in world space taking parenting in account.
  9004. */
  9005. transformedDirection: Vector3;
  9006. /**
  9007. * The friendly name of the light in the scene.
  9008. */
  9009. name: string;
  9010. /**
  9011. * Defines the shadow projection clipping minimum z value.
  9012. */
  9013. shadowMinZ: number;
  9014. /**
  9015. * Defines the shadow projection clipping maximum z value.
  9016. */
  9017. shadowMaxZ: number;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Gets the scene the light belongs to.
  9025. * @returns The scene
  9026. */
  9027. getScene(): Scene;
  9028. /**
  9029. * Callback defining a custom Projection Matrix Builder.
  9030. * This can be used to override the default projection matrix computation.
  9031. */
  9032. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9033. /**
  9034. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9035. * @param matrix The materix to updated with the projection information
  9036. * @param viewMatrix The transform matrix of the light
  9037. * @param renderList The list of mesh to render in the map
  9038. * @returns The current light
  9039. */
  9040. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9041. /**
  9042. * Gets the current depth scale used in ESM.
  9043. * @returns The scale
  9044. */
  9045. getDepthScale(): number;
  9046. /**
  9047. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9048. * @returns true if a cube texture needs to be use
  9049. */
  9050. needCube(): boolean;
  9051. /**
  9052. * Detects if the projection matrix requires to be recomputed this frame.
  9053. * @returns true if it requires to be recomputed otherwise, false.
  9054. */
  9055. needProjectionMatrixCompute(): boolean;
  9056. /**
  9057. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9058. */
  9059. forceProjectionMatrixCompute(): void;
  9060. /**
  9061. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9062. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9063. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9064. */
  9065. getShadowDirection(faceIndex?: number): Vector3;
  9066. /**
  9067. * Gets the minZ used for shadow according to both the scene and the light.
  9068. * @param activeCamera The camera we are returning the min for
  9069. * @returns the depth min z
  9070. */
  9071. getDepthMinZ(activeCamera: Camera): number;
  9072. /**
  9073. * Gets the maxZ used for shadow according to both the scene and the light.
  9074. * @param activeCamera The camera we are returning the max for
  9075. * @returns the depth max z
  9076. */
  9077. getDepthMaxZ(activeCamera: Camera): number;
  9078. }
  9079. /**
  9080. * Base implementation IShadowLight
  9081. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9082. */
  9083. export abstract class ShadowLight extends Light implements IShadowLight {
  9084. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9085. protected _position: Vector3;
  9086. protected _setPosition(value: Vector3): void;
  9087. /**
  9088. * Sets the position the shadow will be casted from. Also use as the light position for both
  9089. * point and spot lights.
  9090. */
  9091. /**
  9092. * Sets the position the shadow will be casted from. Also use as the light position for both
  9093. * point and spot lights.
  9094. */
  9095. position: Vector3;
  9096. protected _direction: Vector3;
  9097. protected _setDirection(value: Vector3): void;
  9098. /**
  9099. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9100. * Also use as the light direction on spot and directional lights.
  9101. */
  9102. /**
  9103. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9104. * Also use as the light direction on spot and directional lights.
  9105. */
  9106. direction: Vector3;
  9107. private _shadowMinZ;
  9108. /**
  9109. * Gets the shadow projection clipping minimum z value.
  9110. */
  9111. /**
  9112. * Sets the shadow projection clipping minimum z value.
  9113. */
  9114. shadowMinZ: number;
  9115. private _shadowMaxZ;
  9116. /**
  9117. * Sets the shadow projection clipping maximum z value.
  9118. */
  9119. /**
  9120. * Gets the shadow projection clipping maximum z value.
  9121. */
  9122. shadowMaxZ: number;
  9123. /**
  9124. * Callback defining a custom Projection Matrix Builder.
  9125. * This can be used to override the default projection matrix computation.
  9126. */
  9127. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9128. /**
  9129. * The transformed position. Position of the light in world space taking parenting in account.
  9130. */
  9131. transformedPosition: Vector3;
  9132. /**
  9133. * The transformed direction. Direction of the light in world space taking parenting in account.
  9134. */
  9135. transformedDirection: Vector3;
  9136. private _needProjectionMatrixCompute;
  9137. /**
  9138. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9139. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9140. */
  9141. computeTransformedInformation(): boolean;
  9142. /**
  9143. * Return the depth scale used for the shadow map.
  9144. * @returns the depth scale.
  9145. */
  9146. getDepthScale(): number;
  9147. /**
  9148. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9149. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9150. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9151. */
  9152. getShadowDirection(faceIndex?: number): Vector3;
  9153. /**
  9154. * Returns the ShadowLight absolute position in the World.
  9155. * @returns the position vector in world space
  9156. */
  9157. getAbsolutePosition(): Vector3;
  9158. /**
  9159. * Sets the ShadowLight direction toward the passed target.
  9160. * @param target The point to target in local space
  9161. * @returns the updated ShadowLight direction
  9162. */
  9163. setDirectionToTarget(target: Vector3): Vector3;
  9164. /**
  9165. * Returns the light rotation in euler definition.
  9166. * @returns the x y z rotation in local space.
  9167. */
  9168. getRotation(): Vector3;
  9169. /**
  9170. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9171. * @returns true if a cube texture needs to be use
  9172. */
  9173. needCube(): boolean;
  9174. /**
  9175. * Detects if the projection matrix requires to be recomputed this frame.
  9176. * @returns true if it requires to be recomputed otherwise, false.
  9177. */
  9178. needProjectionMatrixCompute(): boolean;
  9179. /**
  9180. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9181. */
  9182. forceProjectionMatrixCompute(): void;
  9183. /** @hidden */
  9184. _initCache(): void;
  9185. /** @hidden */
  9186. _isSynchronized(): boolean;
  9187. /**
  9188. * Computes the world matrix of the node
  9189. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9190. * @returns the world matrix
  9191. */
  9192. computeWorldMatrix(force?: boolean): Matrix;
  9193. /**
  9194. * Gets the minZ used for shadow according to both the scene and the light.
  9195. * @param activeCamera The camera we are returning the min for
  9196. * @returns the depth min z
  9197. */
  9198. getDepthMinZ(activeCamera: Camera): number;
  9199. /**
  9200. * Gets the maxZ used for shadow according to both the scene and the light.
  9201. * @param activeCamera The camera we are returning the max for
  9202. * @returns the depth max z
  9203. */
  9204. getDepthMaxZ(activeCamera: Camera): number;
  9205. /**
  9206. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9207. * @param matrix The materix to updated with the projection information
  9208. * @param viewMatrix The transform matrix of the light
  9209. * @param renderList The list of mesh to render in the map
  9210. * @returns The current light
  9211. */
  9212. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9213. }
  9214. }
  9215. declare module "babylonjs/Materials/materialHelper" {
  9216. import { Nullable } from "babylonjs/types";
  9217. import { Scene } from "babylonjs/scene";
  9218. import { Engine } from "babylonjs/Engines/engine";
  9219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9220. import { Light } from "babylonjs/Lights/light";
  9221. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9222. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9224. /**
  9225. * "Static Class" containing the most commonly used helper while dealing with material for
  9226. * rendering purpose.
  9227. *
  9228. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9229. *
  9230. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9231. */
  9232. export class MaterialHelper {
  9233. /**
  9234. * Bind the current view position to an effect.
  9235. * @param effect The effect to be bound
  9236. * @param scene The scene the eyes position is used from
  9237. */
  9238. static BindEyePosition(effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Helps preparing the defines values about the UVs in used in the effect.
  9241. * UVs are shared as much as we can accross channels in the shaders.
  9242. * @param texture The texture we are preparing the UVs for
  9243. * @param defines The defines to update
  9244. * @param key The channel key "diffuse", "specular"... used in the shader
  9245. */
  9246. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9247. /**
  9248. * Binds a texture matrix value to its corrsponding uniform
  9249. * @param texture The texture to bind the matrix for
  9250. * @param uniformBuffer The uniform buffer receivin the data
  9251. * @param key The channel key "diffuse", "specular"... used in the shader
  9252. */
  9253. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9256. * @param mesh defines the current mesh
  9257. * @param scene defines the current scene
  9258. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9259. * @param pointsCloud defines if point cloud rendering has to be turned on
  9260. * @param fogEnabled defines if fog has to be turned on
  9261. * @param alphaTest defines if alpha testing has to be turned on
  9262. * @param defines defines the current list of defines
  9263. */
  9264. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9265. /**
  9266. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9267. * @param scene defines the current scene
  9268. * @param engine defines the current engine
  9269. * @param defines specifies the list of active defines
  9270. * @param useInstances defines if instances have to be turned on
  9271. * @param useClipPlane defines if clip plane have to be turned on
  9272. */
  9273. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9274. /**
  9275. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9276. * @param mesh The mesh containing the geometry data we will draw
  9277. * @param defines The defines to update
  9278. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9279. * @param useBones Precise whether bones should be used or not (override mesh info)
  9280. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9281. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9282. * @returns false if defines are considered not dirty and have not been checked
  9283. */
  9284. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9285. /**
  9286. * Prepares the defines related to multiview
  9287. * @param scene The scene we are intending to draw
  9288. * @param defines The defines to update
  9289. */
  9290. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9291. /**
  9292. * Prepares the defines related to the light information passed in parameter
  9293. * @param scene The scene we are intending to draw
  9294. * @param mesh The mesh the effect is compiling for
  9295. * @param defines The defines to update
  9296. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9297. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9298. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9299. * @returns true if normals will be required for the rest of the effect
  9300. */
  9301. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9302. /**
  9303. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9304. * that won t be acctive due to defines being turned off.
  9305. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9306. * @param samplersList The samplers list
  9307. * @param defines The defines helping in the list generation
  9308. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9309. */
  9310. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9311. /**
  9312. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9313. * @param defines The defines to update while falling back
  9314. * @param fallbacks The authorized effect fallbacks
  9315. * @param maxSimultaneousLights The maximum number of lights allowed
  9316. * @param rank the current rank of the Effect
  9317. * @returns The newly affected rank
  9318. */
  9319. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9320. /**
  9321. * Prepares the list of attributes required for morph targets according to the effect defines.
  9322. * @param attribs The current list of supported attribs
  9323. * @param mesh The mesh to prepare the morph targets attributes for
  9324. * @param defines The current Defines of the effect
  9325. */
  9326. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9327. /**
  9328. * Prepares the list of attributes required for bones according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the bones attributes for
  9331. * @param defines The current Defines of the effect
  9332. * @param fallbacks The current efffect fallback strategy
  9333. */
  9334. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9335. /**
  9336. * Prepares the list of attributes required for instances according to the effect defines.
  9337. * @param attribs The current list of supported attribs
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9341. /**
  9342. * Binds the light shadow information to the effect for the given mesh.
  9343. * @param light The light containing the generator
  9344. * @param scene The scene the lights belongs to
  9345. * @param mesh The mesh we are binding the information to render
  9346. * @param lightIndex The light index in the effect used to render the mesh
  9347. * @param effect The effect we are binding the data to
  9348. */
  9349. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9350. /**
  9351. * Binds the light information to the effect.
  9352. * @param light The light containing the generator
  9353. * @param effect The effect we are binding the data to
  9354. * @param lightIndex The light index in the effect used to render
  9355. */
  9356. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9357. /**
  9358. * Binds the lights information from the scene to the effect for the given mesh.
  9359. * @param scene The scene the lights belongs to
  9360. * @param mesh The mesh we are binding the information to render
  9361. * @param effect The effect we are binding the data to
  9362. * @param defines The generated defines for the effect
  9363. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9364. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9365. */
  9366. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9367. private static _tempFogColor;
  9368. /**
  9369. * Binds the fog information from the scene to the effect for the given mesh.
  9370. * @param scene The scene the lights belongs to
  9371. * @param mesh The mesh we are binding the information to render
  9372. * @param effect The effect we are binding the data to
  9373. * @param linearSpace Defines if the fog effect is applied in linear space
  9374. */
  9375. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9376. /**
  9377. * Binds the bones information from the mesh to the effect.
  9378. * @param mesh The mesh we are binding the information to render
  9379. * @param effect The effect we are binding the data to
  9380. */
  9381. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9382. /**
  9383. * Binds the morph targets information from the mesh to the effect.
  9384. * @param abstractMesh The mesh we are binding the information to render
  9385. * @param effect The effect we are binding the data to
  9386. */
  9387. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9388. /**
  9389. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9390. * @param defines The generated defines used in the effect
  9391. * @param effect The effect we are binding the data to
  9392. * @param scene The scene we are willing to render with logarithmic scale for
  9393. */
  9394. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9395. /**
  9396. * Binds the clip plane information from the scene to the effect.
  9397. * @param scene The scene the clip plane information are extracted from
  9398. * @param effect The effect we are binding the data to
  9399. */
  9400. static BindClipPlane(effect: Effect, scene: Scene): void;
  9401. }
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9404. /** @hidden */
  9405. export var kernelBlurVaryingDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9411. /** @hidden */
  9412. export var kernelBlurFragment: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9418. /** @hidden */
  9419. export var kernelBlurFragment2: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9425. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9426. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9427. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9428. /** @hidden */
  9429. export var kernelBlurPixelShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9435. /** @hidden */
  9436. export var kernelBlurVertex: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9442. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9443. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9444. /** @hidden */
  9445. export var kernelBlurVertexShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9451. import { Vector2 } from "babylonjs/Maths/math";
  9452. import { Nullable } from "babylonjs/types";
  9453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9454. import { Camera } from "babylonjs/Cameras/camera";
  9455. import { Effect } from "babylonjs/Materials/effect";
  9456. import { Engine } from "babylonjs/Engines/engine";
  9457. import "babylonjs/Shaders/kernelBlur.fragment";
  9458. import "babylonjs/Shaders/kernelBlur.vertex";
  9459. /**
  9460. * The Blur Post Process which blurs an image based on a kernel and direction.
  9461. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9462. */
  9463. export class BlurPostProcess extends PostProcess {
  9464. /** The direction in which to blur the image. */
  9465. direction: Vector2;
  9466. private blockCompilation;
  9467. protected _kernel: number;
  9468. protected _idealKernel: number;
  9469. protected _packedFloat: boolean;
  9470. private _staticDefines;
  9471. /**
  9472. * Sets the length in pixels of the blur sample region
  9473. */
  9474. /**
  9475. * Gets the length in pixels of the blur sample region
  9476. */
  9477. kernel: number;
  9478. /**
  9479. * Sets wether or not the blur needs to unpack/repack floats
  9480. */
  9481. /**
  9482. * Gets wether or not the blur is unpacking/repacking floats
  9483. */
  9484. packedFloat: boolean;
  9485. /**
  9486. * Creates a new instance BlurPostProcess
  9487. * @param name The name of the effect.
  9488. * @param direction The direction in which to blur the image.
  9489. * @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.
  9490. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9491. * @param camera The camera to apply the render pass to.
  9492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9493. * @param engine The engine which the post process will be applied. (default: current engine)
  9494. * @param reusable If the post process can be reused on the same frame. (default: false)
  9495. * @param textureType Type of textures used when performing the post process. (default: 0)
  9496. * @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)
  9497. */
  9498. constructor(name: string,
  9499. /** The direction in which to blur the image. */
  9500. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9501. /**
  9502. * Updates the effect with the current post process compile time values and recompiles the shader.
  9503. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9504. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9505. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9506. * @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
  9507. * @param onCompiled Called when the shader has been compiled.
  9508. * @param onError Called if there is an error when compiling a shader.
  9509. */
  9510. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9511. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9512. /**
  9513. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9514. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9515. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9516. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9517. * The gaps between physical kernels are compensated for in the weighting of the samples
  9518. * @param idealKernel Ideal blur kernel.
  9519. * @return Nearest best kernel.
  9520. */
  9521. protected _nearestBestKernel(idealKernel: number): number;
  9522. /**
  9523. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9524. * @param x The point on the Gaussian distribution to sample.
  9525. * @return the value of the Gaussian function at x.
  9526. */
  9527. protected _gaussianWeight(x: number): number;
  9528. /**
  9529. * Generates a string that can be used as a floating point number in GLSL.
  9530. * @param x Value to print.
  9531. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9532. * @return GLSL float string.
  9533. */
  9534. protected _glslFloat(x: number, decimalFigures?: number): string;
  9535. }
  9536. }
  9537. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9538. /** @hidden */
  9539. export var shadowMapPixelShader: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9545. /** @hidden */
  9546. export var bonesDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9552. /** @hidden */
  9553. export var morphTargetsVertexGlobalDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9559. /** @hidden */
  9560. export var morphTargetsVertexDeclaration: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9566. /** @hidden */
  9567. export var instancesDeclaration: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9573. /** @hidden */
  9574. export var helperFunctions: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9580. /** @hidden */
  9581. export var morphTargetsVertex: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9587. /** @hidden */
  9588. export var instancesVertex: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9594. /** @hidden */
  9595. export var bonesVertex: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9601. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9603. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9604. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9606. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9607. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9608. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9609. /** @hidden */
  9610. export var shadowMapVertexShader: {
  9611. name: string;
  9612. shader: string;
  9613. };
  9614. }
  9615. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9616. /** @hidden */
  9617. export var depthBoxBlurPixelShader: {
  9618. name: string;
  9619. shader: string;
  9620. };
  9621. }
  9622. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9623. import { Nullable } from "babylonjs/types";
  9624. import { Scene } from "babylonjs/scene";
  9625. import { Matrix } from "babylonjs/Maths/math";
  9626. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9628. import { Mesh } from "babylonjs/Meshes/mesh";
  9629. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9630. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9631. import { Effect } from "babylonjs/Materials/effect";
  9632. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9633. import "babylonjs/Shaders/shadowMap.fragment";
  9634. import "babylonjs/Shaders/shadowMap.vertex";
  9635. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9636. import { Observable } from "babylonjs/Misc/observable";
  9637. /**
  9638. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9639. */
  9640. export interface ICustomShaderOptions {
  9641. /**
  9642. * Gets or sets the custom shader name to use
  9643. */
  9644. shaderName: string;
  9645. /**
  9646. * The list of attribute names used in the shader
  9647. */
  9648. attributes?: string[];
  9649. /**
  9650. * The list of unifrom names used in the shader
  9651. */
  9652. uniforms?: string[];
  9653. /**
  9654. * The list of sampler names used in the shader
  9655. */
  9656. samplers?: string[];
  9657. /**
  9658. * The list of defines used in the shader
  9659. */
  9660. defines?: string[];
  9661. }
  9662. /**
  9663. * Interface to implement to create a shadow generator compatible with BJS.
  9664. */
  9665. export interface IShadowGenerator {
  9666. /**
  9667. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9668. * @returns The render target texture if present otherwise, null
  9669. */
  9670. getShadowMap(): Nullable<RenderTargetTexture>;
  9671. /**
  9672. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9673. * @returns The render target texture if the shadow map is present otherwise, null
  9674. */
  9675. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9676. /**
  9677. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9678. * @param subMesh The submesh we want to render in the shadow map
  9679. * @param useInstances Defines wether will draw in the map using instances
  9680. * @returns true if ready otherwise, false
  9681. */
  9682. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9683. /**
  9684. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9685. * @param defines Defines of the material we want to update
  9686. * @param lightIndex Index of the light in the enabled light list of the material
  9687. */
  9688. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9689. /**
  9690. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9691. * defined in the generator but impacting the effect).
  9692. * It implies the unifroms available on the materials are the standard BJS ones.
  9693. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9694. * @param effect The effect we are binfing the information for
  9695. */
  9696. bindShadowLight(lightIndex: string, effect: Effect): void;
  9697. /**
  9698. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9699. * (eq to shadow prjection matrix * light transform matrix)
  9700. * @returns The transform matrix used to create the shadow map
  9701. */
  9702. getTransformMatrix(): Matrix;
  9703. /**
  9704. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9705. * Cube and 2D textures for instance.
  9706. */
  9707. recreateShadowMap(): void;
  9708. /**
  9709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9710. * @param onCompiled Callback triggered at the and of the effects compilation
  9711. * @param options Sets of optional options forcing the compilation with different modes
  9712. */
  9713. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9714. useInstances: boolean;
  9715. }>): void;
  9716. /**
  9717. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9718. * @param options Sets of optional options forcing the compilation with different modes
  9719. * @returns A promise that resolves when the compilation completes
  9720. */
  9721. forceCompilationAsync(options?: Partial<{
  9722. useInstances: boolean;
  9723. }>): Promise<void>;
  9724. /**
  9725. * Serializes the shadow generator setup to a json object.
  9726. * @returns The serialized JSON object
  9727. */
  9728. serialize(): any;
  9729. /**
  9730. * Disposes the Shadow map and related Textures and effects.
  9731. */
  9732. dispose(): void;
  9733. }
  9734. /**
  9735. * Default implementation IShadowGenerator.
  9736. * This is the main object responsible of generating shadows in the framework.
  9737. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9738. */
  9739. export class ShadowGenerator implements IShadowGenerator {
  9740. /**
  9741. * Shadow generator mode None: no filtering applied.
  9742. */
  9743. static readonly FILTER_NONE: number;
  9744. /**
  9745. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9746. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9747. */
  9748. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9749. /**
  9750. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9751. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9752. */
  9753. static readonly FILTER_POISSONSAMPLING: number;
  9754. /**
  9755. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9756. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9757. */
  9758. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9759. /**
  9760. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9761. * edge artifacts on steep falloff.
  9762. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9763. */
  9764. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9765. /**
  9766. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9767. * edge artifacts on steep falloff.
  9768. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9769. */
  9770. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9771. /**
  9772. * Shadow generator mode PCF: Percentage Closer Filtering
  9773. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9774. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9775. */
  9776. static readonly FILTER_PCF: number;
  9777. /**
  9778. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9779. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9780. * Contact Hardening
  9781. */
  9782. static readonly FILTER_PCSS: number;
  9783. /**
  9784. * Reserved for PCF and PCSS
  9785. * Highest Quality.
  9786. *
  9787. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9788. *
  9789. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9790. */
  9791. static readonly QUALITY_HIGH: number;
  9792. /**
  9793. * Reserved for PCF and PCSS
  9794. * Good tradeoff for quality/perf cross devices
  9795. *
  9796. * Execute PCF on a 3*3 kernel.
  9797. *
  9798. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9799. */
  9800. static readonly QUALITY_MEDIUM: number;
  9801. /**
  9802. * Reserved for PCF and PCSS
  9803. * The lowest quality but the fastest.
  9804. *
  9805. * Execute PCF on a 1*1 kernel.
  9806. *
  9807. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9808. */
  9809. static readonly QUALITY_LOW: number;
  9810. /** Gets or sets the custom shader name to use */
  9811. customShaderOptions: ICustomShaderOptions;
  9812. /**
  9813. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9814. */
  9815. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9816. /**
  9817. * Observable triggered before a mesh is rendered in the shadow map.
  9818. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9819. */
  9820. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9821. private _bias;
  9822. /**
  9823. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9824. */
  9825. /**
  9826. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9827. */
  9828. bias: number;
  9829. private _normalBias;
  9830. /**
  9831. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9832. */
  9833. /**
  9834. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9835. */
  9836. normalBias: number;
  9837. private _blurBoxOffset;
  9838. /**
  9839. * Gets the blur box offset: offset applied during the blur pass.
  9840. * Only useful if useKernelBlur = false
  9841. */
  9842. /**
  9843. * Sets the blur box offset: offset applied during the blur pass.
  9844. * Only useful if useKernelBlur = false
  9845. */
  9846. blurBoxOffset: number;
  9847. private _blurScale;
  9848. /**
  9849. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9850. * 2 means half of the size.
  9851. */
  9852. /**
  9853. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9854. * 2 means half of the size.
  9855. */
  9856. blurScale: number;
  9857. private _blurKernel;
  9858. /**
  9859. * Gets the blur kernel: kernel size of the blur pass.
  9860. * Only useful if useKernelBlur = true
  9861. */
  9862. /**
  9863. * Sets the blur kernel: kernel size of the blur pass.
  9864. * Only useful if useKernelBlur = true
  9865. */
  9866. blurKernel: number;
  9867. private _useKernelBlur;
  9868. /**
  9869. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9870. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9871. */
  9872. /**
  9873. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9874. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9875. */
  9876. useKernelBlur: boolean;
  9877. private _depthScale;
  9878. /**
  9879. * Gets the depth scale used in ESM mode.
  9880. */
  9881. /**
  9882. * Sets the depth scale used in ESM mode.
  9883. * This can override the scale stored on the light.
  9884. */
  9885. depthScale: number;
  9886. private _filter;
  9887. /**
  9888. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9889. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9890. */
  9891. /**
  9892. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9893. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9894. */
  9895. filter: number;
  9896. /**
  9897. * Gets if the current filter is set to Poisson Sampling.
  9898. */
  9899. /**
  9900. * Sets the current filter to Poisson Sampling.
  9901. */
  9902. usePoissonSampling: boolean;
  9903. /**
  9904. * Gets if the current filter is set to ESM.
  9905. */
  9906. /**
  9907. * Sets the current filter is to ESM.
  9908. */
  9909. useExponentialShadowMap: boolean;
  9910. /**
  9911. * Gets if the current filter is set to filtered ESM.
  9912. */
  9913. /**
  9914. * Gets if the current filter is set to filtered ESM.
  9915. */
  9916. useBlurExponentialShadowMap: boolean;
  9917. /**
  9918. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9919. * exponential to prevent steep falloff artifacts).
  9920. */
  9921. /**
  9922. * Sets the current filter to "close ESM" (using the inverse of the
  9923. * exponential to prevent steep falloff artifacts).
  9924. */
  9925. useCloseExponentialShadowMap: boolean;
  9926. /**
  9927. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9928. * exponential to prevent steep falloff artifacts).
  9929. */
  9930. /**
  9931. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9932. * exponential to prevent steep falloff artifacts).
  9933. */
  9934. useBlurCloseExponentialShadowMap: boolean;
  9935. /**
  9936. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9937. */
  9938. /**
  9939. * Sets the current filter to "PCF" (percentage closer filtering).
  9940. */
  9941. usePercentageCloserFiltering: boolean;
  9942. private _filteringQuality;
  9943. /**
  9944. * Gets the PCF or PCSS Quality.
  9945. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9946. */
  9947. /**
  9948. * Sets the PCF or PCSS Quality.
  9949. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9950. */
  9951. filteringQuality: number;
  9952. /**
  9953. * Gets if the current filter is set to "PCSS" (contact hardening).
  9954. */
  9955. /**
  9956. * Sets the current filter to "PCSS" (contact hardening).
  9957. */
  9958. useContactHardeningShadow: boolean;
  9959. private _contactHardeningLightSizeUVRatio;
  9960. /**
  9961. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9962. * Using a ratio helps keeping shape stability independently of the map size.
  9963. *
  9964. * It does not account for the light projection as it was having too much
  9965. * instability during the light setup or during light position changes.
  9966. *
  9967. * Only valid if useContactHardeningShadow is true.
  9968. */
  9969. /**
  9970. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9971. * Using a ratio helps keeping shape stability independently of the map size.
  9972. *
  9973. * It does not account for the light projection as it was having too much
  9974. * instability during the light setup or during light position changes.
  9975. *
  9976. * Only valid if useContactHardeningShadow is true.
  9977. */
  9978. contactHardeningLightSizeUVRatio: number;
  9979. private _darkness;
  9980. /**
  9981. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9982. * 0 means strongest and 1 would means no shadow.
  9983. * @returns the darkness.
  9984. */
  9985. getDarkness(): number;
  9986. /**
  9987. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9988. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9989. * @returns the shadow generator allowing fluent coding.
  9990. */
  9991. setDarkness(darkness: number): ShadowGenerator;
  9992. private _transparencyShadow;
  9993. /**
  9994. * Sets the ability to have transparent shadow (boolean).
  9995. * @param transparent True if transparent else False
  9996. * @returns the shadow generator allowing fluent coding
  9997. */
  9998. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9999. private _shadowMap;
  10000. private _shadowMap2;
  10001. /**
  10002. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10003. * @returns The render target texture if present otherwise, null
  10004. */
  10005. getShadowMap(): Nullable<RenderTargetTexture>;
  10006. /**
  10007. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10008. * @returns The render target texture if the shadow map is present otherwise, null
  10009. */
  10010. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10011. /**
  10012. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10013. * @param mesh Mesh to add
  10014. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10015. * @returns the Shadow Generator itself
  10016. */
  10017. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10018. /**
  10019. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10020. * @param mesh Mesh to remove
  10021. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10022. * @returns the Shadow Generator itself
  10023. */
  10024. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10025. /**
  10026. * Controls the extent to which the shadows fade out at the edge of the frustum
  10027. * Used only by directionals and spots
  10028. */
  10029. frustumEdgeFalloff: number;
  10030. private _light;
  10031. /**
  10032. * Returns the associated light object.
  10033. * @returns the light generating the shadow
  10034. */
  10035. getLight(): IShadowLight;
  10036. /**
  10037. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10038. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10039. * It might on the other hand introduce peter panning.
  10040. */
  10041. forceBackFacesOnly: boolean;
  10042. private _scene;
  10043. private _lightDirection;
  10044. private _effect;
  10045. private _viewMatrix;
  10046. private _projectionMatrix;
  10047. private _transformMatrix;
  10048. private _cachedPosition;
  10049. private _cachedDirection;
  10050. private _cachedDefines;
  10051. private _currentRenderID;
  10052. private _boxBlurPostprocess;
  10053. private _kernelBlurXPostprocess;
  10054. private _kernelBlurYPostprocess;
  10055. private _blurPostProcesses;
  10056. private _mapSize;
  10057. private _currentFaceIndex;
  10058. private _currentFaceIndexCache;
  10059. private _textureType;
  10060. private _defaultTextureMatrix;
  10061. /** @hidden */
  10062. static _SceneComponentInitialization: (scene: Scene) => void;
  10063. /**
  10064. * Creates a ShadowGenerator object.
  10065. * A ShadowGenerator is the required tool to use the shadows.
  10066. * Each light casting shadows needs to use its own ShadowGenerator.
  10067. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10068. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10069. * @param light The light object generating the shadows.
  10070. * @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.
  10071. */
  10072. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10073. private _initializeGenerator;
  10074. private _initializeShadowMap;
  10075. private _initializeBlurRTTAndPostProcesses;
  10076. private _renderForShadowMap;
  10077. private _renderSubMeshForShadowMap;
  10078. private _applyFilterValues;
  10079. /**
  10080. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10081. * @param onCompiled Callback triggered at the and of the effects compilation
  10082. * @param options Sets of optional options forcing the compilation with different modes
  10083. */
  10084. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10085. useInstances: boolean;
  10086. }>): void;
  10087. /**
  10088. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10089. * @param options Sets of optional options forcing the compilation with different modes
  10090. * @returns A promise that resolves when the compilation completes
  10091. */
  10092. forceCompilationAsync(options?: Partial<{
  10093. useInstances: boolean;
  10094. }>): Promise<void>;
  10095. /**
  10096. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10097. * @param subMesh The submesh we want to render in the shadow map
  10098. * @param useInstances Defines wether will draw in the map using instances
  10099. * @returns true if ready otherwise, false
  10100. */
  10101. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10102. /**
  10103. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10104. * @param defines Defines of the material we want to update
  10105. * @param lightIndex Index of the light in the enabled light list of the material
  10106. */
  10107. prepareDefines(defines: any, lightIndex: number): void;
  10108. /**
  10109. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10110. * defined in the generator but impacting the effect).
  10111. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10112. * @param effect The effect we are binfing the information for
  10113. */
  10114. bindShadowLight(lightIndex: string, effect: Effect): void;
  10115. /**
  10116. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10117. * (eq to shadow prjection matrix * light transform matrix)
  10118. * @returns The transform matrix used to create the shadow map
  10119. */
  10120. getTransformMatrix(): Matrix;
  10121. /**
  10122. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10123. * Cube and 2D textures for instance.
  10124. */
  10125. recreateShadowMap(): void;
  10126. private _disposeBlurPostProcesses;
  10127. private _disposeRTTandPostProcesses;
  10128. /**
  10129. * Disposes the ShadowGenerator.
  10130. * Returns nothing.
  10131. */
  10132. dispose(): void;
  10133. /**
  10134. * Serializes the shadow generator setup to a json object.
  10135. * @returns The serialized JSON object
  10136. */
  10137. serialize(): any;
  10138. /**
  10139. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10140. * @param parsedShadowGenerator The JSON object to parse
  10141. * @param scene The scene to create the shadow map for
  10142. * @returns The parsed shadow generator
  10143. */
  10144. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10145. }
  10146. }
  10147. declare module "babylonjs/Lights/light" {
  10148. import { Nullable } from "babylonjs/types";
  10149. import { Scene } from "babylonjs/scene";
  10150. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10151. import { Node } from "babylonjs/node";
  10152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10153. import { Effect } from "babylonjs/Materials/effect";
  10154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10155. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10156. /**
  10157. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10158. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10159. * 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.
  10160. */
  10161. export abstract class Light extends Node {
  10162. /**
  10163. * Falloff Default: light is falling off following the material specification:
  10164. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10165. */
  10166. static readonly FALLOFF_DEFAULT: number;
  10167. /**
  10168. * Falloff Physical: light is falling off following the inverse squared distance law.
  10169. */
  10170. static readonly FALLOFF_PHYSICAL: number;
  10171. /**
  10172. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10173. * to enhance interoperability with other engines.
  10174. */
  10175. static readonly FALLOFF_GLTF: number;
  10176. /**
  10177. * Falloff Standard: light is falling off like in the standard material
  10178. * to enhance interoperability with other materials.
  10179. */
  10180. static readonly FALLOFF_STANDARD: number;
  10181. /**
  10182. * If every light affecting the material is in this lightmapMode,
  10183. * material.lightmapTexture adds or multiplies
  10184. * (depends on material.useLightmapAsShadowmap)
  10185. * after every other light calculations.
  10186. */
  10187. static readonly LIGHTMAP_DEFAULT: number;
  10188. /**
  10189. * material.lightmapTexture as only diffuse lighting from this light
  10190. * adds only specular lighting from this light
  10191. * adds dynamic shadows
  10192. */
  10193. static readonly LIGHTMAP_SPECULAR: number;
  10194. /**
  10195. * material.lightmapTexture as only lighting
  10196. * no light calculation from this light
  10197. * only adds dynamic shadows from this light
  10198. */
  10199. static readonly LIGHTMAP_SHADOWSONLY: number;
  10200. /**
  10201. * Each light type uses the default quantity according to its type:
  10202. * point/spot lights use luminous intensity
  10203. * directional lights use illuminance
  10204. */
  10205. static readonly INTENSITYMODE_AUTOMATIC: number;
  10206. /**
  10207. * lumen (lm)
  10208. */
  10209. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10210. /**
  10211. * candela (lm/sr)
  10212. */
  10213. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10214. /**
  10215. * lux (lm/m^2)
  10216. */
  10217. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10218. /**
  10219. * nit (cd/m^2)
  10220. */
  10221. static readonly INTENSITYMODE_LUMINANCE: number;
  10222. /**
  10223. * Light type const id of the point light.
  10224. */
  10225. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10226. /**
  10227. * Light type const id of the directional light.
  10228. */
  10229. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10230. /**
  10231. * Light type const id of the spot light.
  10232. */
  10233. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10234. /**
  10235. * Light type const id of the hemispheric light.
  10236. */
  10237. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10238. /**
  10239. * Diffuse gives the basic color to an object.
  10240. */
  10241. diffuse: Color3;
  10242. /**
  10243. * Specular produces a highlight color on an object.
  10244. * Note: This is note affecting PBR materials.
  10245. */
  10246. specular: Color3;
  10247. /**
  10248. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10249. * falling off base on range or angle.
  10250. * This can be set to any values in Light.FALLOFF_x.
  10251. *
  10252. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10253. * other types of materials.
  10254. */
  10255. falloffType: number;
  10256. /**
  10257. * Strength of the light.
  10258. * Note: By default it is define in the framework own unit.
  10259. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10260. */
  10261. intensity: number;
  10262. private _range;
  10263. protected _inverseSquaredRange: number;
  10264. /**
  10265. * Defines how far from the source the light is impacting in scene units.
  10266. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10267. */
  10268. /**
  10269. * Defines how far from the source the light is impacting in scene units.
  10270. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10271. */
  10272. range: number;
  10273. /**
  10274. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10275. * of light.
  10276. */
  10277. private _photometricScale;
  10278. private _intensityMode;
  10279. /**
  10280. * Gets the photometric scale used to interpret the intensity.
  10281. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10282. */
  10283. /**
  10284. * Sets the photometric scale used to interpret the intensity.
  10285. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10286. */
  10287. intensityMode: number;
  10288. private _radius;
  10289. /**
  10290. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10291. */
  10292. /**
  10293. * sets the light radius used by PBR Materials to simulate soft area lights.
  10294. */
  10295. radius: number;
  10296. private _renderPriority;
  10297. /**
  10298. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10299. * exceeding the number allowed of the materials.
  10300. */
  10301. renderPriority: number;
  10302. private _shadowEnabled;
  10303. /**
  10304. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10305. * the current shadow generator.
  10306. */
  10307. /**
  10308. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10309. * the current shadow generator.
  10310. */
  10311. shadowEnabled: boolean;
  10312. private _includedOnlyMeshes;
  10313. /**
  10314. * Gets the only meshes impacted by this light.
  10315. */
  10316. /**
  10317. * Sets the only meshes impacted by this light.
  10318. */
  10319. includedOnlyMeshes: AbstractMesh[];
  10320. private _excludedMeshes;
  10321. /**
  10322. * Gets the meshes not impacted by this light.
  10323. */
  10324. /**
  10325. * Sets the meshes not impacted by this light.
  10326. */
  10327. excludedMeshes: AbstractMesh[];
  10328. private _excludeWithLayerMask;
  10329. /**
  10330. * Gets the layer id use to find what meshes are not impacted by the light.
  10331. * Inactive if 0
  10332. */
  10333. /**
  10334. * Sets the layer id use to find what meshes are not impacted by the light.
  10335. * Inactive if 0
  10336. */
  10337. excludeWithLayerMask: number;
  10338. private _includeOnlyWithLayerMask;
  10339. /**
  10340. * Gets the layer id use to find what meshes are impacted by the light.
  10341. * Inactive if 0
  10342. */
  10343. /**
  10344. * Sets the layer id use to find what meshes are impacted by the light.
  10345. * Inactive if 0
  10346. */
  10347. includeOnlyWithLayerMask: number;
  10348. private _lightmapMode;
  10349. /**
  10350. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10351. */
  10352. /**
  10353. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10354. */
  10355. lightmapMode: number;
  10356. /**
  10357. * Shadow generator associted to the light.
  10358. * @hidden Internal use only.
  10359. */
  10360. _shadowGenerator: Nullable<IShadowGenerator>;
  10361. /**
  10362. * @hidden Internal use only.
  10363. */
  10364. _excludedMeshesIds: string[];
  10365. /**
  10366. * @hidden Internal use only.
  10367. */
  10368. _includedOnlyMeshesIds: string[];
  10369. /**
  10370. * The current light unifom buffer.
  10371. * @hidden Internal use only.
  10372. */
  10373. _uniformBuffer: UniformBuffer;
  10374. /**
  10375. * Creates a Light object in the scene.
  10376. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10377. * @param name The firendly name of the light
  10378. * @param scene The scene the light belongs too
  10379. */
  10380. constructor(name: string, scene: Scene);
  10381. protected abstract _buildUniformLayout(): void;
  10382. /**
  10383. * Sets the passed Effect "effect" with the Light information.
  10384. * @param effect The effect to update
  10385. * @param lightIndex The index of the light in the effect to update
  10386. * @returns The light
  10387. */
  10388. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10389. /**
  10390. * Returns the string "Light".
  10391. * @returns the class name
  10392. */
  10393. getClassName(): string;
  10394. /** @hidden */
  10395. readonly _isLight: boolean;
  10396. /**
  10397. * Converts the light information to a readable string for debug purpose.
  10398. * @param fullDetails Supports for multiple levels of logging within scene loading
  10399. * @returns the human readable light info
  10400. */
  10401. toString(fullDetails?: boolean): string;
  10402. /** @hidden */
  10403. protected _syncParentEnabledState(): void;
  10404. /**
  10405. * Set the enabled state of this node.
  10406. * @param value - the new enabled state
  10407. */
  10408. setEnabled(value: boolean): void;
  10409. /**
  10410. * Returns the Light associated shadow generator if any.
  10411. * @return the associated shadow generator.
  10412. */
  10413. getShadowGenerator(): Nullable<IShadowGenerator>;
  10414. /**
  10415. * Returns a Vector3, the absolute light position in the World.
  10416. * @returns the world space position of the light
  10417. */
  10418. getAbsolutePosition(): Vector3;
  10419. /**
  10420. * Specifies if the light will affect the passed mesh.
  10421. * @param mesh The mesh to test against the light
  10422. * @return true the mesh is affected otherwise, false.
  10423. */
  10424. canAffectMesh(mesh: AbstractMesh): boolean;
  10425. /**
  10426. * Sort function to order lights for rendering.
  10427. * @param a First Light object to compare to second.
  10428. * @param b Second Light object to compare first.
  10429. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10430. */
  10431. static CompareLightsPriority(a: Light, b: Light): number;
  10432. /**
  10433. * Releases resources associated with this node.
  10434. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10435. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10436. */
  10437. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10438. /**
  10439. * Returns the light type ID (integer).
  10440. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10441. */
  10442. getTypeID(): number;
  10443. /**
  10444. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10445. * @returns the scaled intensity in intensity mode unit
  10446. */
  10447. getScaledIntensity(): number;
  10448. /**
  10449. * Returns a new Light object, named "name", from the current one.
  10450. * @param name The name of the cloned light
  10451. * @returns the new created light
  10452. */
  10453. clone(name: string): Nullable<Light>;
  10454. /**
  10455. * Serializes the current light into a Serialization object.
  10456. * @returns the serialized object.
  10457. */
  10458. serialize(): any;
  10459. /**
  10460. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10461. * This new light is named "name" and added to the passed scene.
  10462. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10463. * @param name The friendly name of the light
  10464. * @param scene The scene the new light will belong to
  10465. * @returns the constructor function
  10466. */
  10467. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10468. /**
  10469. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10470. * @param parsedLight The JSON representation of the light
  10471. * @param scene The scene to create the parsed light in
  10472. * @returns the created light after parsing
  10473. */
  10474. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10475. private _hookArrayForExcluded;
  10476. private _hookArrayForIncludedOnly;
  10477. private _resyncMeshes;
  10478. /**
  10479. * Forces the meshes to update their light related information in their rendering used effects
  10480. * @hidden Internal Use Only
  10481. */
  10482. _markMeshesAsLightDirty(): void;
  10483. /**
  10484. * Recomputes the cached photometric scale if needed.
  10485. */
  10486. private _computePhotometricScale;
  10487. /**
  10488. * Returns the Photometric Scale according to the light type and intensity mode.
  10489. */
  10490. private _getPhotometricScale;
  10491. /**
  10492. * Reorder the light in the scene according to their defined priority.
  10493. * @hidden Internal Use Only
  10494. */
  10495. _reorderLightsInScene(): void;
  10496. /**
  10497. * Prepares the list of defines specific to the light type.
  10498. * @param defines the list of defines
  10499. * @param lightIndex defines the index of the light for the effect
  10500. */
  10501. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10502. }
  10503. }
  10504. declare module "babylonjs/Actions/action" {
  10505. import { Observable } from "babylonjs/Misc/observable";
  10506. import { Condition } from "babylonjs/Actions/condition";
  10507. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10508. import { ActionManager } from "babylonjs/Actions/actionManager";
  10509. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10510. /**
  10511. * Interface used to define Action
  10512. */
  10513. export interface IAction {
  10514. /**
  10515. * Trigger for the action
  10516. */
  10517. trigger: number;
  10518. /** Options of the trigger */
  10519. triggerOptions: any;
  10520. /**
  10521. * Gets the trigger parameters
  10522. * @returns the trigger parameters
  10523. */
  10524. getTriggerParameter(): any;
  10525. /**
  10526. * Internal only - executes current action event
  10527. * @hidden
  10528. */
  10529. _executeCurrent(evt?: ActionEvent): void;
  10530. /**
  10531. * Serialize placeholder for child classes
  10532. * @param parent of child
  10533. * @returns the serialized object
  10534. */
  10535. serialize(parent: any): any;
  10536. /**
  10537. * Internal only
  10538. * @hidden
  10539. */
  10540. _prepare(): void;
  10541. /**
  10542. * Internal only - manager for action
  10543. * @hidden
  10544. */
  10545. _actionManager: AbstractActionManager;
  10546. }
  10547. /**
  10548. * The action to be carried out following a trigger
  10549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10550. */
  10551. export class Action implements IAction {
  10552. /** the trigger, with or without parameters, for the action */
  10553. triggerOptions: any;
  10554. /**
  10555. * Trigger for the action
  10556. */
  10557. trigger: number;
  10558. /**
  10559. * Internal only - manager for action
  10560. * @hidden
  10561. */
  10562. _actionManager: ActionManager;
  10563. private _nextActiveAction;
  10564. private _child;
  10565. private _condition?;
  10566. private _triggerParameter;
  10567. /**
  10568. * An event triggered prior to action being executed.
  10569. */
  10570. onBeforeExecuteObservable: Observable<Action>;
  10571. /**
  10572. * Creates a new Action
  10573. * @param triggerOptions the trigger, with or without parameters, for the action
  10574. * @param condition an optional determinant of action
  10575. */
  10576. constructor(
  10577. /** the trigger, with or without parameters, for the action */
  10578. triggerOptions: any, condition?: Condition);
  10579. /**
  10580. * Internal only
  10581. * @hidden
  10582. */
  10583. _prepare(): void;
  10584. /**
  10585. * Gets the trigger parameters
  10586. * @returns the trigger parameters
  10587. */
  10588. getTriggerParameter(): any;
  10589. /**
  10590. * Internal only - executes current action event
  10591. * @hidden
  10592. */
  10593. _executeCurrent(evt?: ActionEvent): void;
  10594. /**
  10595. * Execute placeholder for child classes
  10596. * @param evt optional action event
  10597. */
  10598. execute(evt?: ActionEvent): void;
  10599. /**
  10600. * Skips to next active action
  10601. */
  10602. skipToNextActiveAction(): void;
  10603. /**
  10604. * Adds action to chain of actions, may be a DoNothingAction
  10605. * @param action defines the next action to execute
  10606. * @returns The action passed in
  10607. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10608. */
  10609. then(action: Action): Action;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. _getProperty(propertyPath: string): string;
  10615. /**
  10616. * Internal only
  10617. * @hidden
  10618. */
  10619. _getEffectiveTarget(target: any, propertyPath: string): any;
  10620. /**
  10621. * Serialize placeholder for child classes
  10622. * @param parent of child
  10623. * @returns the serialized object
  10624. */
  10625. serialize(parent: any): any;
  10626. /**
  10627. * Internal only called by serialize
  10628. * @hidden
  10629. */
  10630. protected _serialize(serializedAction: any, parent?: any): any;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. static _SerializeValueAsString: (value: any) => string;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10641. name: string;
  10642. targetType: string;
  10643. value: string;
  10644. };
  10645. }
  10646. }
  10647. declare module "babylonjs/Actions/condition" {
  10648. import { ActionManager } from "babylonjs/Actions/actionManager";
  10649. /**
  10650. * A Condition applied to an Action
  10651. */
  10652. export class Condition {
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Internal only
  10660. * @hidden
  10661. */
  10662. _evaluationId: number;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. _currentResult: boolean;
  10668. /**
  10669. * Creates a new Condition
  10670. * @param actionManager the manager of the action the condition is applied to
  10671. */
  10672. constructor(actionManager: ActionManager);
  10673. /**
  10674. * Check if the current condition is valid
  10675. * @returns a boolean
  10676. */
  10677. isValid(): boolean;
  10678. /**
  10679. * Internal only
  10680. * @hidden
  10681. */
  10682. _getProperty(propertyPath: string): string;
  10683. /**
  10684. * Internal only
  10685. * @hidden
  10686. */
  10687. _getEffectiveTarget(target: any, propertyPath: string): any;
  10688. /**
  10689. * Serialize placeholder for child classes
  10690. * @returns the serialized object
  10691. */
  10692. serialize(): any;
  10693. /**
  10694. * Internal only
  10695. * @hidden
  10696. */
  10697. protected _serialize(serializedCondition: any): any;
  10698. }
  10699. /**
  10700. * Defines specific conditional operators as extensions of Condition
  10701. */
  10702. export class ValueCondition extends Condition {
  10703. /** path to specify the property of the target the conditional operator uses */
  10704. propertyPath: string;
  10705. /** the value compared by the conditional operator against the current value of the property */
  10706. value: any;
  10707. /** the conditional operator, default ValueCondition.IsEqual */
  10708. operator: number;
  10709. /**
  10710. * Internal only
  10711. * @hidden
  10712. */
  10713. private static _IsEqual;
  10714. /**
  10715. * Internal only
  10716. * @hidden
  10717. */
  10718. private static _IsDifferent;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. private static _IsGreater;
  10724. /**
  10725. * Internal only
  10726. * @hidden
  10727. */
  10728. private static _IsLesser;
  10729. /**
  10730. * returns the number for IsEqual
  10731. */
  10732. static readonly IsEqual: number;
  10733. /**
  10734. * Returns the number for IsDifferent
  10735. */
  10736. static readonly IsDifferent: number;
  10737. /**
  10738. * Returns the number for IsGreater
  10739. */
  10740. static readonly IsGreater: number;
  10741. /**
  10742. * Returns the number for IsLesser
  10743. */
  10744. static readonly IsLesser: number;
  10745. /**
  10746. * Internal only The action manager for the condition
  10747. * @hidden
  10748. */
  10749. _actionManager: ActionManager;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. private _target;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. private _effectiveTarget;
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. private _property;
  10765. /**
  10766. * Creates a new ValueCondition
  10767. * @param actionManager manager for the action the condition applies to
  10768. * @param target for the action
  10769. * @param propertyPath path to specify the property of the target the conditional operator uses
  10770. * @param value the value compared by the conditional operator against the current value of the property
  10771. * @param operator the conditional operator, default ValueCondition.IsEqual
  10772. */
  10773. constructor(actionManager: ActionManager, target: any,
  10774. /** path to specify the property of the target the conditional operator uses */
  10775. propertyPath: string,
  10776. /** the value compared by the conditional operator against the current value of the property */
  10777. value: any,
  10778. /** the conditional operator, default ValueCondition.IsEqual */
  10779. operator?: number);
  10780. /**
  10781. * Compares the given value with the property value for the specified conditional operator
  10782. * @returns the result of the comparison
  10783. */
  10784. isValid(): boolean;
  10785. /**
  10786. * Serialize the ValueCondition into a JSON compatible object
  10787. * @returns serialization object
  10788. */
  10789. serialize(): any;
  10790. /**
  10791. * Gets the name of the conditional operator for the ValueCondition
  10792. * @param operator the conditional operator
  10793. * @returns the name
  10794. */
  10795. static GetOperatorName(operator: number): string;
  10796. }
  10797. /**
  10798. * Defines a predicate condition as an extension of Condition
  10799. */
  10800. export class PredicateCondition extends Condition {
  10801. /** defines the predicate function used to validate the condition */
  10802. predicate: () => boolean;
  10803. /**
  10804. * Internal only - manager for action
  10805. * @hidden
  10806. */
  10807. _actionManager: ActionManager;
  10808. /**
  10809. * Creates a new PredicateCondition
  10810. * @param actionManager manager for the action the condition applies to
  10811. * @param predicate defines the predicate function used to validate the condition
  10812. */
  10813. constructor(actionManager: ActionManager,
  10814. /** defines the predicate function used to validate the condition */
  10815. predicate: () => boolean);
  10816. /**
  10817. * @returns the validity of the predicate condition
  10818. */
  10819. isValid(): boolean;
  10820. }
  10821. /**
  10822. * Defines a state condition as an extension of Condition
  10823. */
  10824. export class StateCondition extends Condition {
  10825. /** Value to compare with target state */
  10826. value: string;
  10827. /**
  10828. * Internal only - manager for action
  10829. * @hidden
  10830. */
  10831. _actionManager: ActionManager;
  10832. /**
  10833. * Internal only
  10834. * @hidden
  10835. */
  10836. private _target;
  10837. /**
  10838. * Creates a new StateCondition
  10839. * @param actionManager manager for the action the condition applies to
  10840. * @param target of the condition
  10841. * @param value to compare with target state
  10842. */
  10843. constructor(actionManager: ActionManager, target: any,
  10844. /** Value to compare with target state */
  10845. value: string);
  10846. /**
  10847. * Gets a boolean indicating if the current condition is met
  10848. * @returns the validity of the state
  10849. */
  10850. isValid(): boolean;
  10851. /**
  10852. * Serialize the StateCondition into a JSON compatible object
  10853. * @returns serialization object
  10854. */
  10855. serialize(): any;
  10856. }
  10857. }
  10858. declare module "babylonjs/Actions/directActions" {
  10859. import { Action } from "babylonjs/Actions/action";
  10860. import { Condition } from "babylonjs/Actions/condition";
  10861. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10862. /**
  10863. * This defines an action responsible to toggle a boolean once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class SwitchBooleanAction extends Action {
  10867. /**
  10868. * The path to the boolean property in the target object
  10869. */
  10870. propertyPath: string;
  10871. private _target;
  10872. private _effectiveTarget;
  10873. private _property;
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param target defines the object containing the boolean
  10878. * @param propertyPath defines the path to the boolean property in the target object
  10879. * @param condition defines the trigger related conditions
  10880. */
  10881. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10882. /** @hidden */
  10883. _prepare(): void;
  10884. /**
  10885. * Execute the action toggle the boolean value.
  10886. */
  10887. execute(): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to set a the state field of the target
  10897. * to a desired value once triggered.
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10899. */
  10900. export class SetStateAction extends Action {
  10901. /**
  10902. * The value to store in the state field.
  10903. */
  10904. value: string;
  10905. private _target;
  10906. /**
  10907. * Instantiate the action
  10908. * @param triggerOptions defines the trigger options
  10909. * @param target defines the object containing the state property
  10910. * @param value defines the value to store in the state field
  10911. * @param condition defines the trigger related conditions
  10912. */
  10913. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10914. /**
  10915. * Execute the action and store the value on the target state property.
  10916. */
  10917. execute(): void;
  10918. /**
  10919. * Serializes the actions and its related information.
  10920. * @param parent defines the object to serialize in
  10921. * @returns the serialized object
  10922. */
  10923. serialize(parent: any): any;
  10924. }
  10925. /**
  10926. * This defines an action responsible to set a property of the target
  10927. * to a desired value once triggered.
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10929. */
  10930. export class SetValueAction extends Action {
  10931. /**
  10932. * The path of the property to set in the target.
  10933. */
  10934. propertyPath: string;
  10935. /**
  10936. * The value to set in the property
  10937. */
  10938. value: any;
  10939. private _target;
  10940. private _effectiveTarget;
  10941. private _property;
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param target defines the object containing the property
  10946. * @param propertyPath defines the path of the property to set in the target
  10947. * @param value defines the value to set in the property
  10948. * @param condition defines the trigger related conditions
  10949. */
  10950. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10951. /** @hidden */
  10952. _prepare(): void;
  10953. /**
  10954. * Execute the action and set the targetted property to the desired value.
  10955. */
  10956. execute(): void;
  10957. /**
  10958. * Serializes the actions and its related information.
  10959. * @param parent defines the object to serialize in
  10960. * @returns the serialized object
  10961. */
  10962. serialize(parent: any): any;
  10963. }
  10964. /**
  10965. * This defines an action responsible to increment the target value
  10966. * to a desired value once triggered.
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10968. */
  10969. export class IncrementValueAction extends Action {
  10970. /**
  10971. * The path of the property to increment in the target.
  10972. */
  10973. propertyPath: string;
  10974. /**
  10975. * The value we should increment the property by.
  10976. */
  10977. value: any;
  10978. private _target;
  10979. private _effectiveTarget;
  10980. private _property;
  10981. /**
  10982. * Instantiate the action
  10983. * @param triggerOptions defines the trigger options
  10984. * @param target defines the object containing the property
  10985. * @param propertyPath defines the path of the property to increment in the target
  10986. * @param value defines the value value we should increment the property by
  10987. * @param condition defines the trigger related conditions
  10988. */
  10989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10990. /** @hidden */
  10991. _prepare(): void;
  10992. /**
  10993. * Execute the action and increment the target of the value amount.
  10994. */
  10995. execute(): void;
  10996. /**
  10997. * Serializes the actions and its related information.
  10998. * @param parent defines the object to serialize in
  10999. * @returns the serialized object
  11000. */
  11001. serialize(parent: any): any;
  11002. }
  11003. /**
  11004. * This defines an action responsible to start an animation once triggered.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11006. */
  11007. export class PlayAnimationAction extends Action {
  11008. /**
  11009. * Where the animation should start (animation frame)
  11010. */
  11011. from: number;
  11012. /**
  11013. * Where the animation should stop (animation frame)
  11014. */
  11015. to: number;
  11016. /**
  11017. * Define if the animation should loop or stop after the first play.
  11018. */
  11019. loop?: boolean;
  11020. private _target;
  11021. /**
  11022. * Instantiate the action
  11023. * @param triggerOptions defines the trigger options
  11024. * @param target defines the target animation or animation name
  11025. * @param from defines from where the animation should start (animation frame)
  11026. * @param end defines where the animation should stop (animation frame)
  11027. * @param loop defines if the animation should loop or stop after the first play
  11028. * @param condition defines the trigger related conditions
  11029. */
  11030. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11031. /** @hidden */
  11032. _prepare(): void;
  11033. /**
  11034. * Execute the action and play the animation.
  11035. */
  11036. execute(): void;
  11037. /**
  11038. * Serializes the actions and its related information.
  11039. * @param parent defines the object to serialize in
  11040. * @returns the serialized object
  11041. */
  11042. serialize(parent: any): any;
  11043. }
  11044. /**
  11045. * This defines an action responsible to stop an animation once triggered.
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11047. */
  11048. export class StopAnimationAction extends Action {
  11049. private _target;
  11050. /**
  11051. * Instantiate the action
  11052. * @param triggerOptions defines the trigger options
  11053. * @param target defines the target animation or animation name
  11054. * @param condition defines the trigger related conditions
  11055. */
  11056. constructor(triggerOptions: any, target: any, condition?: Condition);
  11057. /** @hidden */
  11058. _prepare(): void;
  11059. /**
  11060. * Execute the action and stop the animation.
  11061. */
  11062. execute(): void;
  11063. /**
  11064. * Serializes the actions and its related information.
  11065. * @param parent defines the object to serialize in
  11066. * @returns the serialized object
  11067. */
  11068. serialize(parent: any): any;
  11069. }
  11070. /**
  11071. * This defines an action responsible that does nothing once triggered.
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11073. */
  11074. export class DoNothingAction extends Action {
  11075. /**
  11076. * Instantiate the action
  11077. * @param triggerOptions defines the trigger options
  11078. * @param condition defines the trigger related conditions
  11079. */
  11080. constructor(triggerOptions?: any, condition?: Condition);
  11081. /**
  11082. * Execute the action and do nothing.
  11083. */
  11084. execute(): void;
  11085. /**
  11086. * Serializes the actions and its related information.
  11087. * @param parent defines the object to serialize in
  11088. * @returns the serialized object
  11089. */
  11090. serialize(parent: any): any;
  11091. }
  11092. /**
  11093. * This defines an action responsible to trigger several actions once triggered.
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11095. */
  11096. export class CombineAction extends Action {
  11097. /**
  11098. * The list of aggregated animations to run.
  11099. */
  11100. children: Action[];
  11101. /**
  11102. * Instantiate the action
  11103. * @param triggerOptions defines the trigger options
  11104. * @param children defines the list of aggregated animations to run
  11105. * @param condition defines the trigger related conditions
  11106. */
  11107. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11108. /** @hidden */
  11109. _prepare(): void;
  11110. /**
  11111. * Execute the action and executes all the aggregated actions.
  11112. */
  11113. execute(evt: ActionEvent): void;
  11114. /**
  11115. * Serializes the actions and its related information.
  11116. * @param parent defines the object to serialize in
  11117. * @returns the serialized object
  11118. */
  11119. serialize(parent: any): any;
  11120. }
  11121. /**
  11122. * This defines an action responsible to run code (external event) once triggered.
  11123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11124. */
  11125. export class ExecuteCodeAction extends Action {
  11126. /**
  11127. * The callback function to run.
  11128. */
  11129. func: (evt: ActionEvent) => void;
  11130. /**
  11131. * Instantiate the action
  11132. * @param triggerOptions defines the trigger options
  11133. * @param func defines the callback function to run
  11134. * @param condition defines the trigger related conditions
  11135. */
  11136. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11137. /**
  11138. * Execute the action and run the attached code.
  11139. */
  11140. execute(evt: ActionEvent): void;
  11141. }
  11142. /**
  11143. * This defines an action responsible to set the parent property of the target once triggered.
  11144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11145. */
  11146. export class SetParentAction extends Action {
  11147. private _parent;
  11148. private _target;
  11149. /**
  11150. * Instantiate the action
  11151. * @param triggerOptions defines the trigger options
  11152. * @param target defines the target containing the parent property
  11153. * @param parent defines from where the animation should start (animation frame)
  11154. * @param condition defines the trigger related conditions
  11155. */
  11156. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11157. /** @hidden */
  11158. _prepare(): void;
  11159. /**
  11160. * Execute the action and set the parent property.
  11161. */
  11162. execute(): void;
  11163. /**
  11164. * Serializes the actions and its related information.
  11165. * @param parent defines the object to serialize in
  11166. * @returns the serialized object
  11167. */
  11168. serialize(parent: any): any;
  11169. }
  11170. }
  11171. declare module "babylonjs/Actions/actionManager" {
  11172. import { Nullable } from "babylonjs/types";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { Scene } from "babylonjs/scene";
  11175. import { IAction } from "babylonjs/Actions/action";
  11176. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11177. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11178. /**
  11179. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11180. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11182. */
  11183. export class ActionManager extends AbstractActionManager {
  11184. /**
  11185. * Nothing
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly NothingTrigger: number;
  11189. /**
  11190. * On pick
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnPickTrigger: number;
  11194. /**
  11195. * On left pick
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnLeftPickTrigger: number;
  11199. /**
  11200. * On right pick
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnRightPickTrigger: number;
  11204. /**
  11205. * On center pick
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnCenterPickTrigger: number;
  11209. /**
  11210. * On pick down
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnPickDownTrigger: number;
  11214. /**
  11215. * On double pick
  11216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11217. */
  11218. static readonly OnDoublePickTrigger: number;
  11219. /**
  11220. * On pick up
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnPickUpTrigger: number;
  11224. /**
  11225. * On pick out.
  11226. * This trigger will only be raised if you also declared a OnPickDown
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnPickOutTrigger: number;
  11230. /**
  11231. * On long press
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnLongPressTrigger: number;
  11235. /**
  11236. * On pointer over
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnPointerOverTrigger: number;
  11240. /**
  11241. * On pointer out
  11242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11243. */
  11244. static readonly OnPointerOutTrigger: number;
  11245. /**
  11246. * On every frame
  11247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11248. */
  11249. static readonly OnEveryFrameTrigger: number;
  11250. /**
  11251. * On intersection enter
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnIntersectionEnterTrigger: number;
  11255. /**
  11256. * On intersection exit
  11257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11258. */
  11259. static readonly OnIntersectionExitTrigger: number;
  11260. /**
  11261. * On key down
  11262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11263. */
  11264. static readonly OnKeyDownTrigger: number;
  11265. /**
  11266. * On key up
  11267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11268. */
  11269. static readonly OnKeyUpTrigger: number;
  11270. private _scene;
  11271. /**
  11272. * Creates a new action manager
  11273. * @param scene defines the hosting scene
  11274. */
  11275. constructor(scene: Scene);
  11276. /**
  11277. * Releases all associated resources
  11278. */
  11279. dispose(): void;
  11280. /**
  11281. * Gets hosting scene
  11282. * @returns the hosting scene
  11283. */
  11284. getScene(): Scene;
  11285. /**
  11286. * Does this action manager handles actions of any of the given triggers
  11287. * @param triggers defines the triggers to be tested
  11288. * @return a boolean indicating whether one (or more) of the triggers is handled
  11289. */
  11290. hasSpecificTriggers(triggers: number[]): boolean;
  11291. /**
  11292. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11293. * speed.
  11294. * @param triggerA defines the trigger to be tested
  11295. * @param triggerB defines the trigger to be tested
  11296. * @return a boolean indicating whether one (or more) of the triggers is handled
  11297. */
  11298. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11299. /**
  11300. * Does this action manager handles actions of a given trigger
  11301. * @param trigger defines the trigger to be tested
  11302. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11303. * @return whether the trigger is handled
  11304. */
  11305. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11306. /**
  11307. * Does this action manager has pointer triggers
  11308. */
  11309. readonly hasPointerTriggers: boolean;
  11310. /**
  11311. * Does this action manager has pick triggers
  11312. */
  11313. readonly hasPickTriggers: boolean;
  11314. /**
  11315. * Registers an action to this action manager
  11316. * @param action defines the action to be registered
  11317. * @return the action amended (prepared) after registration
  11318. */
  11319. registerAction(action: IAction): Nullable<IAction>;
  11320. /**
  11321. * Unregisters an action to this action manager
  11322. * @param action defines the action to be unregistered
  11323. * @return a boolean indicating whether the action has been unregistered
  11324. */
  11325. unregisterAction(action: IAction): Boolean;
  11326. /**
  11327. * Process a specific trigger
  11328. * @param trigger defines the trigger to process
  11329. * @param evt defines the event details to be processed
  11330. */
  11331. processTrigger(trigger: number, evt?: IActionEvent): void;
  11332. /** @hidden */
  11333. _getEffectiveTarget(target: any, propertyPath: string): any;
  11334. /** @hidden */
  11335. _getProperty(propertyPath: string): string;
  11336. /**
  11337. * Serialize this manager to a JSON object
  11338. * @param name defines the property name to store this manager
  11339. * @returns a JSON representation of this manager
  11340. */
  11341. serialize(name: string): any;
  11342. /**
  11343. * Creates a new ActionManager from a JSON data
  11344. * @param parsedActions defines the JSON data to read from
  11345. * @param object defines the hosting mesh
  11346. * @param scene defines the hosting scene
  11347. */
  11348. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11349. /**
  11350. * Get a trigger name by index
  11351. * @param trigger defines the trigger index
  11352. * @returns a trigger name
  11353. */
  11354. static GetTriggerName(trigger: number): string;
  11355. }
  11356. }
  11357. declare module "babylonjs/Culling/ray" {
  11358. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11359. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11361. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11362. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11363. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11364. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11365. /**
  11366. * Class representing a ray with position and direction
  11367. */
  11368. export class Ray {
  11369. /** origin point */
  11370. origin: Vector3;
  11371. /** direction */
  11372. direction: Vector3;
  11373. /** length of the ray */
  11374. length: number;
  11375. private static readonly TmpVector3;
  11376. private _tmpRay;
  11377. /**
  11378. * Creates a new ray
  11379. * @param origin origin point
  11380. * @param direction direction
  11381. * @param length length of the ray
  11382. */
  11383. constructor(
  11384. /** origin point */
  11385. origin: Vector3,
  11386. /** direction */
  11387. direction: Vector3,
  11388. /** length of the ray */
  11389. length?: number);
  11390. /**
  11391. * Checks if the ray intersects a box
  11392. * @param minimum bound of the box
  11393. * @param maximum bound of the box
  11394. * @param intersectionTreshold extra extend to be added to the box in all direction
  11395. * @returns if the box was hit
  11396. */
  11397. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11398. /**
  11399. * Checks if the ray intersects a box
  11400. * @param box the bounding box to check
  11401. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11402. * @returns if the box was hit
  11403. */
  11404. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11405. /**
  11406. * If the ray hits a sphere
  11407. * @param sphere the bounding sphere to check
  11408. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11409. * @returns true if it hits the sphere
  11410. */
  11411. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11412. /**
  11413. * If the ray hits a triange
  11414. * @param vertex0 triangle vertex
  11415. * @param vertex1 triangle vertex
  11416. * @param vertex2 triangle vertex
  11417. * @returns intersection information if hit
  11418. */
  11419. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11420. /**
  11421. * Checks if ray intersects a plane
  11422. * @param plane the plane to check
  11423. * @returns the distance away it was hit
  11424. */
  11425. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11426. /**
  11427. * Checks if ray intersects a mesh
  11428. * @param mesh the mesh to check
  11429. * @param fastCheck if only the bounding box should checked
  11430. * @returns picking info of the intersecton
  11431. */
  11432. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11433. /**
  11434. * Checks if ray intersects a mesh
  11435. * @param meshes the meshes to check
  11436. * @param fastCheck if only the bounding box should checked
  11437. * @param results array to store result in
  11438. * @returns Array of picking infos
  11439. */
  11440. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11441. private _comparePickingInfo;
  11442. private static smallnum;
  11443. private static rayl;
  11444. /**
  11445. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11446. * @param sega the first point of the segment to test the intersection against
  11447. * @param segb the second point of the segment to test the intersection against
  11448. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11449. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11450. */
  11451. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11452. /**
  11453. * Update the ray from viewport position
  11454. * @param x position
  11455. * @param y y position
  11456. * @param viewportWidth viewport width
  11457. * @param viewportHeight viewport height
  11458. * @param world world matrix
  11459. * @param view view matrix
  11460. * @param projection projection matrix
  11461. * @returns this ray updated
  11462. */
  11463. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11464. /**
  11465. * Creates a ray with origin and direction of 0,0,0
  11466. * @returns the new ray
  11467. */
  11468. static Zero(): Ray;
  11469. /**
  11470. * Creates a new ray from screen space and viewport
  11471. * @param x position
  11472. * @param y y position
  11473. * @param viewportWidth viewport width
  11474. * @param viewportHeight viewport height
  11475. * @param world world matrix
  11476. * @param view view matrix
  11477. * @param projection projection matrix
  11478. * @returns new ray
  11479. */
  11480. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11481. /**
  11482. * 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
  11483. * transformed to the given world matrix.
  11484. * @param origin The origin point
  11485. * @param end The end point
  11486. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11487. * @returns the new ray
  11488. */
  11489. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11490. /**
  11491. * Transforms a ray by a matrix
  11492. * @param ray ray to transform
  11493. * @param matrix matrix to apply
  11494. * @returns the resulting new ray
  11495. */
  11496. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11497. /**
  11498. * Transforms a ray by a matrix
  11499. * @param ray ray to transform
  11500. * @param matrix matrix to apply
  11501. * @param result ray to store result in
  11502. */
  11503. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11504. /**
  11505. * Unproject a ray from screen space to object space
  11506. * @param sourceX defines the screen space x coordinate to use
  11507. * @param sourceY defines the screen space y coordinate to use
  11508. * @param viewportWidth defines the current width of the viewport
  11509. * @param viewportHeight defines the current height of the viewport
  11510. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11511. * @param view defines the view matrix to use
  11512. * @param projection defines the projection matrix to use
  11513. */
  11514. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11515. }
  11516. /**
  11517. * Type used to define predicate used to select faces when a mesh intersection is detected
  11518. */
  11519. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11520. module "babylonjs/scene" {
  11521. interface Scene {
  11522. /** @hidden */
  11523. _tempPickingRay: Nullable<Ray>;
  11524. /** @hidden */
  11525. _cachedRayForTransform: Ray;
  11526. /** @hidden */
  11527. _pickWithRayInverseMatrix: Matrix;
  11528. /** @hidden */
  11529. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11530. /** @hidden */
  11531. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11532. }
  11533. }
  11534. }
  11535. declare module "babylonjs/sceneComponent" {
  11536. import { Scene } from "babylonjs/scene";
  11537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11539. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11540. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11541. import { Nullable } from "babylonjs/types";
  11542. import { Camera } from "babylonjs/Cameras/camera";
  11543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11545. import { AbstractScene } from "babylonjs/abstractScene";
  11546. /**
  11547. * Groups all the scene component constants in one place to ease maintenance.
  11548. * @hidden
  11549. */
  11550. export class SceneComponentConstants {
  11551. static readonly NAME_EFFECTLAYER: string;
  11552. static readonly NAME_LAYER: string;
  11553. static readonly NAME_LENSFLARESYSTEM: string;
  11554. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11555. static readonly NAME_PARTICLESYSTEM: string;
  11556. static readonly NAME_GAMEPAD: string;
  11557. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11558. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11559. static readonly NAME_DEPTHRENDERER: string;
  11560. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11561. static readonly NAME_SPRITE: string;
  11562. static readonly NAME_OUTLINERENDERER: string;
  11563. static readonly NAME_PROCEDURALTEXTURE: string;
  11564. static readonly NAME_SHADOWGENERATOR: string;
  11565. static readonly NAME_OCTREE: string;
  11566. static readonly NAME_PHYSICSENGINE: string;
  11567. static readonly NAME_AUDIO: string;
  11568. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11569. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11570. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11571. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11572. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11573. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11574. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11575. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11576. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11577. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11578. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11579. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11580. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11581. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11582. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11583. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11584. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11585. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11586. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11587. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11588. static readonly STEP_AFTERRENDER_AUDIO: number;
  11589. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11590. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11591. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11592. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11593. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11594. static readonly STEP_POINTERMOVE_SPRITE: number;
  11595. static readonly STEP_POINTERDOWN_SPRITE: number;
  11596. static readonly STEP_POINTERUP_SPRITE: number;
  11597. }
  11598. /**
  11599. * This represents a scene component.
  11600. *
  11601. * This is used to decouple the dependency the scene is having on the different workloads like
  11602. * layers, post processes...
  11603. */
  11604. export interface ISceneComponent {
  11605. /**
  11606. * The name of the component. Each component must have a unique name.
  11607. */
  11608. name: string;
  11609. /**
  11610. * The scene the component belongs to.
  11611. */
  11612. scene: Scene;
  11613. /**
  11614. * Register the component to one instance of a scene.
  11615. */
  11616. register(): void;
  11617. /**
  11618. * Rebuilds the elements related to this component in case of
  11619. * context lost for instance.
  11620. */
  11621. rebuild(): void;
  11622. /**
  11623. * Disposes the component and the associated ressources.
  11624. */
  11625. dispose(): void;
  11626. }
  11627. /**
  11628. * This represents a SERIALIZABLE scene component.
  11629. *
  11630. * This extends Scene Component to add Serialization methods on top.
  11631. */
  11632. export interface ISceneSerializableComponent extends ISceneComponent {
  11633. /**
  11634. * Adds all the element from the container to the scene
  11635. * @param container the container holding the elements
  11636. */
  11637. addFromContainer(container: AbstractScene): void;
  11638. /**
  11639. * Removes all the elements in the container from the scene
  11640. * @param container contains the elements to remove
  11641. * @param dispose if the removed element should be disposed (default: false)
  11642. */
  11643. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11644. /**
  11645. * Serializes the component data to the specified json object
  11646. * @param serializationObject The object to serialize to
  11647. */
  11648. serialize(serializationObject: any): void;
  11649. }
  11650. /**
  11651. * Strong typing of a Mesh related stage step action
  11652. */
  11653. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11654. /**
  11655. * Strong typing of a Evaluate Sub Mesh related stage step action
  11656. */
  11657. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11658. /**
  11659. * Strong typing of a Active Mesh related stage step action
  11660. */
  11661. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11662. /**
  11663. * Strong typing of a Camera related stage step action
  11664. */
  11665. export type CameraStageAction = (camera: Camera) => void;
  11666. /**
  11667. * Strong typing of a Render Target related stage step action
  11668. */
  11669. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11670. /**
  11671. * Strong typing of a RenderingGroup related stage step action
  11672. */
  11673. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11674. /**
  11675. * Strong typing of a Mesh Render related stage step action
  11676. */
  11677. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11678. /**
  11679. * Strong typing of a simple stage step action
  11680. */
  11681. export type SimpleStageAction = () => void;
  11682. /**
  11683. * Strong typing of a render target action.
  11684. */
  11685. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11686. /**
  11687. * Strong typing of a pointer move action.
  11688. */
  11689. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11690. /**
  11691. * Strong typing of a pointer up/down action.
  11692. */
  11693. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11694. /**
  11695. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11696. * @hidden
  11697. */
  11698. export class Stage<T extends Function> extends Array<{
  11699. index: number;
  11700. component: ISceneComponent;
  11701. action: T;
  11702. }> {
  11703. /**
  11704. * Hide ctor from the rest of the world.
  11705. * @param items The items to add.
  11706. */
  11707. private constructor();
  11708. /**
  11709. * Creates a new Stage.
  11710. * @returns A new instance of a Stage
  11711. */
  11712. static Create<T extends Function>(): Stage<T>;
  11713. /**
  11714. * Registers a step in an ordered way in the targeted stage.
  11715. * @param index Defines the position to register the step in
  11716. * @param component Defines the component attached to the step
  11717. * @param action Defines the action to launch during the step
  11718. */
  11719. registerStep(index: number, component: ISceneComponent, action: T): void;
  11720. /**
  11721. * Clears all the steps from the stage.
  11722. */
  11723. clear(): void;
  11724. }
  11725. }
  11726. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11727. import { Nullable } from "babylonjs/types";
  11728. import { Observable } from "babylonjs/Misc/observable";
  11729. import { Scene } from "babylonjs/scene";
  11730. import { Sprite } from "babylonjs/Sprites/sprite";
  11731. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11732. import { Ray } from "babylonjs/Culling/ray";
  11733. import { Camera } from "babylonjs/Cameras/camera";
  11734. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11735. import { ISceneComponent } from "babylonjs/sceneComponent";
  11736. module "babylonjs/scene" {
  11737. interface Scene {
  11738. /** @hidden */
  11739. _pointerOverSprite: Nullable<Sprite>;
  11740. /** @hidden */
  11741. _pickedDownSprite: Nullable<Sprite>;
  11742. /** @hidden */
  11743. _tempSpritePickingRay: Nullable<Ray>;
  11744. /**
  11745. * All of the sprite managers added to this scene
  11746. * @see http://doc.babylonjs.com/babylon101/sprites
  11747. */
  11748. spriteManagers: Array<ISpriteManager>;
  11749. /**
  11750. * An event triggered when sprites rendering is about to start
  11751. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11752. */
  11753. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11754. /**
  11755. * An event triggered when sprites rendering is done
  11756. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11757. */
  11758. onAfterSpritesRenderingObservable: Observable<Scene>;
  11759. /** @hidden */
  11760. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** Launch a ray to try to pick a sprite in the scene
  11762. * @param x position on screen
  11763. * @param y position on screen
  11764. * @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
  11765. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11767. * @returns a PickingInfo
  11768. */
  11769. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11770. /** Use the given ray to pick a sprite in the scene
  11771. * @param ray The ray (in world space) to use to pick meshes
  11772. * @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
  11773. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11775. * @returns a PickingInfo
  11776. */
  11777. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11778. /**
  11779. * Force the sprite under the pointer
  11780. * @param sprite defines the sprite to use
  11781. */
  11782. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11783. /**
  11784. * Gets the sprite under the pointer
  11785. * @returns a Sprite or null if no sprite is under the pointer
  11786. */
  11787. getPointerOverSprite(): Nullable<Sprite>;
  11788. }
  11789. }
  11790. /**
  11791. * Defines the sprite scene component responsible to manage sprites
  11792. * in a given scene.
  11793. */
  11794. export class SpriteSceneComponent implements ISceneComponent {
  11795. /**
  11796. * The component name helpfull to identify the component in the list of scene components.
  11797. */
  11798. readonly name: string;
  11799. /**
  11800. * The scene the component belongs to.
  11801. */
  11802. scene: Scene;
  11803. /** @hidden */
  11804. private _spritePredicate;
  11805. /**
  11806. * Creates a new instance of the component for the given scene
  11807. * @param scene Defines the scene to register the component in
  11808. */
  11809. constructor(scene: Scene);
  11810. /**
  11811. * Registers the component in a given scene
  11812. */
  11813. register(): void;
  11814. /**
  11815. * Rebuilds the elements related to this component in case of
  11816. * context lost for instance.
  11817. */
  11818. rebuild(): void;
  11819. /**
  11820. * Disposes the component and the associated ressources.
  11821. */
  11822. dispose(): void;
  11823. private _pickSpriteButKeepRay;
  11824. private _pointerMove;
  11825. private _pointerDown;
  11826. private _pointerUp;
  11827. }
  11828. }
  11829. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11830. /** @hidden */
  11831. export var fogFragmentDeclaration: {
  11832. name: string;
  11833. shader: string;
  11834. };
  11835. }
  11836. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11837. /** @hidden */
  11838. export var fogFragment: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Shaders/sprites.fragment" {
  11844. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11845. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11846. /** @hidden */
  11847. export var spritesPixelShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11853. /** @hidden */
  11854. export var fogVertexDeclaration: {
  11855. name: string;
  11856. shader: string;
  11857. };
  11858. }
  11859. declare module "babylonjs/Shaders/sprites.vertex" {
  11860. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11861. /** @hidden */
  11862. export var spritesVertexShader: {
  11863. name: string;
  11864. shader: string;
  11865. };
  11866. }
  11867. declare module "babylonjs/Sprites/spriteManager" {
  11868. import { IDisposable, Scene } from "babylonjs/scene";
  11869. import { Nullable } from "babylonjs/types";
  11870. import { Observable } from "babylonjs/Misc/observable";
  11871. import { Sprite } from "babylonjs/Sprites/sprite";
  11872. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11873. import { Camera } from "babylonjs/Cameras/camera";
  11874. import { Texture } from "babylonjs/Materials/Textures/texture";
  11875. import "babylonjs/Shaders/sprites.fragment";
  11876. import "babylonjs/Shaders/sprites.vertex";
  11877. import { Ray } from "babylonjs/Culling/ray";
  11878. /**
  11879. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11880. */
  11881. export interface ISpriteManager extends IDisposable {
  11882. /**
  11883. * Restricts the camera to viewing objects with the same layerMask.
  11884. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11885. */
  11886. layerMask: number;
  11887. /**
  11888. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11889. */
  11890. isPickable: boolean;
  11891. /**
  11892. * Specifies the rendering group id for this mesh (0 by default)
  11893. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11894. */
  11895. renderingGroupId: number;
  11896. /**
  11897. * Defines the list of sprites managed by the manager.
  11898. */
  11899. sprites: Array<Sprite>;
  11900. /**
  11901. * Tests the intersection of a sprite with a specific ray.
  11902. * @param ray The ray we are sending to test the collision
  11903. * @param camera The camera space we are sending rays in
  11904. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11905. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11906. * @returns picking info or null.
  11907. */
  11908. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11909. /**
  11910. * Renders the list of sprites on screen.
  11911. */
  11912. render(): void;
  11913. }
  11914. /**
  11915. * Class used to manage multiple sprites on the same spritesheet
  11916. * @see http://doc.babylonjs.com/babylon101/sprites
  11917. */
  11918. export class SpriteManager implements ISpriteManager {
  11919. /** defines the manager's name */
  11920. name: string;
  11921. /** Gets the list of sprites */
  11922. sprites: Sprite[];
  11923. /** Gets or sets the rendering group id (0 by default) */
  11924. renderingGroupId: number;
  11925. /** Gets or sets camera layer mask */
  11926. layerMask: number;
  11927. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11928. fogEnabled: boolean;
  11929. /** Gets or sets a boolean indicating if the sprites are pickable */
  11930. isPickable: boolean;
  11931. /** Defines the default width of a cell in the spritesheet */
  11932. cellWidth: number;
  11933. /** Defines the default height of a cell in the spritesheet */
  11934. cellHeight: number;
  11935. /**
  11936. * An event triggered when the manager is disposed.
  11937. */
  11938. onDisposeObservable: Observable<SpriteManager>;
  11939. private _onDisposeObserver;
  11940. /**
  11941. * Callback called when the manager is disposed
  11942. */
  11943. onDispose: () => void;
  11944. private _capacity;
  11945. private _spriteTexture;
  11946. private _epsilon;
  11947. private _scene;
  11948. private _vertexData;
  11949. private _buffer;
  11950. private _vertexBuffers;
  11951. private _indexBuffer;
  11952. private _effectBase;
  11953. private _effectFog;
  11954. /**
  11955. * Gets or sets the spritesheet texture
  11956. */
  11957. texture: Texture;
  11958. /**
  11959. * Creates a new sprite manager
  11960. * @param name defines the manager's name
  11961. * @param imgUrl defines the sprite sheet url
  11962. * @param capacity defines the maximum allowed number of sprites
  11963. * @param cellSize defines the size of a sprite cell
  11964. * @param scene defines the hosting scene
  11965. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11966. * @param samplingMode defines the smapling mode to use with spritesheet
  11967. */
  11968. constructor(
  11969. /** defines the manager's name */
  11970. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11971. private _appendSpriteVertex;
  11972. /**
  11973. * Intersects the sprites with a ray
  11974. * @param ray defines the ray to intersect with
  11975. * @param camera defines the current active camera
  11976. * @param predicate defines a predicate used to select candidate sprites
  11977. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11978. * @returns null if no hit or a PickingInfo
  11979. */
  11980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11981. /**
  11982. * Render all child sprites
  11983. */
  11984. render(): void;
  11985. /**
  11986. * Release associated resources
  11987. */
  11988. dispose(): void;
  11989. }
  11990. }
  11991. declare module "babylonjs/Sprites/sprite" {
  11992. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11993. import { Nullable } from "babylonjs/types";
  11994. import { ActionManager } from "babylonjs/Actions/actionManager";
  11995. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11996. /**
  11997. * Class used to represent a sprite
  11998. * @see http://doc.babylonjs.com/babylon101/sprites
  11999. */
  12000. export class Sprite {
  12001. /** defines the name */
  12002. name: string;
  12003. /** Gets or sets the current world position */
  12004. position: Vector3;
  12005. /** Gets or sets the main color */
  12006. color: Color4;
  12007. /** Gets or sets the width */
  12008. width: number;
  12009. /** Gets or sets the height */
  12010. height: number;
  12011. /** Gets or sets rotation angle */
  12012. angle: number;
  12013. /** Gets or sets the cell index in the sprite sheet */
  12014. cellIndex: number;
  12015. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12016. invertU: number;
  12017. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12018. invertV: number;
  12019. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12020. disposeWhenFinishedAnimating: boolean;
  12021. /** Gets the list of attached animations */
  12022. animations: Animation[];
  12023. /** Gets or sets a boolean indicating if the sprite can be picked */
  12024. isPickable: boolean;
  12025. /**
  12026. * Gets or sets the associated action manager
  12027. */
  12028. actionManager: Nullable<ActionManager>;
  12029. private _animationStarted;
  12030. private _loopAnimation;
  12031. private _fromIndex;
  12032. private _toIndex;
  12033. private _delay;
  12034. private _direction;
  12035. private _manager;
  12036. private _time;
  12037. private _onAnimationEnd;
  12038. /**
  12039. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12040. */
  12041. isVisible: boolean;
  12042. /**
  12043. * Gets or sets the sprite size
  12044. */
  12045. size: number;
  12046. /**
  12047. * Creates a new Sprite
  12048. * @param name defines the name
  12049. * @param manager defines the manager
  12050. */
  12051. constructor(
  12052. /** defines the name */
  12053. name: string, manager: ISpriteManager);
  12054. /**
  12055. * Starts an animation
  12056. * @param from defines the initial key
  12057. * @param to defines the end key
  12058. * @param loop defines if the animation must loop
  12059. * @param delay defines the start delay (in ms)
  12060. * @param onAnimationEnd defines a callback to call when animation ends
  12061. */
  12062. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12063. /** Stops current animation (if any) */
  12064. stopAnimation(): void;
  12065. /** @hidden */
  12066. _animate(deltaTime: number): void;
  12067. /** Release associated resources */
  12068. dispose(): void;
  12069. }
  12070. }
  12071. declare module "babylonjs/Collisions/pickingInfo" {
  12072. import { Nullable } from "babylonjs/types";
  12073. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12075. import { Sprite } from "babylonjs/Sprites/sprite";
  12076. import { Ray } from "babylonjs/Culling/ray";
  12077. /**
  12078. * Information about the result of picking within a scene
  12079. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12080. */
  12081. export class PickingInfo {
  12082. /** @hidden */
  12083. _pickingUnavailable: boolean;
  12084. /**
  12085. * If the pick collided with an object
  12086. */
  12087. hit: boolean;
  12088. /**
  12089. * Distance away where the pick collided
  12090. */
  12091. distance: number;
  12092. /**
  12093. * The location of pick collision
  12094. */
  12095. pickedPoint: Nullable<Vector3>;
  12096. /**
  12097. * The mesh corresponding the the pick collision
  12098. */
  12099. pickedMesh: Nullable<AbstractMesh>;
  12100. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12101. bu: number;
  12102. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12103. bv: number;
  12104. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12105. faceId: number;
  12106. /** Id of the the submesh that was picked */
  12107. subMeshId: number;
  12108. /** If a sprite was picked, this will be the sprite the pick collided with */
  12109. pickedSprite: Nullable<Sprite>;
  12110. /**
  12111. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12112. */
  12113. originMesh: Nullable<AbstractMesh>;
  12114. /**
  12115. * The ray that was used to perform the picking.
  12116. */
  12117. ray: Nullable<Ray>;
  12118. /**
  12119. * Gets the normal correspodning to the face the pick collided with
  12120. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12121. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12122. * @returns The normal correspodning to the face the pick collided with
  12123. */
  12124. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12125. /**
  12126. * Gets the texture coordinates of where the pick occured
  12127. * @returns the vector containing the coordnates of the texture
  12128. */
  12129. getTextureCoordinates(): Nullable<Vector2>;
  12130. }
  12131. }
  12132. declare module "babylonjs/Events/pointerEvents" {
  12133. import { Nullable } from "babylonjs/types";
  12134. import { Vector2 } from "babylonjs/Maths/math";
  12135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12136. import { Ray } from "babylonjs/Culling/ray";
  12137. /**
  12138. * Gather the list of pointer event types as constants.
  12139. */
  12140. export class PointerEventTypes {
  12141. /**
  12142. * 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.
  12143. */
  12144. static readonly POINTERDOWN: number;
  12145. /**
  12146. * The pointerup event is fired when a pointer is no longer active.
  12147. */
  12148. static readonly POINTERUP: number;
  12149. /**
  12150. * The pointermove event is fired when a pointer changes coordinates.
  12151. */
  12152. static readonly POINTERMOVE: number;
  12153. /**
  12154. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12155. */
  12156. static readonly POINTERWHEEL: number;
  12157. /**
  12158. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12159. */
  12160. static readonly POINTERPICK: number;
  12161. /**
  12162. * The pointertap event is fired when a the object has been touched and released without drag.
  12163. */
  12164. static readonly POINTERTAP: number;
  12165. /**
  12166. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12167. */
  12168. static readonly POINTERDOUBLETAP: number;
  12169. }
  12170. /**
  12171. * Base class of pointer info types.
  12172. */
  12173. export class PointerInfoBase {
  12174. /**
  12175. * Defines the type of event (PointerEventTypes)
  12176. */
  12177. type: number;
  12178. /**
  12179. * Defines the related dom event
  12180. */
  12181. event: PointerEvent | MouseWheelEvent;
  12182. /**
  12183. * Instantiates the base class of pointers info.
  12184. * @param type Defines the type of event (PointerEventTypes)
  12185. * @param event Defines the related dom event
  12186. */
  12187. constructor(
  12188. /**
  12189. * Defines the type of event (PointerEventTypes)
  12190. */
  12191. type: number,
  12192. /**
  12193. * Defines the related dom event
  12194. */
  12195. event: PointerEvent | MouseWheelEvent);
  12196. }
  12197. /**
  12198. * This class is used to store pointer related info for the onPrePointerObservable event.
  12199. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12200. */
  12201. export class PointerInfoPre extends PointerInfoBase {
  12202. /**
  12203. * Ray from a pointer if availible (eg. 6dof controller)
  12204. */
  12205. ray: Nullable<Ray>;
  12206. /**
  12207. * Defines the local position of the pointer on the canvas.
  12208. */
  12209. localPosition: Vector2;
  12210. /**
  12211. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12212. */
  12213. skipOnPointerObservable: boolean;
  12214. /**
  12215. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12216. * @param type Defines the type of event (PointerEventTypes)
  12217. * @param event Defines the related dom event
  12218. * @param localX Defines the local x coordinates of the pointer when the event occured
  12219. * @param localY Defines the local y coordinates of the pointer when the event occured
  12220. */
  12221. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12222. }
  12223. /**
  12224. * This type contains all the data related to a pointer event in Babylon.js.
  12225. * 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.
  12226. */
  12227. export class PointerInfo extends PointerInfoBase {
  12228. /**
  12229. * Defines the picking info associated to the info (if any)\
  12230. */
  12231. pickInfo: Nullable<PickingInfo>;
  12232. /**
  12233. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12234. * @param type Defines the type of event (PointerEventTypes)
  12235. * @param event Defines the related dom event
  12236. * @param pickInfo Defines the picking info associated to the info (if any)\
  12237. */
  12238. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12239. /**
  12240. * Defines the picking info associated to the info (if any)\
  12241. */
  12242. pickInfo: Nullable<PickingInfo>);
  12243. }
  12244. /**
  12245. * Data relating to a touch event on the screen.
  12246. */
  12247. export interface PointerTouch {
  12248. /**
  12249. * X coordinate of touch.
  12250. */
  12251. x: number;
  12252. /**
  12253. * Y coordinate of touch.
  12254. */
  12255. y: number;
  12256. /**
  12257. * Id of touch. Unique for each finger.
  12258. */
  12259. pointerId: number;
  12260. /**
  12261. * Event type passed from DOM.
  12262. */
  12263. type: any;
  12264. }
  12265. }
  12266. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12267. import { Observable } from "babylonjs/Misc/observable";
  12268. import { Nullable } from "babylonjs/types";
  12269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12271. /**
  12272. * Manage the mouse inputs to control the movement of a free camera.
  12273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12274. */
  12275. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12276. /**
  12277. * Define if touch is enabled in the mouse input
  12278. */
  12279. touchEnabled: boolean;
  12280. /**
  12281. * Defines the camera the input is attached to.
  12282. */
  12283. camera: FreeCamera;
  12284. /**
  12285. * Defines the buttons associated with the input to handle camera move.
  12286. */
  12287. buttons: number[];
  12288. /**
  12289. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12290. */
  12291. angularSensibility: number;
  12292. private _pointerInput;
  12293. private _onMouseMove;
  12294. private _observer;
  12295. private previousPosition;
  12296. /**
  12297. * Observable for when a pointer move event occurs containing the move offset
  12298. */
  12299. onPointerMovedObservable: Observable<{
  12300. offsetX: number;
  12301. offsetY: number;
  12302. }>;
  12303. /**
  12304. * @hidden
  12305. * If the camera should be rotated automatically based on pointer movement
  12306. */
  12307. _allowCameraRotation: boolean;
  12308. /**
  12309. * Manage the mouse inputs to control the movement of a free camera.
  12310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12311. * @param touchEnabled Defines if touch is enabled or not
  12312. */
  12313. constructor(
  12314. /**
  12315. * Define if touch is enabled in the mouse input
  12316. */
  12317. touchEnabled?: boolean);
  12318. /**
  12319. * Attach the input controls to a specific dom element to get the input from.
  12320. * @param element Defines the element the controls should be listened from
  12321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12322. */
  12323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12324. /**
  12325. * Called on JS contextmenu event.
  12326. * Override this method to provide functionality.
  12327. */
  12328. protected onContextMenu(evt: PointerEvent): void;
  12329. /**
  12330. * Detach the current controls from the specified dom element.
  12331. * @param element Defines the element to stop listening the inputs from
  12332. */
  12333. detachControl(element: Nullable<HTMLElement>): void;
  12334. /**
  12335. * Gets the class name of the current intput.
  12336. * @returns the class name
  12337. */
  12338. getClassName(): string;
  12339. /**
  12340. * Get the friendly name associated with the input class.
  12341. * @returns the input friendly name
  12342. */
  12343. getSimpleName(): string;
  12344. }
  12345. }
  12346. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12347. import { Nullable } from "babylonjs/types";
  12348. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12349. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12350. /**
  12351. * Manage the touch inputs to control the movement of a free camera.
  12352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12353. */
  12354. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12355. /**
  12356. * Defines the camera the input is attached to.
  12357. */
  12358. camera: FreeCamera;
  12359. /**
  12360. * Defines the touch sensibility for rotation.
  12361. * The higher the faster.
  12362. */
  12363. touchAngularSensibility: number;
  12364. /**
  12365. * Defines the touch sensibility for move.
  12366. * The higher the faster.
  12367. */
  12368. touchMoveSensibility: number;
  12369. private _offsetX;
  12370. private _offsetY;
  12371. private _pointerPressed;
  12372. private _pointerInput;
  12373. private _observer;
  12374. private _onLostFocus;
  12375. /**
  12376. * Attach the input controls to a specific dom element to get the input from.
  12377. * @param element Defines the element the controls should be listened from
  12378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12379. */
  12380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12381. /**
  12382. * Detach the current controls from the specified dom element.
  12383. * @param element Defines the element to stop listening the inputs from
  12384. */
  12385. detachControl(element: Nullable<HTMLElement>): void;
  12386. /**
  12387. * Update the current camera state depending on the inputs that have been used this frame.
  12388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12389. */
  12390. checkInputs(): void;
  12391. /**
  12392. * Gets the class name of the current intput.
  12393. * @returns the class name
  12394. */
  12395. getClassName(): string;
  12396. /**
  12397. * Get the friendly name associated with the input class.
  12398. * @returns the input friendly name
  12399. */
  12400. getSimpleName(): string;
  12401. }
  12402. }
  12403. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12405. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12406. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12407. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12408. import { Nullable } from "babylonjs/types";
  12409. /**
  12410. * Default Inputs manager for the FreeCamera.
  12411. * It groups all the default supported inputs for ease of use.
  12412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12413. */
  12414. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12415. /**
  12416. * @hidden
  12417. */
  12418. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12419. /**
  12420. * @hidden
  12421. */
  12422. _mouseInput: Nullable<FreeCameraMouseInput>;
  12423. /**
  12424. * Instantiates a new FreeCameraInputsManager.
  12425. * @param camera Defines the camera the inputs belong to
  12426. */
  12427. constructor(camera: FreeCamera);
  12428. /**
  12429. * Add keyboard input support to the input manager.
  12430. * @returns the current input manager
  12431. */
  12432. addKeyboard(): FreeCameraInputsManager;
  12433. /**
  12434. * Add mouse input support to the input manager.
  12435. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12436. * @returns the current input manager
  12437. */
  12438. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12439. /**
  12440. * Removes the mouse input support from the manager
  12441. * @returns the current input manager
  12442. */
  12443. removeMouse(): FreeCameraInputsManager;
  12444. /**
  12445. * Add touch input support to the input manager.
  12446. * @returns the current input manager
  12447. */
  12448. addTouch(): FreeCameraInputsManager;
  12449. }
  12450. }
  12451. declare module "babylonjs/Cameras/freeCamera" {
  12452. import { Vector3 } from "babylonjs/Maths/math";
  12453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12454. import { Scene } from "babylonjs/scene";
  12455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12456. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12457. /**
  12458. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12459. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12460. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12461. */
  12462. export class FreeCamera extends TargetCamera {
  12463. /**
  12464. * Define the collision ellipsoid of the camera.
  12465. * This is helpful to simulate a camera body like the player body around the camera
  12466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12467. */
  12468. ellipsoid: Vector3;
  12469. /**
  12470. * Define an offset for the position of the ellipsoid around the camera.
  12471. * This can be helpful to determine the center of the body near the gravity center of the body
  12472. * instead of its head.
  12473. */
  12474. ellipsoidOffset: Vector3;
  12475. /**
  12476. * Enable or disable collisions of the camera with the rest of the scene objects.
  12477. */
  12478. checkCollisions: boolean;
  12479. /**
  12480. * Enable or disable gravity on the camera.
  12481. */
  12482. applyGravity: boolean;
  12483. /**
  12484. * Define the input manager associated to the camera.
  12485. */
  12486. inputs: FreeCameraInputsManager;
  12487. /**
  12488. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12489. * Higher values reduce sensitivity.
  12490. */
  12491. /**
  12492. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12493. * Higher values reduce sensitivity.
  12494. */
  12495. angularSensibility: number;
  12496. /**
  12497. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12498. */
  12499. keysUp: number[];
  12500. /**
  12501. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12502. */
  12503. keysDown: number[];
  12504. /**
  12505. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12506. */
  12507. keysLeft: number[];
  12508. /**
  12509. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12510. */
  12511. keysRight: number[];
  12512. /**
  12513. * Event raised when the camera collide with a mesh in the scene.
  12514. */
  12515. onCollide: (collidedMesh: AbstractMesh) => void;
  12516. private _collider;
  12517. private _needMoveForGravity;
  12518. private _oldPosition;
  12519. private _diffPosition;
  12520. private _newPosition;
  12521. /** @hidden */
  12522. _localDirection: Vector3;
  12523. /** @hidden */
  12524. _transformedDirection: Vector3;
  12525. /**
  12526. * Instantiates a Free Camera.
  12527. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12528. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12529. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12530. * @param name Define the name of the camera in the scene
  12531. * @param position Define the start position of the camera in the scene
  12532. * @param scene Define the scene the camera belongs to
  12533. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12534. */
  12535. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12536. /**
  12537. * Attached controls to the current camera.
  12538. * @param element Defines the element the controls should be listened from
  12539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12540. */
  12541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12542. /**
  12543. * Detach the current controls from the camera.
  12544. * The camera will stop reacting to inputs.
  12545. * @param element Defines the element to stop listening the inputs from
  12546. */
  12547. detachControl(element: HTMLElement): void;
  12548. private _collisionMask;
  12549. /**
  12550. * Define a collision mask to limit the list of object the camera can collide with
  12551. */
  12552. collisionMask: number;
  12553. /** @hidden */
  12554. _collideWithWorld(displacement: Vector3): void;
  12555. private _onCollisionPositionChange;
  12556. /** @hidden */
  12557. _checkInputs(): void;
  12558. /** @hidden */
  12559. _decideIfNeedsToMove(): boolean;
  12560. /** @hidden */
  12561. _updatePosition(): void;
  12562. /**
  12563. * Destroy the camera and release the current resources hold by it.
  12564. */
  12565. dispose(): void;
  12566. /**
  12567. * Gets the current object class name.
  12568. * @return the class name
  12569. */
  12570. getClassName(): string;
  12571. }
  12572. }
  12573. declare module "babylonjs/Gamepads/gamepad" {
  12574. import { Observable } from "babylonjs/Misc/observable";
  12575. /**
  12576. * Represents a gamepad control stick position
  12577. */
  12578. export class StickValues {
  12579. /**
  12580. * The x component of the control stick
  12581. */
  12582. x: number;
  12583. /**
  12584. * The y component of the control stick
  12585. */
  12586. y: number;
  12587. /**
  12588. * Initializes the gamepad x and y control stick values
  12589. * @param x The x component of the gamepad control stick value
  12590. * @param y The y component of the gamepad control stick value
  12591. */
  12592. constructor(
  12593. /**
  12594. * The x component of the control stick
  12595. */
  12596. x: number,
  12597. /**
  12598. * The y component of the control stick
  12599. */
  12600. y: number);
  12601. }
  12602. /**
  12603. * An interface which manages callbacks for gamepad button changes
  12604. */
  12605. export interface GamepadButtonChanges {
  12606. /**
  12607. * Called when a gamepad has been changed
  12608. */
  12609. changed: boolean;
  12610. /**
  12611. * Called when a gamepad press event has been triggered
  12612. */
  12613. pressChanged: boolean;
  12614. /**
  12615. * Called when a touch event has been triggered
  12616. */
  12617. touchChanged: boolean;
  12618. /**
  12619. * Called when a value has changed
  12620. */
  12621. valueChanged: boolean;
  12622. }
  12623. /**
  12624. * Represents a gamepad
  12625. */
  12626. export class Gamepad {
  12627. /**
  12628. * The id of the gamepad
  12629. */
  12630. id: string;
  12631. /**
  12632. * The index of the gamepad
  12633. */
  12634. index: number;
  12635. /**
  12636. * The browser gamepad
  12637. */
  12638. browserGamepad: any;
  12639. /**
  12640. * Specifies what type of gamepad this represents
  12641. */
  12642. type: number;
  12643. private _leftStick;
  12644. private _rightStick;
  12645. /** @hidden */
  12646. _isConnected: boolean;
  12647. private _leftStickAxisX;
  12648. private _leftStickAxisY;
  12649. private _rightStickAxisX;
  12650. private _rightStickAxisY;
  12651. /**
  12652. * Triggered when the left control stick has been changed
  12653. */
  12654. private _onleftstickchanged;
  12655. /**
  12656. * Triggered when the right control stick has been changed
  12657. */
  12658. private _onrightstickchanged;
  12659. /**
  12660. * Represents a gamepad controller
  12661. */
  12662. static GAMEPAD: number;
  12663. /**
  12664. * Represents a generic controller
  12665. */
  12666. static GENERIC: number;
  12667. /**
  12668. * Represents an XBox controller
  12669. */
  12670. static XBOX: number;
  12671. /**
  12672. * Represents a pose-enabled controller
  12673. */
  12674. static POSE_ENABLED: number;
  12675. /**
  12676. * Specifies whether the left control stick should be Y-inverted
  12677. */
  12678. protected _invertLeftStickY: boolean;
  12679. /**
  12680. * Specifies if the gamepad has been connected
  12681. */
  12682. readonly isConnected: boolean;
  12683. /**
  12684. * Initializes the gamepad
  12685. * @param id The id of the gamepad
  12686. * @param index The index of the gamepad
  12687. * @param browserGamepad The browser gamepad
  12688. * @param leftStickX The x component of the left joystick
  12689. * @param leftStickY The y component of the left joystick
  12690. * @param rightStickX The x component of the right joystick
  12691. * @param rightStickY The y component of the right joystick
  12692. */
  12693. constructor(
  12694. /**
  12695. * The id of the gamepad
  12696. */
  12697. id: string,
  12698. /**
  12699. * The index of the gamepad
  12700. */
  12701. index: number,
  12702. /**
  12703. * The browser gamepad
  12704. */
  12705. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12706. /**
  12707. * Callback triggered when the left joystick has changed
  12708. * @param callback
  12709. */
  12710. onleftstickchanged(callback: (values: StickValues) => void): void;
  12711. /**
  12712. * Callback triggered when the right joystick has changed
  12713. * @param callback
  12714. */
  12715. onrightstickchanged(callback: (values: StickValues) => void): void;
  12716. /**
  12717. * Gets the left joystick
  12718. */
  12719. /**
  12720. * Sets the left joystick values
  12721. */
  12722. leftStick: StickValues;
  12723. /**
  12724. * Gets the right joystick
  12725. */
  12726. /**
  12727. * Sets the right joystick value
  12728. */
  12729. rightStick: StickValues;
  12730. /**
  12731. * Updates the gamepad joystick positions
  12732. */
  12733. update(): void;
  12734. /**
  12735. * Disposes the gamepad
  12736. */
  12737. dispose(): void;
  12738. }
  12739. /**
  12740. * Represents a generic gamepad
  12741. */
  12742. export class GenericPad extends Gamepad {
  12743. private _buttons;
  12744. private _onbuttondown;
  12745. private _onbuttonup;
  12746. /**
  12747. * Observable triggered when a button has been pressed
  12748. */
  12749. onButtonDownObservable: Observable<number>;
  12750. /**
  12751. * Observable triggered when a button has been released
  12752. */
  12753. onButtonUpObservable: Observable<number>;
  12754. /**
  12755. * Callback triggered when a button has been pressed
  12756. * @param callback Called when a button has been pressed
  12757. */
  12758. onbuttondown(callback: (buttonPressed: number) => void): void;
  12759. /**
  12760. * Callback triggered when a button has been released
  12761. * @param callback Called when a button has been released
  12762. */
  12763. onbuttonup(callback: (buttonReleased: number) => void): void;
  12764. /**
  12765. * Initializes the generic gamepad
  12766. * @param id The id of the generic gamepad
  12767. * @param index The index of the generic gamepad
  12768. * @param browserGamepad The browser gamepad
  12769. */
  12770. constructor(id: string, index: number, browserGamepad: any);
  12771. private _setButtonValue;
  12772. /**
  12773. * Updates the generic gamepad
  12774. */
  12775. update(): void;
  12776. /**
  12777. * Disposes the generic gamepad
  12778. */
  12779. dispose(): void;
  12780. }
  12781. }
  12782. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12783. import { Observable } from "babylonjs/Misc/observable";
  12784. import { Nullable } from "babylonjs/types";
  12785. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12786. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12788. import { Ray } from "babylonjs/Culling/ray";
  12789. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12790. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12791. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12792. /**
  12793. * Defines the types of pose enabled controllers that are supported
  12794. */
  12795. export enum PoseEnabledControllerType {
  12796. /**
  12797. * HTC Vive
  12798. */
  12799. VIVE = 0,
  12800. /**
  12801. * Oculus Rift
  12802. */
  12803. OCULUS = 1,
  12804. /**
  12805. * Windows mixed reality
  12806. */
  12807. WINDOWS = 2,
  12808. /**
  12809. * Samsung gear VR
  12810. */
  12811. GEAR_VR = 3,
  12812. /**
  12813. * Google Daydream
  12814. */
  12815. DAYDREAM = 4,
  12816. /**
  12817. * Generic
  12818. */
  12819. GENERIC = 5
  12820. }
  12821. /**
  12822. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12823. */
  12824. export interface MutableGamepadButton {
  12825. /**
  12826. * Value of the button/trigger
  12827. */
  12828. value: number;
  12829. /**
  12830. * If the button/trigger is currently touched
  12831. */
  12832. touched: boolean;
  12833. /**
  12834. * If the button/trigger is currently pressed
  12835. */
  12836. pressed: boolean;
  12837. }
  12838. /**
  12839. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12840. * @hidden
  12841. */
  12842. export interface ExtendedGamepadButton extends GamepadButton {
  12843. /**
  12844. * If the button/trigger is currently pressed
  12845. */
  12846. readonly pressed: boolean;
  12847. /**
  12848. * If the button/trigger is currently touched
  12849. */
  12850. readonly touched: boolean;
  12851. /**
  12852. * Value of the button/trigger
  12853. */
  12854. readonly value: number;
  12855. }
  12856. /** @hidden */
  12857. export interface _GamePadFactory {
  12858. /**
  12859. * Returns wether or not the current gamepad can be created for this type of controller.
  12860. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12861. * @returns true if it can be created, otherwise false
  12862. */
  12863. canCreate(gamepadInfo: any): boolean;
  12864. /**
  12865. * Creates a new instance of the Gamepad.
  12866. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12867. * @returns the new gamepad instance
  12868. */
  12869. create(gamepadInfo: any): Gamepad;
  12870. }
  12871. /**
  12872. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12873. */
  12874. export class PoseEnabledControllerHelper {
  12875. /** @hidden */
  12876. static _ControllerFactories: _GamePadFactory[];
  12877. /** @hidden */
  12878. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12879. /**
  12880. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12881. * @param vrGamepad the gamepad to initialized
  12882. * @returns a vr controller of the type the gamepad identified as
  12883. */
  12884. static InitiateController(vrGamepad: any): Gamepad;
  12885. }
  12886. /**
  12887. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12888. */
  12889. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12890. private _deviceRoomPosition;
  12891. private _deviceRoomRotationQuaternion;
  12892. /**
  12893. * The device position in babylon space
  12894. */
  12895. devicePosition: Vector3;
  12896. /**
  12897. * The device rotation in babylon space
  12898. */
  12899. deviceRotationQuaternion: Quaternion;
  12900. /**
  12901. * The scale factor of the device in babylon space
  12902. */
  12903. deviceScaleFactor: number;
  12904. /**
  12905. * (Likely devicePosition should be used instead) The device position in its room space
  12906. */
  12907. position: Vector3;
  12908. /**
  12909. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12910. */
  12911. rotationQuaternion: Quaternion;
  12912. /**
  12913. * The type of controller (Eg. Windows mixed reality)
  12914. */
  12915. controllerType: PoseEnabledControllerType;
  12916. protected _calculatedPosition: Vector3;
  12917. private _calculatedRotation;
  12918. /**
  12919. * The raw pose from the device
  12920. */
  12921. rawPose: DevicePose;
  12922. private _trackPosition;
  12923. private _maxRotationDistFromHeadset;
  12924. private _draggedRoomRotation;
  12925. /**
  12926. * @hidden
  12927. */
  12928. _disableTrackPosition(fixedPosition: Vector3): void;
  12929. /**
  12930. * Internal, the mesh attached to the controller
  12931. * @hidden
  12932. */
  12933. _mesh: Nullable<AbstractMesh>;
  12934. private _poseControlledCamera;
  12935. private _leftHandSystemQuaternion;
  12936. /**
  12937. * Internal, matrix used to convert room space to babylon space
  12938. * @hidden
  12939. */
  12940. _deviceToWorld: Matrix;
  12941. /**
  12942. * Node to be used when casting a ray from the controller
  12943. * @hidden
  12944. */
  12945. _pointingPoseNode: Nullable<TransformNode>;
  12946. /**
  12947. * Name of the child mesh that can be used to cast a ray from the controller
  12948. */
  12949. static readonly POINTING_POSE: string;
  12950. /**
  12951. * Creates a new PoseEnabledController from a gamepad
  12952. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12953. */
  12954. constructor(browserGamepad: any);
  12955. private _workingMatrix;
  12956. /**
  12957. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12958. */
  12959. update(): void;
  12960. /**
  12961. * Updates only the pose device and mesh without doing any button event checking
  12962. */
  12963. protected _updatePoseAndMesh(): void;
  12964. /**
  12965. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12966. * @param poseData raw pose fromthe device
  12967. */
  12968. updateFromDevice(poseData: DevicePose): void;
  12969. /**
  12970. * @hidden
  12971. */
  12972. _meshAttachedObservable: Observable<AbstractMesh>;
  12973. /**
  12974. * Attaches a mesh to the controller
  12975. * @param mesh the mesh to be attached
  12976. */
  12977. attachToMesh(mesh: AbstractMesh): void;
  12978. /**
  12979. * Attaches the controllers mesh to a camera
  12980. * @param camera the camera the mesh should be attached to
  12981. */
  12982. attachToPoseControlledCamera(camera: TargetCamera): void;
  12983. /**
  12984. * Disposes of the controller
  12985. */
  12986. dispose(): void;
  12987. /**
  12988. * The mesh that is attached to the controller
  12989. */
  12990. readonly mesh: Nullable<AbstractMesh>;
  12991. /**
  12992. * Gets the ray of the controller in the direction the controller is pointing
  12993. * @param length the length the resulting ray should be
  12994. * @returns a ray in the direction the controller is pointing
  12995. */
  12996. getForwardRay(length?: number): Ray;
  12997. }
  12998. }
  12999. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13000. import { Observable } from "babylonjs/Misc/observable";
  13001. import { Scene } from "babylonjs/scene";
  13002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13003. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13004. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13005. /**
  13006. * Defines the WebVRController object that represents controllers tracked in 3D space
  13007. */
  13008. export abstract class WebVRController extends PoseEnabledController {
  13009. /**
  13010. * Internal, the default controller model for the controller
  13011. */
  13012. protected _defaultModel: AbstractMesh;
  13013. /**
  13014. * Fired when the trigger state has changed
  13015. */
  13016. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13017. /**
  13018. * Fired when the main button state has changed
  13019. */
  13020. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13021. /**
  13022. * Fired when the secondary button state has changed
  13023. */
  13024. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13025. /**
  13026. * Fired when the pad state has changed
  13027. */
  13028. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13029. /**
  13030. * Fired when controllers stick values have changed
  13031. */
  13032. onPadValuesChangedObservable: Observable<StickValues>;
  13033. /**
  13034. * Array of button availible on the controller
  13035. */
  13036. protected _buttons: Array<MutableGamepadButton>;
  13037. private _onButtonStateChange;
  13038. /**
  13039. * Fired when a controller button's state has changed
  13040. * @param callback the callback containing the button that was modified
  13041. */
  13042. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13043. /**
  13044. * X and Y axis corrisponding to the controllers joystick
  13045. */
  13046. pad: StickValues;
  13047. /**
  13048. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13049. */
  13050. hand: string;
  13051. /**
  13052. * The default controller model for the controller
  13053. */
  13054. readonly defaultModel: AbstractMesh;
  13055. /**
  13056. * Creates a new WebVRController from a gamepad
  13057. * @param vrGamepad the gamepad that the WebVRController should be created from
  13058. */
  13059. constructor(vrGamepad: any);
  13060. /**
  13061. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13062. */
  13063. update(): void;
  13064. /**
  13065. * Function to be called when a button is modified
  13066. */
  13067. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13068. /**
  13069. * Loads a mesh and attaches it to the controller
  13070. * @param scene the scene the mesh should be added to
  13071. * @param meshLoaded callback for when the mesh has been loaded
  13072. */
  13073. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13074. private _setButtonValue;
  13075. private _changes;
  13076. private _checkChanges;
  13077. /**
  13078. * Disposes of th webVRCOntroller
  13079. */
  13080. dispose(): void;
  13081. }
  13082. }
  13083. declare module "babylonjs/Lights/hemisphericLight" {
  13084. import { Nullable } from "babylonjs/types";
  13085. import { Scene } from "babylonjs/scene";
  13086. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13087. import { Effect } from "babylonjs/Materials/effect";
  13088. import { Light } from "babylonjs/Lights/light";
  13089. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13090. /**
  13091. * The HemisphericLight simulates the ambient environment light,
  13092. * so the passed direction is the light reflection direction, not the incoming direction.
  13093. */
  13094. export class HemisphericLight extends Light {
  13095. /**
  13096. * The groundColor is the light in the opposite direction to the one specified during creation.
  13097. * 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.
  13098. */
  13099. groundColor: Color3;
  13100. /**
  13101. * The light reflection direction, not the incoming direction.
  13102. */
  13103. direction: Vector3;
  13104. /**
  13105. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13106. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13107. * The HemisphericLight can't cast shadows.
  13108. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13109. * @param name The friendly name of the light
  13110. * @param direction The direction of the light reflection
  13111. * @param scene The scene the light belongs to
  13112. */
  13113. constructor(name: string, direction: Vector3, scene: Scene);
  13114. protected _buildUniformLayout(): void;
  13115. /**
  13116. * Returns the string "HemisphericLight".
  13117. * @return The class name
  13118. */
  13119. getClassName(): string;
  13120. /**
  13121. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13122. * Returns the updated direction.
  13123. * @param target The target the direction should point to
  13124. * @return The computed direction
  13125. */
  13126. setDirectionToTarget(target: Vector3): Vector3;
  13127. /**
  13128. * Returns the shadow generator associated to the light.
  13129. * @returns Always null for hemispheric lights because it does not support shadows.
  13130. */
  13131. getShadowGenerator(): Nullable<IShadowGenerator>;
  13132. /**
  13133. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13134. * @param effect The effect to update
  13135. * @param lightIndex The index of the light in the effect to update
  13136. * @returns The hemispheric light
  13137. */
  13138. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13139. /**
  13140. * Computes the world matrix of the node
  13141. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13142. * @param useWasUpdatedFlag defines a reserved property
  13143. * @returns the world matrix
  13144. */
  13145. computeWorldMatrix(): Matrix;
  13146. /**
  13147. * Returns the integer 3.
  13148. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13149. */
  13150. getTypeID(): number;
  13151. /**
  13152. * Prepares the list of defines specific to the light type.
  13153. * @param defines the list of defines
  13154. * @param lightIndex defines the index of the light for the effect
  13155. */
  13156. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13157. }
  13158. }
  13159. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13160. /** @hidden */
  13161. export var vrMultiviewToSingleviewPixelShader: {
  13162. name: string;
  13163. shader: string;
  13164. };
  13165. }
  13166. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13168. import { Scene } from "babylonjs/scene";
  13169. /**
  13170. * Renders to multiple views with a single draw call
  13171. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13172. */
  13173. export class MultiviewRenderTarget extends RenderTargetTexture {
  13174. /**
  13175. * Creates a multiview render target
  13176. * @param scene scene used with the render target
  13177. * @param size the size of the render target (used for each view)
  13178. */
  13179. constructor(scene: Scene, size?: number | {
  13180. width: number;
  13181. height: number;
  13182. } | {
  13183. ratio: number;
  13184. });
  13185. /**
  13186. * @hidden
  13187. * @param faceIndex the face index, if its a cube texture
  13188. */
  13189. _bindFrameBuffer(faceIndex?: number): void;
  13190. /**
  13191. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13192. * @returns the view count
  13193. */
  13194. getViewCount(): number;
  13195. }
  13196. }
  13197. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13198. import { Camera } from "babylonjs/Cameras/camera";
  13199. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13200. import { Nullable } from "babylonjs/types";
  13201. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13202. import { Matrix } from "babylonjs/Maths/math";
  13203. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13204. module "babylonjs/Engines/engine" {
  13205. interface Engine {
  13206. /**
  13207. * Creates a new multiview render target
  13208. * @param width defines the width of the texture
  13209. * @param height defines the height of the texture
  13210. * @returns the created multiview texture
  13211. */
  13212. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13213. /**
  13214. * Binds a multiview framebuffer to be drawn to
  13215. * @param multiviewTexture texture to bind
  13216. */
  13217. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13218. }
  13219. }
  13220. module "babylonjs/Cameras/camera" {
  13221. interface Camera {
  13222. /**
  13223. * @hidden
  13224. * 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)
  13225. */
  13226. _useMultiviewToSingleView: boolean;
  13227. /**
  13228. * @hidden
  13229. * 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)
  13230. */
  13231. _multiviewTexture: Nullable<RenderTargetTexture>;
  13232. /**
  13233. * @hidden
  13234. * ensures the multiview texture of the camera exists and has the specified width/height
  13235. * @param width height to set on the multiview texture
  13236. * @param height width to set on the multiview texture
  13237. */
  13238. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13239. }
  13240. }
  13241. module "babylonjs/scene" {
  13242. interface Scene {
  13243. /** @hidden */
  13244. _transformMatrixR: Matrix;
  13245. /** @hidden */
  13246. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13247. /** @hidden */
  13248. _createMultiviewUbo(): void;
  13249. /** @hidden */
  13250. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13251. /** @hidden */
  13252. _renderMultiviewToSingleView(camera: Camera): void;
  13253. }
  13254. }
  13255. }
  13256. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13257. import { Camera } from "babylonjs/Cameras/camera";
  13258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13259. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13260. import "babylonjs/Engines/Extensions/engine.multiview";
  13261. /**
  13262. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13263. * This will not be used for webXR as it supports displaying texture arrays directly
  13264. */
  13265. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13266. /**
  13267. * Initializes a VRMultiviewToSingleview
  13268. * @param name name of the post process
  13269. * @param camera camera to be applied to
  13270. * @param scaleFactor scaling factor to the size of the output texture
  13271. */
  13272. constructor(name: string, camera: Camera, scaleFactor: number);
  13273. }
  13274. }
  13275. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13276. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13277. import { Nullable } from "babylonjs/types";
  13278. import { Observable } from "babylonjs/Misc/observable";
  13279. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13280. import { Scene } from "babylonjs/scene";
  13281. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13282. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13283. import { Node } from "babylonjs/node";
  13284. import { Ray } from "babylonjs/Culling/ray";
  13285. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13286. /**
  13287. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13288. * IMPORTANT!! The data is right-hand data.
  13289. * @export
  13290. * @interface DevicePose
  13291. */
  13292. export interface DevicePose {
  13293. /**
  13294. * The position of the device, values in array are [x,y,z].
  13295. */
  13296. readonly position: Nullable<Float32Array>;
  13297. /**
  13298. * The linearVelocity of the device, values in array are [x,y,z].
  13299. */
  13300. readonly linearVelocity: Nullable<Float32Array>;
  13301. /**
  13302. * The linearAcceleration of the device, values in array are [x,y,z].
  13303. */
  13304. readonly linearAcceleration: Nullable<Float32Array>;
  13305. /**
  13306. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13307. */
  13308. readonly orientation: Nullable<Float32Array>;
  13309. /**
  13310. * The angularVelocity of the device, values in array are [x,y,z].
  13311. */
  13312. readonly angularVelocity: Nullable<Float32Array>;
  13313. /**
  13314. * The angularAcceleration of the device, values in array are [x,y,z].
  13315. */
  13316. readonly angularAcceleration: Nullable<Float32Array>;
  13317. }
  13318. /**
  13319. * Interface representing a pose controlled object in Babylon.
  13320. * A pose controlled object has both regular pose values as well as pose values
  13321. * from an external device such as a VR head mounted display
  13322. */
  13323. export interface PoseControlled {
  13324. /**
  13325. * The position of the object in babylon space.
  13326. */
  13327. position: Vector3;
  13328. /**
  13329. * The rotation quaternion of the object in babylon space.
  13330. */
  13331. rotationQuaternion: Quaternion;
  13332. /**
  13333. * The position of the device in babylon space.
  13334. */
  13335. devicePosition?: Vector3;
  13336. /**
  13337. * The rotation quaternion of the device in babylon space.
  13338. */
  13339. deviceRotationQuaternion: Quaternion;
  13340. /**
  13341. * The raw pose coming from the device.
  13342. */
  13343. rawPose: Nullable<DevicePose>;
  13344. /**
  13345. * The scale of the device to be used when translating from device space to babylon space.
  13346. */
  13347. deviceScaleFactor: number;
  13348. /**
  13349. * Updates the poseControlled values based on the input device pose.
  13350. * @param poseData the pose data to update the object with
  13351. */
  13352. updateFromDevice(poseData: DevicePose): void;
  13353. }
  13354. /**
  13355. * Set of options to customize the webVRCamera
  13356. */
  13357. export interface WebVROptions {
  13358. /**
  13359. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13360. */
  13361. trackPosition?: boolean;
  13362. /**
  13363. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13364. */
  13365. positionScale?: number;
  13366. /**
  13367. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13368. */
  13369. displayName?: string;
  13370. /**
  13371. * Should the native controller meshes be initialized. (default: true)
  13372. */
  13373. controllerMeshes?: boolean;
  13374. /**
  13375. * Creating a default HemiLight only on controllers. (default: true)
  13376. */
  13377. defaultLightingOnControllers?: boolean;
  13378. /**
  13379. * If you don't want to use the default VR button of the helper. (default: false)
  13380. */
  13381. useCustomVRButton?: boolean;
  13382. /**
  13383. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13384. */
  13385. customVRButton?: HTMLButtonElement;
  13386. /**
  13387. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13388. */
  13389. rayLength?: number;
  13390. /**
  13391. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13392. */
  13393. defaultHeight?: number;
  13394. /**
  13395. * If multiview should be used if availible (default: false)
  13396. */
  13397. useMultiview?: boolean;
  13398. }
  13399. /**
  13400. * This represents a WebVR camera.
  13401. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13402. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13403. */
  13404. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13405. private webVROptions;
  13406. /**
  13407. * @hidden
  13408. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13409. */
  13410. _vrDevice: any;
  13411. /**
  13412. * The rawPose of the vrDevice.
  13413. */
  13414. rawPose: Nullable<DevicePose>;
  13415. private _onVREnabled;
  13416. private _specsVersion;
  13417. private _attached;
  13418. private _frameData;
  13419. protected _descendants: Array<Node>;
  13420. private _deviceRoomPosition;
  13421. /** @hidden */
  13422. _deviceRoomRotationQuaternion: Quaternion;
  13423. private _standingMatrix;
  13424. /**
  13425. * Represents device position in babylon space.
  13426. */
  13427. devicePosition: Vector3;
  13428. /**
  13429. * Represents device rotation in babylon space.
  13430. */
  13431. deviceRotationQuaternion: Quaternion;
  13432. /**
  13433. * The scale of the device to be used when translating from device space to babylon space.
  13434. */
  13435. deviceScaleFactor: number;
  13436. private _deviceToWorld;
  13437. private _worldToDevice;
  13438. /**
  13439. * References to the webVR controllers for the vrDevice.
  13440. */
  13441. controllers: Array<WebVRController>;
  13442. /**
  13443. * Emits an event when a controller is attached.
  13444. */
  13445. onControllersAttachedObservable: Observable<WebVRController[]>;
  13446. /**
  13447. * Emits an event when a controller's mesh has been loaded;
  13448. */
  13449. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13450. /**
  13451. * Emits an event when the HMD's pose has been updated.
  13452. */
  13453. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13454. private _poseSet;
  13455. /**
  13456. * If the rig cameras be used as parent instead of this camera.
  13457. */
  13458. rigParenting: boolean;
  13459. private _lightOnControllers;
  13460. private _defaultHeight?;
  13461. /**
  13462. * Instantiates a WebVRFreeCamera.
  13463. * @param name The name of the WebVRFreeCamera
  13464. * @param position The starting anchor position for the camera
  13465. * @param scene The scene the camera belongs to
  13466. * @param webVROptions a set of customizable options for the webVRCamera
  13467. */
  13468. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13469. /**
  13470. * Gets the device distance from the ground in meters.
  13471. * @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.
  13472. */
  13473. deviceDistanceToRoomGround(): number;
  13474. /**
  13475. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13476. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13477. */
  13478. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13479. /**
  13480. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13481. * @returns A promise with a boolean set to if the standing matrix is supported.
  13482. */
  13483. useStandingMatrixAsync(): Promise<boolean>;
  13484. /**
  13485. * Disposes the camera
  13486. */
  13487. dispose(): void;
  13488. /**
  13489. * Gets a vrController by name.
  13490. * @param name The name of the controller to retreive
  13491. * @returns the controller matching the name specified or null if not found
  13492. */
  13493. getControllerByName(name: string): Nullable<WebVRController>;
  13494. private _leftController;
  13495. /**
  13496. * The controller corrisponding to the users left hand.
  13497. */
  13498. readonly leftController: Nullable<WebVRController>;
  13499. private _rightController;
  13500. /**
  13501. * The controller corrisponding to the users right hand.
  13502. */
  13503. readonly rightController: Nullable<WebVRController>;
  13504. /**
  13505. * Casts a ray forward from the vrCamera's gaze.
  13506. * @param length Length of the ray (default: 100)
  13507. * @returns the ray corrisponding to the gaze
  13508. */
  13509. getForwardRay(length?: number): Ray;
  13510. /**
  13511. * @hidden
  13512. * Updates the camera based on device's frame data
  13513. */
  13514. _checkInputs(): void;
  13515. /**
  13516. * Updates the poseControlled values based on the input device pose.
  13517. * @param poseData Pose coming from the device
  13518. */
  13519. updateFromDevice(poseData: DevicePose): void;
  13520. private _htmlElementAttached;
  13521. private _detachIfAttached;
  13522. /**
  13523. * WebVR's attach control will start broadcasting frames to the device.
  13524. * Note that in certain browsers (chrome for example) this function must be called
  13525. * within a user-interaction callback. Example:
  13526. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13527. *
  13528. * @param element html element to attach the vrDevice to
  13529. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13530. */
  13531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13532. /**
  13533. * Detaches the camera from the html element and disables VR
  13534. *
  13535. * @param element html element to detach from
  13536. */
  13537. detachControl(element: HTMLElement): void;
  13538. /**
  13539. * @returns the name of this class
  13540. */
  13541. getClassName(): string;
  13542. /**
  13543. * Calls resetPose on the vrDisplay
  13544. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13545. */
  13546. resetToCurrentRotation(): void;
  13547. /**
  13548. * @hidden
  13549. * Updates the rig cameras (left and right eye)
  13550. */
  13551. _updateRigCameras(): void;
  13552. private _workingVector;
  13553. private _oneVector;
  13554. private _workingMatrix;
  13555. private updateCacheCalled;
  13556. private _correctPositionIfNotTrackPosition;
  13557. /**
  13558. * @hidden
  13559. * Updates the cached values of the camera
  13560. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13561. */
  13562. _updateCache(ignoreParentClass?: boolean): void;
  13563. /**
  13564. * @hidden
  13565. * Get current device position in babylon world
  13566. */
  13567. _computeDevicePosition(): void;
  13568. /**
  13569. * Updates the current device position and rotation in the babylon world
  13570. */
  13571. update(): void;
  13572. /**
  13573. * @hidden
  13574. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13575. * @returns an identity matrix
  13576. */
  13577. _getViewMatrix(): Matrix;
  13578. private _tmpMatrix;
  13579. /**
  13580. * This function is called by the two RIG cameras.
  13581. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13582. * @hidden
  13583. */
  13584. _getWebVRViewMatrix(): Matrix;
  13585. /** @hidden */
  13586. _getWebVRProjectionMatrix(): Matrix;
  13587. private _onGamepadConnectedObserver;
  13588. private _onGamepadDisconnectedObserver;
  13589. private _updateCacheWhenTrackingDisabledObserver;
  13590. /**
  13591. * Initializes the controllers and their meshes
  13592. */
  13593. initControllers(): void;
  13594. }
  13595. }
  13596. declare module "babylonjs/PostProcesses/postProcess" {
  13597. import { Nullable } from "babylonjs/types";
  13598. import { SmartArray } from "babylonjs/Misc/smartArray";
  13599. import { Observable } from "babylonjs/Misc/observable";
  13600. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13601. import { Camera } from "babylonjs/Cameras/camera";
  13602. import { Effect } from "babylonjs/Materials/effect";
  13603. import "babylonjs/Shaders/postprocess.vertex";
  13604. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13606. import { Engine } from "babylonjs/Engines/engine";
  13607. /**
  13608. * Size options for a post process
  13609. */
  13610. export type PostProcessOptions = {
  13611. width: number;
  13612. height: number;
  13613. };
  13614. /**
  13615. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13616. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13617. */
  13618. export class PostProcess {
  13619. /** Name of the PostProcess. */
  13620. name: string;
  13621. /**
  13622. * Gets or sets the unique id of the post process
  13623. */
  13624. uniqueId: number;
  13625. /**
  13626. * Width of the texture to apply the post process on
  13627. */
  13628. width: number;
  13629. /**
  13630. * Height of the texture to apply the post process on
  13631. */
  13632. height: number;
  13633. /**
  13634. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13635. * @hidden
  13636. */
  13637. _outputTexture: Nullable<InternalTexture>;
  13638. /**
  13639. * Sampling mode used by the shader
  13640. * See https://doc.babylonjs.com/classes/3.1/texture
  13641. */
  13642. renderTargetSamplingMode: number;
  13643. /**
  13644. * Clear color to use when screen clearing
  13645. */
  13646. clearColor: Color4;
  13647. /**
  13648. * If the buffer needs to be cleared before applying the post process. (default: true)
  13649. * Should be set to false if shader will overwrite all previous pixels.
  13650. */
  13651. autoClear: boolean;
  13652. /**
  13653. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13654. */
  13655. alphaMode: number;
  13656. /**
  13657. * Sets the setAlphaBlendConstants of the babylon engine
  13658. */
  13659. alphaConstants: Color4;
  13660. /**
  13661. * Animations to be used for the post processing
  13662. */
  13663. animations: import("babylonjs/Animations/animation").Animation[];
  13664. /**
  13665. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13666. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13667. */
  13668. enablePixelPerfectMode: boolean;
  13669. /**
  13670. * Force the postprocess to be applied without taking in account viewport
  13671. */
  13672. forceFullscreenViewport: boolean;
  13673. /**
  13674. * List of inspectable custom properties (used by the Inspector)
  13675. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13676. */
  13677. inspectableCustomProperties: IInspectable[];
  13678. /**
  13679. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13680. *
  13681. * | Value | Type | Description |
  13682. * | ----- | ----------------------------------- | ----------- |
  13683. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13684. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13685. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13686. *
  13687. */
  13688. scaleMode: number;
  13689. /**
  13690. * Force textures to be a power of two (default: false)
  13691. */
  13692. alwaysForcePOT: boolean;
  13693. private _samples;
  13694. /**
  13695. * Number of sample textures (default: 1)
  13696. */
  13697. samples: number;
  13698. /**
  13699. * Modify the scale of the post process to be the same as the viewport (default: false)
  13700. */
  13701. adaptScaleToCurrentViewport: boolean;
  13702. private _camera;
  13703. private _scene;
  13704. private _engine;
  13705. private _options;
  13706. private _reusable;
  13707. private _textureType;
  13708. /**
  13709. * Smart array of input and output textures for the post process.
  13710. * @hidden
  13711. */
  13712. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13713. /**
  13714. * The index in _textures that corresponds to the output texture.
  13715. * @hidden
  13716. */
  13717. _currentRenderTextureInd: number;
  13718. private _effect;
  13719. private _samplers;
  13720. private _fragmentUrl;
  13721. private _vertexUrl;
  13722. private _parameters;
  13723. private _scaleRatio;
  13724. protected _indexParameters: any;
  13725. private _shareOutputWithPostProcess;
  13726. private _texelSize;
  13727. private _forcedOutputTexture;
  13728. /**
  13729. * Returns the fragment url or shader name used in the post process.
  13730. * @returns the fragment url or name in the shader store.
  13731. */
  13732. getEffectName(): string;
  13733. /**
  13734. * An event triggered when the postprocess is activated.
  13735. */
  13736. onActivateObservable: Observable<Camera>;
  13737. private _onActivateObserver;
  13738. /**
  13739. * A function that is added to the onActivateObservable
  13740. */
  13741. onActivate: Nullable<(camera: Camera) => void>;
  13742. /**
  13743. * An event triggered when the postprocess changes its size.
  13744. */
  13745. onSizeChangedObservable: Observable<PostProcess>;
  13746. private _onSizeChangedObserver;
  13747. /**
  13748. * A function that is added to the onSizeChangedObservable
  13749. */
  13750. onSizeChanged: (postProcess: PostProcess) => void;
  13751. /**
  13752. * An event triggered when the postprocess applies its effect.
  13753. */
  13754. onApplyObservable: Observable<Effect>;
  13755. private _onApplyObserver;
  13756. /**
  13757. * A function that is added to the onApplyObservable
  13758. */
  13759. onApply: (effect: Effect) => void;
  13760. /**
  13761. * An event triggered before rendering the postprocess
  13762. */
  13763. onBeforeRenderObservable: Observable<Effect>;
  13764. private _onBeforeRenderObserver;
  13765. /**
  13766. * A function that is added to the onBeforeRenderObservable
  13767. */
  13768. onBeforeRender: (effect: Effect) => void;
  13769. /**
  13770. * An event triggered after rendering the postprocess
  13771. */
  13772. onAfterRenderObservable: Observable<Effect>;
  13773. private _onAfterRenderObserver;
  13774. /**
  13775. * A function that is added to the onAfterRenderObservable
  13776. */
  13777. onAfterRender: (efect: Effect) => void;
  13778. /**
  13779. * 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
  13780. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13781. */
  13782. inputTexture: InternalTexture;
  13783. /**
  13784. * Gets the camera which post process is applied to.
  13785. * @returns The camera the post process is applied to.
  13786. */
  13787. getCamera(): Camera;
  13788. /**
  13789. * Gets the texel size of the postprocess.
  13790. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13791. */
  13792. readonly texelSize: Vector2;
  13793. /**
  13794. * Creates a new instance PostProcess
  13795. * @param name The name of the PostProcess.
  13796. * @param fragmentUrl The url of the fragment shader to be used.
  13797. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13798. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13799. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13800. * @param camera The camera to apply the render pass to.
  13801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13802. * @param engine The engine which the post process will be applied. (default: current engine)
  13803. * @param reusable If the post process can be reused on the same frame. (default: false)
  13804. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13805. * @param textureType Type of textures used when performing the post process. (default: 0)
  13806. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13807. * @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
  13808. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13809. */
  13810. constructor(
  13811. /** Name of the PostProcess. */
  13812. 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);
  13813. /**
  13814. * Gets a string idenfifying the name of the class
  13815. * @returns "PostProcess" string
  13816. */
  13817. getClassName(): string;
  13818. /**
  13819. * Gets the engine which this post process belongs to.
  13820. * @returns The engine the post process was enabled with.
  13821. */
  13822. getEngine(): Engine;
  13823. /**
  13824. * The effect that is created when initializing the post process.
  13825. * @returns The created effect corrisponding the the postprocess.
  13826. */
  13827. getEffect(): Effect;
  13828. /**
  13829. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13830. * @param postProcess The post process to share the output with.
  13831. * @returns This post process.
  13832. */
  13833. shareOutputWith(postProcess: PostProcess): PostProcess;
  13834. /**
  13835. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13836. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13837. */
  13838. useOwnOutput(): void;
  13839. /**
  13840. * Updates the effect with the current post process compile time values and recompiles the shader.
  13841. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13842. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13843. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13844. * @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
  13845. * @param onCompiled Called when the shader has been compiled.
  13846. * @param onError Called if there is an error when compiling a shader.
  13847. */
  13848. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13849. /**
  13850. * The post process is reusable if it can be used multiple times within one frame.
  13851. * @returns If the post process is reusable
  13852. */
  13853. isReusable(): boolean;
  13854. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13855. markTextureDirty(): void;
  13856. /**
  13857. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13858. * 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.
  13859. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13860. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13861. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13862. * @returns The target texture that was bound to be written to.
  13863. */
  13864. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13865. /**
  13866. * If the post process is supported.
  13867. */
  13868. readonly isSupported: boolean;
  13869. /**
  13870. * The aspect ratio of the output texture.
  13871. */
  13872. readonly aspectRatio: number;
  13873. /**
  13874. * Get a value indicating if the post-process is ready to be used
  13875. * @returns true if the post-process is ready (shader is compiled)
  13876. */
  13877. isReady(): boolean;
  13878. /**
  13879. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13880. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13881. */
  13882. apply(): Nullable<Effect>;
  13883. private _disposeTextures;
  13884. /**
  13885. * Disposes the post process.
  13886. * @param camera The camera to dispose the post process on.
  13887. */
  13888. dispose(camera?: Camera): void;
  13889. }
  13890. }
  13891. declare module "babylonjs/PostProcesses/postProcessManager" {
  13892. import { Nullable } from "babylonjs/types";
  13893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13895. import { Scene } from "babylonjs/scene";
  13896. /**
  13897. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13898. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13899. */
  13900. export class PostProcessManager {
  13901. private _scene;
  13902. private _indexBuffer;
  13903. private _vertexBuffers;
  13904. /**
  13905. * Creates a new instance PostProcess
  13906. * @param scene The scene that the post process is associated with.
  13907. */
  13908. constructor(scene: Scene);
  13909. private _prepareBuffers;
  13910. private _buildIndexBuffer;
  13911. /**
  13912. * Rebuilds the vertex buffers of the manager.
  13913. * @hidden
  13914. */
  13915. _rebuild(): void;
  13916. /**
  13917. * Prepares a frame to be run through a post process.
  13918. * @param sourceTexture The input texture to the post procesess. (default: null)
  13919. * @param postProcesses An array of post processes to be run. (default: null)
  13920. * @returns True if the post processes were able to be run.
  13921. * @hidden
  13922. */
  13923. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13924. /**
  13925. * Manually render a set of post processes to a texture.
  13926. * @param postProcesses An array of post processes to be run.
  13927. * @param targetTexture The target texture to render to.
  13928. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13929. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13930. * @param lodLevel defines which lod of the texture to render to
  13931. */
  13932. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13933. /**
  13934. * Finalize the result of the output of the postprocesses.
  13935. * @param doNotPresent If true the result will not be displayed to the screen.
  13936. * @param targetTexture The target texture to render to.
  13937. * @param faceIndex The index of the face to bind the target texture to.
  13938. * @param postProcesses The array of post processes to render.
  13939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13940. * @hidden
  13941. */
  13942. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13943. /**
  13944. * Disposes of the post process manager.
  13945. */
  13946. dispose(): void;
  13947. }
  13948. }
  13949. declare module "babylonjs/Layers/layerSceneComponent" {
  13950. import { Scene } from "babylonjs/scene";
  13951. import { ISceneComponent } from "babylonjs/sceneComponent";
  13952. import { Layer } from "babylonjs/Layers/layer";
  13953. module "babylonjs/abstractScene" {
  13954. interface AbstractScene {
  13955. /**
  13956. * The list of layers (background and foreground) of the scene
  13957. */
  13958. layers: Array<Layer>;
  13959. }
  13960. }
  13961. /**
  13962. * Defines the layer scene component responsible to manage any layers
  13963. * in a given scene.
  13964. */
  13965. export class LayerSceneComponent implements ISceneComponent {
  13966. /**
  13967. * The component name helpfull to identify the component in the list of scene components.
  13968. */
  13969. readonly name: string;
  13970. /**
  13971. * The scene the component belongs to.
  13972. */
  13973. scene: Scene;
  13974. private _engine;
  13975. /**
  13976. * Creates a new instance of the component for the given scene
  13977. * @param scene Defines the scene to register the component in
  13978. */
  13979. constructor(scene: Scene);
  13980. /**
  13981. * Registers the component in a given scene
  13982. */
  13983. register(): void;
  13984. /**
  13985. * Rebuilds the elements related to this component in case of
  13986. * context lost for instance.
  13987. */
  13988. rebuild(): void;
  13989. /**
  13990. * Disposes the component and the associated ressources.
  13991. */
  13992. dispose(): void;
  13993. private _draw;
  13994. private _drawCameraPredicate;
  13995. private _drawCameraBackground;
  13996. private _drawCameraForeground;
  13997. private _drawRenderTargetPredicate;
  13998. private _drawRenderTargetBackground;
  13999. private _drawRenderTargetForeground;
  14000. }
  14001. }
  14002. declare module "babylonjs/Shaders/layer.fragment" {
  14003. /** @hidden */
  14004. export var layerPixelShader: {
  14005. name: string;
  14006. shader: string;
  14007. };
  14008. }
  14009. declare module "babylonjs/Shaders/layer.vertex" {
  14010. /** @hidden */
  14011. export var layerVertexShader: {
  14012. name: string;
  14013. shader: string;
  14014. };
  14015. }
  14016. declare module "babylonjs/Layers/layer" {
  14017. import { Observable } from "babylonjs/Misc/observable";
  14018. import { Nullable } from "babylonjs/types";
  14019. import { Scene } from "babylonjs/scene";
  14020. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14021. import { Texture } from "babylonjs/Materials/Textures/texture";
  14022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14023. import "babylonjs/Shaders/layer.fragment";
  14024. import "babylonjs/Shaders/layer.vertex";
  14025. /**
  14026. * This represents a full screen 2d layer.
  14027. * This can be useful to display a picture in the background of your scene for instance.
  14028. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14029. */
  14030. export class Layer {
  14031. /**
  14032. * Define the name of the layer.
  14033. */
  14034. name: string;
  14035. /**
  14036. * Define the texture the layer should display.
  14037. */
  14038. texture: Nullable<Texture>;
  14039. /**
  14040. * Is the layer in background or foreground.
  14041. */
  14042. isBackground: boolean;
  14043. /**
  14044. * Define the color of the layer (instead of texture).
  14045. */
  14046. color: Color4;
  14047. /**
  14048. * Define the scale of the layer in order to zoom in out of the texture.
  14049. */
  14050. scale: Vector2;
  14051. /**
  14052. * Define an offset for the layer in order to shift the texture.
  14053. */
  14054. offset: Vector2;
  14055. /**
  14056. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14057. */
  14058. alphaBlendingMode: number;
  14059. /**
  14060. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14061. * Alpha test will not mix with the background color in case of transparency.
  14062. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14063. */
  14064. alphaTest: boolean;
  14065. /**
  14066. * Define a mask to restrict the layer to only some of the scene cameras.
  14067. */
  14068. layerMask: number;
  14069. /**
  14070. * Define the list of render target the layer is visible into.
  14071. */
  14072. renderTargetTextures: RenderTargetTexture[];
  14073. /**
  14074. * Define if the layer is only used in renderTarget or if it also
  14075. * renders in the main frame buffer of the canvas.
  14076. */
  14077. renderOnlyInRenderTargetTextures: boolean;
  14078. private _scene;
  14079. private _vertexBuffers;
  14080. private _indexBuffer;
  14081. private _effect;
  14082. private _alphaTestEffect;
  14083. /**
  14084. * An event triggered when the layer is disposed.
  14085. */
  14086. onDisposeObservable: Observable<Layer>;
  14087. private _onDisposeObserver;
  14088. /**
  14089. * Back compatibility with callback before the onDisposeObservable existed.
  14090. * The set callback will be triggered when the layer has been disposed.
  14091. */
  14092. onDispose: () => void;
  14093. /**
  14094. * An event triggered before rendering the scene
  14095. */
  14096. onBeforeRenderObservable: Observable<Layer>;
  14097. private _onBeforeRenderObserver;
  14098. /**
  14099. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14100. * The set callback will be triggered just before rendering the layer.
  14101. */
  14102. onBeforeRender: () => void;
  14103. /**
  14104. * An event triggered after rendering the scene
  14105. */
  14106. onAfterRenderObservable: Observable<Layer>;
  14107. private _onAfterRenderObserver;
  14108. /**
  14109. * Back compatibility with callback before the onAfterRenderObservable existed.
  14110. * The set callback will be triggered just after rendering the layer.
  14111. */
  14112. onAfterRender: () => void;
  14113. /**
  14114. * Instantiates a new layer.
  14115. * This represents a full screen 2d layer.
  14116. * This can be useful to display a picture in the background of your scene for instance.
  14117. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14118. * @param name Define the name of the layer in the scene
  14119. * @param imgUrl Define the url of the texture to display in the layer
  14120. * @param scene Define the scene the layer belongs to
  14121. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14122. * @param color Defines a color for the layer
  14123. */
  14124. constructor(
  14125. /**
  14126. * Define the name of the layer.
  14127. */
  14128. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14129. private _createIndexBuffer;
  14130. /** @hidden */
  14131. _rebuild(): void;
  14132. /**
  14133. * Renders the layer in the scene.
  14134. */
  14135. render(): void;
  14136. /**
  14137. * Disposes and releases the associated ressources.
  14138. */
  14139. dispose(): void;
  14140. }
  14141. }
  14142. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14143. import { Scene } from "babylonjs/scene";
  14144. import { ISceneComponent } from "babylonjs/sceneComponent";
  14145. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14146. module "babylonjs/abstractScene" {
  14147. interface AbstractScene {
  14148. /**
  14149. * The list of procedural textures added to the scene
  14150. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14151. */
  14152. proceduralTextures: Array<ProceduralTexture>;
  14153. }
  14154. }
  14155. /**
  14156. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14157. * in a given scene.
  14158. */
  14159. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14160. /**
  14161. * The component name helpfull to identify the component in the list of scene components.
  14162. */
  14163. readonly name: string;
  14164. /**
  14165. * The scene the component belongs to.
  14166. */
  14167. scene: Scene;
  14168. /**
  14169. * Creates a new instance of the component for the given scene
  14170. * @param scene Defines the scene to register the component in
  14171. */
  14172. constructor(scene: Scene);
  14173. /**
  14174. * Registers the component in a given scene
  14175. */
  14176. register(): void;
  14177. /**
  14178. * Rebuilds the elements related to this component in case of
  14179. * context lost for instance.
  14180. */
  14181. rebuild(): void;
  14182. /**
  14183. * Disposes the component and the associated ressources.
  14184. */
  14185. dispose(): void;
  14186. private _beforeClear;
  14187. }
  14188. }
  14189. declare module "babylonjs/Shaders/procedural.vertex" {
  14190. /** @hidden */
  14191. export var proceduralVertexShader: {
  14192. name: string;
  14193. shader: string;
  14194. };
  14195. }
  14196. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14197. import { Observable } from "babylonjs/Misc/observable";
  14198. import { Nullable } from "babylonjs/types";
  14199. import { Scene } from "babylonjs/scene";
  14200. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14201. import { Effect } from "babylonjs/Materials/effect";
  14202. import { Texture } from "babylonjs/Materials/Textures/texture";
  14203. import "babylonjs/Shaders/procedural.vertex";
  14204. /**
  14205. * 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.
  14206. * This is the base class of any Procedural texture and contains most of the shareable code.
  14207. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14208. */
  14209. export class ProceduralTexture extends Texture {
  14210. isCube: boolean;
  14211. /**
  14212. * Define if the texture is enabled or not (disabled texture will not render)
  14213. */
  14214. isEnabled: boolean;
  14215. /**
  14216. * Define if the texture must be cleared before rendering (default is true)
  14217. */
  14218. autoClear: boolean;
  14219. /**
  14220. * Callback called when the texture is generated
  14221. */
  14222. onGenerated: () => void;
  14223. /**
  14224. * Event raised when the texture is generated
  14225. */
  14226. onGeneratedObservable: Observable<ProceduralTexture>;
  14227. /** @hidden */
  14228. _generateMipMaps: boolean;
  14229. /** @hidden **/
  14230. _effect: Effect;
  14231. /** @hidden */
  14232. _textures: {
  14233. [key: string]: Texture;
  14234. };
  14235. private _size;
  14236. private _currentRefreshId;
  14237. private _refreshRate;
  14238. private _vertexBuffers;
  14239. private _indexBuffer;
  14240. private _uniforms;
  14241. private _samplers;
  14242. private _fragment;
  14243. private _floats;
  14244. private _ints;
  14245. private _floatsArrays;
  14246. private _colors3;
  14247. private _colors4;
  14248. private _vectors2;
  14249. private _vectors3;
  14250. private _matrices;
  14251. private _fallbackTexture;
  14252. private _fallbackTextureUsed;
  14253. private _engine;
  14254. private _cachedDefines;
  14255. private _contentUpdateId;
  14256. private _contentData;
  14257. /**
  14258. * Instantiates a new procedural texture.
  14259. * 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.
  14260. * This is the base class of any Procedural texture and contains most of the shareable code.
  14261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14262. * @param name Define the name of the texture
  14263. * @param size Define the size of the texture to create
  14264. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14265. * @param scene Define the scene the texture belongs to
  14266. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14267. * @param generateMipMaps Define if the texture should creates mip maps or not
  14268. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14269. */
  14270. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14271. /**
  14272. * The effect that is created when initializing the post process.
  14273. * @returns The created effect corrisponding the the postprocess.
  14274. */
  14275. getEffect(): Effect;
  14276. /**
  14277. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14278. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14279. */
  14280. getContent(): Nullable<ArrayBufferView>;
  14281. private _createIndexBuffer;
  14282. /** @hidden */
  14283. _rebuild(): void;
  14284. /**
  14285. * Resets the texture in order to recreate its associated resources.
  14286. * This can be called in case of context loss
  14287. */
  14288. reset(): void;
  14289. protected _getDefines(): string;
  14290. /**
  14291. * Is the texture ready to be used ? (rendered at least once)
  14292. * @returns true if ready, otherwise, false.
  14293. */
  14294. isReady(): boolean;
  14295. /**
  14296. * Resets the refresh counter of the texture and start bak from scratch.
  14297. * Could be useful to regenerate the texture if it is setup to render only once.
  14298. */
  14299. resetRefreshCounter(): void;
  14300. /**
  14301. * Set the fragment shader to use in order to render the texture.
  14302. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14303. */
  14304. setFragment(fragment: any): void;
  14305. /**
  14306. * Define the refresh rate of the texture or the rendering frequency.
  14307. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14308. */
  14309. refreshRate: number;
  14310. /** @hidden */
  14311. _shouldRender(): boolean;
  14312. /**
  14313. * Get the size the texture is rendering at.
  14314. * @returns the size (texture is always squared)
  14315. */
  14316. getRenderSize(): number;
  14317. /**
  14318. * Resize the texture to new value.
  14319. * @param size Define the new size the texture should have
  14320. * @param generateMipMaps Define whether the new texture should create mip maps
  14321. */
  14322. resize(size: number, generateMipMaps: boolean): void;
  14323. private _checkUniform;
  14324. /**
  14325. * Set a texture in the shader program used to render.
  14326. * @param name Define the name of the uniform samplers as defined in the shader
  14327. * @param texture Define the texture to bind to this sampler
  14328. * @return the texture itself allowing "fluent" like uniform updates
  14329. */
  14330. setTexture(name: string, texture: Texture): ProceduralTexture;
  14331. /**
  14332. * Set a float in the shader.
  14333. * @param name Define the name of the uniform as defined in the shader
  14334. * @param value Define the value to give to the uniform
  14335. * @return the texture itself allowing "fluent" like uniform updates
  14336. */
  14337. setFloat(name: string, value: number): ProceduralTexture;
  14338. /**
  14339. * Set a int in the shader.
  14340. * @param name Define the name of the uniform as defined in the shader
  14341. * @param value Define the value to give to the uniform
  14342. * @return the texture itself allowing "fluent" like uniform updates
  14343. */
  14344. setInt(name: string, value: number): ProceduralTexture;
  14345. /**
  14346. * Set an array of floats in the shader.
  14347. * @param name Define the name of the uniform as defined in the shader
  14348. * @param value Define the value to give to the uniform
  14349. * @return the texture itself allowing "fluent" like uniform updates
  14350. */
  14351. setFloats(name: string, value: number[]): ProceduralTexture;
  14352. /**
  14353. * Set a vec3 in the shader from a Color3.
  14354. * @param name Define the name of the uniform as defined in the shader
  14355. * @param value Define the value to give to the uniform
  14356. * @return the texture itself allowing "fluent" like uniform updates
  14357. */
  14358. setColor3(name: string, value: Color3): ProceduralTexture;
  14359. /**
  14360. * Set a vec4 in the shader from a Color4.
  14361. * @param name Define the name of the uniform as defined in the shader
  14362. * @param value Define the value to give to the uniform
  14363. * @return the texture itself allowing "fluent" like uniform updates
  14364. */
  14365. setColor4(name: string, value: Color4): ProceduralTexture;
  14366. /**
  14367. * Set a vec2 in the shader from a Vector2.
  14368. * @param name Define the name of the uniform as defined in the shader
  14369. * @param value Define the value to give to the uniform
  14370. * @return the texture itself allowing "fluent" like uniform updates
  14371. */
  14372. setVector2(name: string, value: Vector2): ProceduralTexture;
  14373. /**
  14374. * Set a vec3 in the shader from a Vector3.
  14375. * @param name Define the name of the uniform as defined in the shader
  14376. * @param value Define the value to give to the uniform
  14377. * @return the texture itself allowing "fluent" like uniform updates
  14378. */
  14379. setVector3(name: string, value: Vector3): ProceduralTexture;
  14380. /**
  14381. * Set a mat4 in the shader from a MAtrix.
  14382. * @param name Define the name of the uniform as defined in the shader
  14383. * @param value Define the value to give to the uniform
  14384. * @return the texture itself allowing "fluent" like uniform updates
  14385. */
  14386. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14387. /**
  14388. * Render the texture to its associated render target.
  14389. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14390. */
  14391. render(useCameraPostProcess?: boolean): void;
  14392. /**
  14393. * Clone the texture.
  14394. * @returns the cloned texture
  14395. */
  14396. clone(): ProceduralTexture;
  14397. /**
  14398. * Dispose the texture and release its asoociated resources.
  14399. */
  14400. dispose(): void;
  14401. }
  14402. }
  14403. declare module "babylonjs/Particles/baseParticleSystem" {
  14404. import { Nullable } from "babylonjs/types";
  14405. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14407. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14408. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14409. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14410. import { Scene } from "babylonjs/scene";
  14411. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14412. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14413. import { Texture } from "babylonjs/Materials/Textures/texture";
  14414. import { Animation } from "babylonjs/Animations/animation";
  14415. /**
  14416. * This represents the base class for particle system in Babylon.
  14417. * 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.
  14418. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14419. * @example https://doc.babylonjs.com/babylon101/particles
  14420. */
  14421. export class BaseParticleSystem {
  14422. /**
  14423. * Source color is added to the destination color without alpha affecting the result
  14424. */
  14425. static BLENDMODE_ONEONE: number;
  14426. /**
  14427. * Blend current color and particle color using particle’s alpha
  14428. */
  14429. static BLENDMODE_STANDARD: number;
  14430. /**
  14431. * Add current color and particle color multiplied by particle’s alpha
  14432. */
  14433. static BLENDMODE_ADD: number;
  14434. /**
  14435. * Multiply current color with particle color
  14436. */
  14437. static BLENDMODE_MULTIPLY: number;
  14438. /**
  14439. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14440. */
  14441. static BLENDMODE_MULTIPLYADD: number;
  14442. /**
  14443. * List of animations used by the particle system.
  14444. */
  14445. animations: Animation[];
  14446. /**
  14447. * The id of the Particle system.
  14448. */
  14449. id: string;
  14450. /**
  14451. * The friendly name of the Particle system.
  14452. */
  14453. name: string;
  14454. /**
  14455. * The rendering group used by the Particle system to chose when to render.
  14456. */
  14457. renderingGroupId: number;
  14458. /**
  14459. * The emitter represents the Mesh or position we are attaching the particle system to.
  14460. */
  14461. emitter: Nullable<AbstractMesh | Vector3>;
  14462. /**
  14463. * The maximum number of particles to emit per frame
  14464. */
  14465. emitRate: number;
  14466. /**
  14467. * If you want to launch only a few particles at once, that can be done, as well.
  14468. */
  14469. manualEmitCount: number;
  14470. /**
  14471. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14472. */
  14473. updateSpeed: number;
  14474. /**
  14475. * The amount of time the particle system is running (depends of the overall update speed).
  14476. */
  14477. targetStopDuration: number;
  14478. /**
  14479. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14480. */
  14481. disposeOnStop: boolean;
  14482. /**
  14483. * Minimum power of emitting particles.
  14484. */
  14485. minEmitPower: number;
  14486. /**
  14487. * Maximum power of emitting particles.
  14488. */
  14489. maxEmitPower: number;
  14490. /**
  14491. * Minimum life time of emitting particles.
  14492. */
  14493. minLifeTime: number;
  14494. /**
  14495. * Maximum life time of emitting particles.
  14496. */
  14497. maxLifeTime: number;
  14498. /**
  14499. * Minimum Size of emitting particles.
  14500. */
  14501. minSize: number;
  14502. /**
  14503. * Maximum Size of emitting particles.
  14504. */
  14505. maxSize: number;
  14506. /**
  14507. * Minimum scale of emitting particles on X axis.
  14508. */
  14509. minScaleX: number;
  14510. /**
  14511. * Maximum scale of emitting particles on X axis.
  14512. */
  14513. maxScaleX: number;
  14514. /**
  14515. * Minimum scale of emitting particles on Y axis.
  14516. */
  14517. minScaleY: number;
  14518. /**
  14519. * Maximum scale of emitting particles on Y axis.
  14520. */
  14521. maxScaleY: number;
  14522. /**
  14523. * Gets or sets the minimal initial rotation in radians.
  14524. */
  14525. minInitialRotation: number;
  14526. /**
  14527. * Gets or sets the maximal initial rotation in radians.
  14528. */
  14529. maxInitialRotation: number;
  14530. /**
  14531. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14532. */
  14533. minAngularSpeed: number;
  14534. /**
  14535. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14536. */
  14537. maxAngularSpeed: number;
  14538. /**
  14539. * The texture used to render each particle. (this can be a spritesheet)
  14540. */
  14541. particleTexture: Nullable<Texture>;
  14542. /**
  14543. * The layer mask we are rendering the particles through.
  14544. */
  14545. layerMask: number;
  14546. /**
  14547. * This can help using your own shader to render the particle system.
  14548. * The according effect will be created
  14549. */
  14550. customShader: any;
  14551. /**
  14552. * By default particle system starts as soon as they are created. This prevents the
  14553. * automatic start to happen and let you decide when to start emitting particles.
  14554. */
  14555. preventAutoStart: boolean;
  14556. private _noiseTexture;
  14557. /**
  14558. * Gets or sets a texture used to add random noise to particle positions
  14559. */
  14560. noiseTexture: Nullable<ProceduralTexture>;
  14561. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14562. noiseStrength: Vector3;
  14563. /**
  14564. * Callback triggered when the particle animation is ending.
  14565. */
  14566. onAnimationEnd: Nullable<() => void>;
  14567. /**
  14568. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14569. */
  14570. blendMode: number;
  14571. /**
  14572. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14573. * to override the particles.
  14574. */
  14575. forceDepthWrite: boolean;
  14576. /** 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 */
  14577. preWarmCycles: number;
  14578. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14579. preWarmStepOffset: number;
  14580. /**
  14581. * 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)
  14582. */
  14583. spriteCellChangeSpeed: number;
  14584. /**
  14585. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14586. */
  14587. startSpriteCellID: number;
  14588. /**
  14589. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14590. */
  14591. endSpriteCellID: number;
  14592. /**
  14593. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14594. */
  14595. spriteCellWidth: number;
  14596. /**
  14597. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14598. */
  14599. spriteCellHeight: number;
  14600. /**
  14601. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14602. */
  14603. spriteRandomStartCell: boolean;
  14604. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14605. translationPivot: Vector2;
  14606. /** @hidden */
  14607. protected _isAnimationSheetEnabled: boolean;
  14608. /**
  14609. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14610. */
  14611. beginAnimationOnStart: boolean;
  14612. /**
  14613. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14614. */
  14615. beginAnimationFrom: number;
  14616. /**
  14617. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14618. */
  14619. beginAnimationTo: number;
  14620. /**
  14621. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14622. */
  14623. beginAnimationLoop: boolean;
  14624. /**
  14625. * Gets or sets a world offset applied to all particles
  14626. */
  14627. worldOffset: Vector3;
  14628. /**
  14629. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14630. */
  14631. isAnimationSheetEnabled: boolean;
  14632. /**
  14633. * Get hosting scene
  14634. * @returns the scene
  14635. */
  14636. getScene(): Scene;
  14637. /**
  14638. * You can use gravity if you want to give an orientation to your particles.
  14639. */
  14640. gravity: Vector3;
  14641. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14642. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14643. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14644. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14645. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14646. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14647. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14648. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14649. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14650. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14651. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14652. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14653. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14654. /**
  14655. * Defines the delay in milliseconds before starting the system (0 by default)
  14656. */
  14657. startDelay: number;
  14658. /**
  14659. * Gets the current list of drag gradients.
  14660. * You must use addDragGradient and removeDragGradient to udpate this list
  14661. * @returns the list of drag gradients
  14662. */
  14663. getDragGradients(): Nullable<Array<FactorGradient>>;
  14664. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14665. limitVelocityDamping: number;
  14666. /**
  14667. * Gets the current list of limit velocity gradients.
  14668. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14669. * @returns the list of limit velocity gradients
  14670. */
  14671. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14672. /**
  14673. * Gets the current list of color gradients.
  14674. * You must use addColorGradient and removeColorGradient to udpate this list
  14675. * @returns the list of color gradients
  14676. */
  14677. getColorGradients(): Nullable<Array<ColorGradient>>;
  14678. /**
  14679. * Gets the current list of size gradients.
  14680. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14681. * @returns the list of size gradients
  14682. */
  14683. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14684. /**
  14685. * Gets the current list of color remap gradients.
  14686. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14687. * @returns the list of color remap gradients
  14688. */
  14689. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14690. /**
  14691. * Gets the current list of alpha remap gradients.
  14692. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14693. * @returns the list of alpha remap gradients
  14694. */
  14695. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14696. /**
  14697. * Gets the current list of life time gradients.
  14698. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14699. * @returns the list of life time gradients
  14700. */
  14701. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14702. /**
  14703. * Gets the current list of angular speed gradients.
  14704. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14705. * @returns the list of angular speed gradients
  14706. */
  14707. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14708. /**
  14709. * Gets the current list of velocity gradients.
  14710. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14711. * @returns the list of velocity gradients
  14712. */
  14713. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14714. /**
  14715. * Gets the current list of start size gradients.
  14716. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14717. * @returns the list of start size gradients
  14718. */
  14719. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14720. /**
  14721. * Gets the current list of emit rate gradients.
  14722. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14723. * @returns the list of emit rate gradients
  14724. */
  14725. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14726. /**
  14727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14728. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14729. */
  14730. direction1: Vector3;
  14731. /**
  14732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14734. */
  14735. direction2: Vector3;
  14736. /**
  14737. * 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.
  14738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14739. */
  14740. minEmitBox: Vector3;
  14741. /**
  14742. * 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.
  14743. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14744. */
  14745. maxEmitBox: Vector3;
  14746. /**
  14747. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14748. */
  14749. color1: Color4;
  14750. /**
  14751. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14752. */
  14753. color2: Color4;
  14754. /**
  14755. * Color the particle will have at the end of its lifetime
  14756. */
  14757. colorDead: Color4;
  14758. /**
  14759. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14760. */
  14761. textureMask: Color4;
  14762. /**
  14763. * The particle emitter type defines the emitter used by the particle system.
  14764. * It can be for example box, sphere, or cone...
  14765. */
  14766. particleEmitterType: IParticleEmitterType;
  14767. /** @hidden */
  14768. _isSubEmitter: boolean;
  14769. /**
  14770. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14771. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14772. */
  14773. billboardMode: number;
  14774. protected _isBillboardBased: boolean;
  14775. /**
  14776. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14777. */
  14778. isBillboardBased: boolean;
  14779. /**
  14780. * The scene the particle system belongs to.
  14781. */
  14782. protected _scene: Scene;
  14783. /**
  14784. * Local cache of defines for image processing.
  14785. */
  14786. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14787. /**
  14788. * Default configuration related to image processing available in the standard Material.
  14789. */
  14790. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14791. /**
  14792. * Gets the image processing configuration used either in this material.
  14793. */
  14794. /**
  14795. * Sets the Default image processing configuration used either in the this material.
  14796. *
  14797. * If sets to null, the scene one is in use.
  14798. */
  14799. imageProcessingConfiguration: ImageProcessingConfiguration;
  14800. /**
  14801. * Attaches a new image processing configuration to the Standard Material.
  14802. * @param configuration
  14803. */
  14804. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14805. /** @hidden */
  14806. protected _reset(): void;
  14807. /** @hidden */
  14808. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14809. /**
  14810. * Instantiates a particle system.
  14811. * 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.
  14812. * @param name The name of the particle system
  14813. */
  14814. constructor(name: string);
  14815. /**
  14816. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14817. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14818. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14819. * @returns the emitter
  14820. */
  14821. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14822. /**
  14823. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14824. * @param radius The radius of the hemisphere to emit from
  14825. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14826. * @returns the emitter
  14827. */
  14828. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14829. /**
  14830. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14831. * @param radius The radius of the sphere to emit from
  14832. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14833. * @returns the emitter
  14834. */
  14835. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14836. /**
  14837. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14838. * @param radius The radius of the sphere to emit from
  14839. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14840. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14841. * @returns the emitter
  14842. */
  14843. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14844. /**
  14845. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14846. * @param radius The radius of the emission cylinder
  14847. * @param height The height of the emission cylinder
  14848. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14849. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14850. * @returns the emitter
  14851. */
  14852. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14853. /**
  14854. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14855. * @param radius The radius of the cylinder to emit from
  14856. * @param height The height of the emission cylinder
  14857. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14860. * @returns the emitter
  14861. */
  14862. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14863. /**
  14864. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14865. * @param radius The radius of the cone to emit from
  14866. * @param angle The base angle of the cone
  14867. * @returns the emitter
  14868. */
  14869. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14870. /**
  14871. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14872. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14873. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14874. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14875. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14876. * @returns the emitter
  14877. */
  14878. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14879. }
  14880. }
  14881. declare module "babylonjs/Particles/subEmitter" {
  14882. import { Scene } from "babylonjs/scene";
  14883. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14884. /**
  14885. * Type of sub emitter
  14886. */
  14887. export enum SubEmitterType {
  14888. /**
  14889. * Attached to the particle over it's lifetime
  14890. */
  14891. ATTACHED = 0,
  14892. /**
  14893. * Created when the particle dies
  14894. */
  14895. END = 1
  14896. }
  14897. /**
  14898. * Sub emitter class used to emit particles from an existing particle
  14899. */
  14900. export class SubEmitter {
  14901. /**
  14902. * the particle system to be used by the sub emitter
  14903. */
  14904. particleSystem: ParticleSystem;
  14905. /**
  14906. * Type of the submitter (Default: END)
  14907. */
  14908. type: SubEmitterType;
  14909. /**
  14910. * 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)
  14911. * Note: This only is supported when using an emitter of type Mesh
  14912. */
  14913. inheritDirection: boolean;
  14914. /**
  14915. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14916. */
  14917. inheritedVelocityAmount: number;
  14918. /**
  14919. * Creates a sub emitter
  14920. * @param particleSystem the particle system to be used by the sub emitter
  14921. */
  14922. constructor(
  14923. /**
  14924. * the particle system to be used by the sub emitter
  14925. */
  14926. particleSystem: ParticleSystem);
  14927. /**
  14928. * Clones the sub emitter
  14929. * @returns the cloned sub emitter
  14930. */
  14931. clone(): SubEmitter;
  14932. /**
  14933. * Serialize current object to a JSON object
  14934. * @returns the serialized object
  14935. */
  14936. serialize(): any;
  14937. /** @hidden */
  14938. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14939. /**
  14940. * Creates a new SubEmitter from a serialized JSON version
  14941. * @param serializationObject defines the JSON object to read from
  14942. * @param scene defines the hosting scene
  14943. * @param rootUrl defines the rootUrl for data loading
  14944. * @returns a new SubEmitter
  14945. */
  14946. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14947. /** Release associated resources */
  14948. dispose(): void;
  14949. }
  14950. }
  14951. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14952. /** @hidden */
  14953. export var clipPlaneFragmentDeclaration: {
  14954. name: string;
  14955. shader: string;
  14956. };
  14957. }
  14958. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14959. /** @hidden */
  14960. export var imageProcessingDeclaration: {
  14961. name: string;
  14962. shader: string;
  14963. };
  14964. }
  14965. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14966. /** @hidden */
  14967. export var imageProcessingFunctions: {
  14968. name: string;
  14969. shader: string;
  14970. };
  14971. }
  14972. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14973. /** @hidden */
  14974. export var clipPlaneFragment: {
  14975. name: string;
  14976. shader: string;
  14977. };
  14978. }
  14979. declare module "babylonjs/Shaders/particles.fragment" {
  14980. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14981. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14983. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14984. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14985. /** @hidden */
  14986. export var particlesPixelShader: {
  14987. name: string;
  14988. shader: string;
  14989. };
  14990. }
  14991. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14992. /** @hidden */
  14993. export var clipPlaneVertexDeclaration: {
  14994. name: string;
  14995. shader: string;
  14996. };
  14997. }
  14998. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14999. /** @hidden */
  15000. export var clipPlaneVertex: {
  15001. name: string;
  15002. shader: string;
  15003. };
  15004. }
  15005. declare module "babylonjs/Shaders/particles.vertex" {
  15006. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15007. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15008. /** @hidden */
  15009. export var particlesVertexShader: {
  15010. name: string;
  15011. shader: string;
  15012. };
  15013. }
  15014. declare module "babylonjs/Particles/particleSystem" {
  15015. import { Nullable } from "babylonjs/types";
  15016. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15017. import { Observable } from "babylonjs/Misc/observable";
  15018. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15019. import { Effect } from "babylonjs/Materials/effect";
  15020. import { Scene, IDisposable } from "babylonjs/scene";
  15021. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15022. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15023. import { Particle } from "babylonjs/Particles/particle";
  15024. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15025. import "babylonjs/Shaders/particles.fragment";
  15026. import "babylonjs/Shaders/particles.vertex";
  15027. /**
  15028. * This represents a particle system in Babylon.
  15029. * 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.
  15030. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15031. * @example https://doc.babylonjs.com/babylon101/particles
  15032. */
  15033. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15034. /**
  15035. * Billboard mode will only apply to Y axis
  15036. */
  15037. static readonly BILLBOARDMODE_Y: number;
  15038. /**
  15039. * Billboard mode will apply to all axes
  15040. */
  15041. static readonly BILLBOARDMODE_ALL: number;
  15042. /**
  15043. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15044. */
  15045. static readonly BILLBOARDMODE_STRETCHED: number;
  15046. /**
  15047. * This function can be defined to provide custom update for active particles.
  15048. * This function will be called instead of regular update (age, position, color, etc.).
  15049. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15050. */
  15051. updateFunction: (particles: Particle[]) => void;
  15052. private _emitterWorldMatrix;
  15053. /**
  15054. * This function can be defined to specify initial direction for every new particle.
  15055. * It by default use the emitterType defined function
  15056. */
  15057. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15058. /**
  15059. * This function can be defined to specify initial position for every new particle.
  15060. * It by default use the emitterType defined function
  15061. */
  15062. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15063. /**
  15064. * @hidden
  15065. */
  15066. _inheritedVelocityOffset: Vector3;
  15067. /**
  15068. * An event triggered when the system is disposed
  15069. */
  15070. onDisposeObservable: Observable<ParticleSystem>;
  15071. private _onDisposeObserver;
  15072. /**
  15073. * Sets a callback that will be triggered when the system is disposed
  15074. */
  15075. onDispose: () => void;
  15076. private _particles;
  15077. private _epsilon;
  15078. private _capacity;
  15079. private _stockParticles;
  15080. private _newPartsExcess;
  15081. private _vertexData;
  15082. private _vertexBuffer;
  15083. private _vertexBuffers;
  15084. private _spriteBuffer;
  15085. private _indexBuffer;
  15086. private _effect;
  15087. private _customEffect;
  15088. private _cachedDefines;
  15089. private _scaledColorStep;
  15090. private _colorDiff;
  15091. private _scaledDirection;
  15092. private _scaledGravity;
  15093. private _currentRenderId;
  15094. private _alive;
  15095. private _useInstancing;
  15096. private _started;
  15097. private _stopped;
  15098. private _actualFrame;
  15099. private _scaledUpdateSpeed;
  15100. private _vertexBufferSize;
  15101. /** @hidden */
  15102. _currentEmitRateGradient: Nullable<FactorGradient>;
  15103. /** @hidden */
  15104. _currentEmitRate1: number;
  15105. /** @hidden */
  15106. _currentEmitRate2: number;
  15107. /** @hidden */
  15108. _currentStartSizeGradient: Nullable<FactorGradient>;
  15109. /** @hidden */
  15110. _currentStartSize1: number;
  15111. /** @hidden */
  15112. _currentStartSize2: number;
  15113. private readonly _rawTextureWidth;
  15114. private _rampGradientsTexture;
  15115. private _useRampGradients;
  15116. /** Gets or sets a boolean indicating that ramp gradients must be used
  15117. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15118. */
  15119. useRampGradients: boolean;
  15120. /**
  15121. * 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.
  15122. * 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: [])
  15123. */
  15124. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15125. private _subEmitters;
  15126. /**
  15127. * @hidden
  15128. * If the particle systems emitter should be disposed when the particle system is disposed
  15129. */
  15130. _disposeEmitterOnDispose: boolean;
  15131. /**
  15132. * The current active Sub-systems, this property is used by the root particle system only.
  15133. */
  15134. activeSubSystems: Array<ParticleSystem>;
  15135. private _rootParticleSystem;
  15136. /**
  15137. * Gets the current list of active particles
  15138. */
  15139. readonly particles: Particle[];
  15140. /**
  15141. * Returns the string "ParticleSystem"
  15142. * @returns a string containing the class name
  15143. */
  15144. getClassName(): string;
  15145. /**
  15146. * Instantiates a particle system.
  15147. * 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.
  15148. * @param name The name of the particle system
  15149. * @param capacity The max number of particles alive at the same time
  15150. * @param scene The scene the particle system belongs to
  15151. * @param customEffect a custom effect used to change the way particles are rendered by default
  15152. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15153. * @param epsilon Offset used to render the particles
  15154. */
  15155. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15156. private _addFactorGradient;
  15157. private _removeFactorGradient;
  15158. /**
  15159. * Adds a new life time gradient
  15160. * @param gradient defines the gradient to use (between 0 and 1)
  15161. * @param factor defines the life time factor to affect to the specified gradient
  15162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15163. * @returns the current particle system
  15164. */
  15165. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15166. /**
  15167. * Remove a specific life time gradient
  15168. * @param gradient defines the gradient to remove
  15169. * @returns the current particle system
  15170. */
  15171. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15172. /**
  15173. * Adds a new size gradient
  15174. * @param gradient defines the gradient to use (between 0 and 1)
  15175. * @param factor defines the size factor to affect to the specified gradient
  15176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15177. * @returns the current particle system
  15178. */
  15179. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15180. /**
  15181. * Remove a specific size gradient
  15182. * @param gradient defines the gradient to remove
  15183. * @returns the current particle system
  15184. */
  15185. removeSizeGradient(gradient: number): IParticleSystem;
  15186. /**
  15187. * Adds a new color remap gradient
  15188. * @param gradient defines the gradient to use (between 0 and 1)
  15189. * @param min defines the color remap minimal range
  15190. * @param max defines the color remap maximal range
  15191. * @returns the current particle system
  15192. */
  15193. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15194. /**
  15195. * Remove a specific color remap gradient
  15196. * @param gradient defines the gradient to remove
  15197. * @returns the current particle system
  15198. */
  15199. removeColorRemapGradient(gradient: number): IParticleSystem;
  15200. /**
  15201. * Adds a new alpha remap gradient
  15202. * @param gradient defines the gradient to use (between 0 and 1)
  15203. * @param min defines the alpha remap minimal range
  15204. * @param max defines the alpha remap maximal range
  15205. * @returns the current particle system
  15206. */
  15207. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15208. /**
  15209. * Remove a specific alpha remap gradient
  15210. * @param gradient defines the gradient to remove
  15211. * @returns the current particle system
  15212. */
  15213. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15214. /**
  15215. * Adds a new angular speed gradient
  15216. * @param gradient defines the gradient to use (between 0 and 1)
  15217. * @param factor defines the angular speed to affect to the specified gradient
  15218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15219. * @returns the current particle system
  15220. */
  15221. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15222. /**
  15223. * Remove a specific angular speed gradient
  15224. * @param gradient defines the gradient to remove
  15225. * @returns the current particle system
  15226. */
  15227. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15228. /**
  15229. * Adds a new velocity gradient
  15230. * @param gradient defines the gradient to use (between 0 and 1)
  15231. * @param factor defines the velocity to affect to the specified gradient
  15232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15233. * @returns the current particle system
  15234. */
  15235. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15236. /**
  15237. * Remove a specific velocity gradient
  15238. * @param gradient defines the gradient to remove
  15239. * @returns the current particle system
  15240. */
  15241. removeVelocityGradient(gradient: number): IParticleSystem;
  15242. /**
  15243. * Adds a new limit velocity gradient
  15244. * @param gradient defines the gradient to use (between 0 and 1)
  15245. * @param factor defines the limit velocity value to affect to the specified gradient
  15246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15247. * @returns the current particle system
  15248. */
  15249. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15250. /**
  15251. * Remove a specific limit velocity gradient
  15252. * @param gradient defines the gradient to remove
  15253. * @returns the current particle system
  15254. */
  15255. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15256. /**
  15257. * Adds a new drag gradient
  15258. * @param gradient defines the gradient to use (between 0 and 1)
  15259. * @param factor defines the drag value to affect to the specified gradient
  15260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15261. * @returns the current particle system
  15262. */
  15263. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15264. /**
  15265. * Remove a specific drag gradient
  15266. * @param gradient defines the gradient to remove
  15267. * @returns the current particle system
  15268. */
  15269. removeDragGradient(gradient: number): IParticleSystem;
  15270. /**
  15271. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15272. * @param gradient defines the gradient to use (between 0 and 1)
  15273. * @param factor defines the emit rate value to affect to the specified gradient
  15274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15275. * @returns the current particle system
  15276. */
  15277. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15278. /**
  15279. * Remove a specific emit rate gradient
  15280. * @param gradient defines the gradient to remove
  15281. * @returns the current particle system
  15282. */
  15283. removeEmitRateGradient(gradient: number): IParticleSystem;
  15284. /**
  15285. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15286. * @param gradient defines the gradient to use (between 0 and 1)
  15287. * @param factor defines the start size value to affect to the specified gradient
  15288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15289. * @returns the current particle system
  15290. */
  15291. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15292. /**
  15293. * Remove a specific start size gradient
  15294. * @param gradient defines the gradient to remove
  15295. * @returns the current particle system
  15296. */
  15297. removeStartSizeGradient(gradient: number): IParticleSystem;
  15298. private _createRampGradientTexture;
  15299. /**
  15300. * Gets the current list of ramp gradients.
  15301. * You must use addRampGradient and removeRampGradient to udpate this list
  15302. * @returns the list of ramp gradients
  15303. */
  15304. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15305. /**
  15306. * Adds a new ramp gradient used to remap particle colors
  15307. * @param gradient defines the gradient to use (between 0 and 1)
  15308. * @param color defines the color to affect to the specified gradient
  15309. * @returns the current particle system
  15310. */
  15311. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15312. /**
  15313. * Remove a specific ramp gradient
  15314. * @param gradient defines the gradient to remove
  15315. * @returns the current particle system
  15316. */
  15317. removeRampGradient(gradient: number): ParticleSystem;
  15318. /**
  15319. * Adds a new color gradient
  15320. * @param gradient defines the gradient to use (between 0 and 1)
  15321. * @param color1 defines the color to affect to the specified gradient
  15322. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15323. * @returns this particle system
  15324. */
  15325. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15326. /**
  15327. * Remove a specific color gradient
  15328. * @param gradient defines the gradient to remove
  15329. * @returns this particle system
  15330. */
  15331. removeColorGradient(gradient: number): IParticleSystem;
  15332. private _fetchR;
  15333. protected _reset(): void;
  15334. private _resetEffect;
  15335. private _createVertexBuffers;
  15336. private _createIndexBuffer;
  15337. /**
  15338. * Gets the maximum number of particles active at the same time.
  15339. * @returns The max number of active particles.
  15340. */
  15341. getCapacity(): number;
  15342. /**
  15343. * Gets whether there are still active particles in the system.
  15344. * @returns True if it is alive, otherwise false.
  15345. */
  15346. isAlive(): boolean;
  15347. /**
  15348. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15349. * @returns True if it has been started, otherwise false.
  15350. */
  15351. isStarted(): boolean;
  15352. private _prepareSubEmitterInternalArray;
  15353. /**
  15354. * Starts the particle system and begins to emit
  15355. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15356. */
  15357. start(delay?: number): void;
  15358. /**
  15359. * Stops the particle system.
  15360. * @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.
  15361. */
  15362. stop(stopSubEmitters?: boolean): void;
  15363. /**
  15364. * Remove all active particles
  15365. */
  15366. reset(): void;
  15367. /**
  15368. * @hidden (for internal use only)
  15369. */
  15370. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15371. /**
  15372. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15373. * Its lifetime will start back at 0.
  15374. */
  15375. recycleParticle: (particle: Particle) => void;
  15376. private _stopSubEmitters;
  15377. private _createParticle;
  15378. private _removeFromRoot;
  15379. private _emitFromParticle;
  15380. private _update;
  15381. /** @hidden */
  15382. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15383. /** @hidden */
  15384. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15385. /** @hidden */
  15386. private _getEffect;
  15387. /**
  15388. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15389. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15390. */
  15391. animate(preWarmOnly?: boolean): void;
  15392. private _appendParticleVertices;
  15393. /**
  15394. * Rebuilds the particle system.
  15395. */
  15396. rebuild(): void;
  15397. /**
  15398. * Is this system ready to be used/rendered
  15399. * @return true if the system is ready
  15400. */
  15401. isReady(): boolean;
  15402. private _render;
  15403. /**
  15404. * Renders the particle system in its current state.
  15405. * @returns the current number of particles
  15406. */
  15407. render(): number;
  15408. /**
  15409. * Disposes the particle system and free the associated resources
  15410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15411. */
  15412. dispose(disposeTexture?: boolean): void;
  15413. /**
  15414. * Clones the particle system.
  15415. * @param name The name of the cloned object
  15416. * @param newEmitter The new emitter to use
  15417. * @returns the cloned particle system
  15418. */
  15419. clone(name: string, newEmitter: any): ParticleSystem;
  15420. /**
  15421. * Serializes the particle system to a JSON object.
  15422. * @returns the JSON object
  15423. */
  15424. serialize(): any;
  15425. /** @hidden */
  15426. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15427. /** @hidden */
  15428. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15429. /**
  15430. * Parses a JSON object to create a particle system.
  15431. * @param parsedParticleSystem The JSON object to parse
  15432. * @param scene The scene to create the particle system in
  15433. * @param rootUrl The root url to use to load external dependencies like texture
  15434. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15435. * @returns the Parsed particle system
  15436. */
  15437. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15438. }
  15439. }
  15440. declare module "babylonjs/Particles/particle" {
  15441. import { Nullable } from "babylonjs/types";
  15442. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15443. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15444. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15445. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15446. /**
  15447. * A particle represents one of the element emitted by a particle system.
  15448. * This is mainly define by its coordinates, direction, velocity and age.
  15449. */
  15450. export class Particle {
  15451. /**
  15452. * The particle system the particle belongs to.
  15453. */
  15454. particleSystem: ParticleSystem;
  15455. private static _Count;
  15456. /**
  15457. * Unique ID of the particle
  15458. */
  15459. id: number;
  15460. /**
  15461. * The world position of the particle in the scene.
  15462. */
  15463. position: Vector3;
  15464. /**
  15465. * The world direction of the particle in the scene.
  15466. */
  15467. direction: Vector3;
  15468. /**
  15469. * The color of the particle.
  15470. */
  15471. color: Color4;
  15472. /**
  15473. * The color change of the particle per step.
  15474. */
  15475. colorStep: Color4;
  15476. /**
  15477. * Defines how long will the life of the particle be.
  15478. */
  15479. lifeTime: number;
  15480. /**
  15481. * The current age of the particle.
  15482. */
  15483. age: number;
  15484. /**
  15485. * The current size of the particle.
  15486. */
  15487. size: number;
  15488. /**
  15489. * The current scale of the particle.
  15490. */
  15491. scale: Vector2;
  15492. /**
  15493. * The current angle of the particle.
  15494. */
  15495. angle: number;
  15496. /**
  15497. * Defines how fast is the angle changing.
  15498. */
  15499. angularSpeed: number;
  15500. /**
  15501. * Defines the cell index used by the particle to be rendered from a sprite.
  15502. */
  15503. cellIndex: number;
  15504. /**
  15505. * The information required to support color remapping
  15506. */
  15507. remapData: Vector4;
  15508. /** @hidden */
  15509. _randomCellOffset?: number;
  15510. /** @hidden */
  15511. _initialDirection: Nullable<Vector3>;
  15512. /** @hidden */
  15513. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15514. /** @hidden */
  15515. _initialStartSpriteCellID: number;
  15516. /** @hidden */
  15517. _initialEndSpriteCellID: number;
  15518. /** @hidden */
  15519. _currentColorGradient: Nullable<ColorGradient>;
  15520. /** @hidden */
  15521. _currentColor1: Color4;
  15522. /** @hidden */
  15523. _currentColor2: Color4;
  15524. /** @hidden */
  15525. _currentSizeGradient: Nullable<FactorGradient>;
  15526. /** @hidden */
  15527. _currentSize1: number;
  15528. /** @hidden */
  15529. _currentSize2: number;
  15530. /** @hidden */
  15531. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15532. /** @hidden */
  15533. _currentAngularSpeed1: number;
  15534. /** @hidden */
  15535. _currentAngularSpeed2: number;
  15536. /** @hidden */
  15537. _currentVelocityGradient: Nullable<FactorGradient>;
  15538. /** @hidden */
  15539. _currentVelocity1: number;
  15540. /** @hidden */
  15541. _currentVelocity2: number;
  15542. /** @hidden */
  15543. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15544. /** @hidden */
  15545. _currentLimitVelocity1: number;
  15546. /** @hidden */
  15547. _currentLimitVelocity2: number;
  15548. /** @hidden */
  15549. _currentDragGradient: Nullable<FactorGradient>;
  15550. /** @hidden */
  15551. _currentDrag1: number;
  15552. /** @hidden */
  15553. _currentDrag2: number;
  15554. /** @hidden */
  15555. _randomNoiseCoordinates1: Vector3;
  15556. /** @hidden */
  15557. _randomNoiseCoordinates2: Vector3;
  15558. /**
  15559. * Creates a new instance Particle
  15560. * @param particleSystem the particle system the particle belongs to
  15561. */
  15562. constructor(
  15563. /**
  15564. * The particle system the particle belongs to.
  15565. */
  15566. particleSystem: ParticleSystem);
  15567. private updateCellInfoFromSystem;
  15568. /**
  15569. * Defines how the sprite cell index is updated for the particle
  15570. */
  15571. updateCellIndex(): void;
  15572. /** @hidden */
  15573. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15574. /** @hidden */
  15575. _inheritParticleInfoToSubEmitters(): void;
  15576. /** @hidden */
  15577. _reset(): void;
  15578. /**
  15579. * Copy the properties of particle to another one.
  15580. * @param other the particle to copy the information to.
  15581. */
  15582. copyTo(other: Particle): void;
  15583. }
  15584. }
  15585. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15586. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15587. import { Effect } from "babylonjs/Materials/effect";
  15588. import { Particle } from "babylonjs/Particles/particle";
  15589. /**
  15590. * Particle emitter represents a volume emitting particles.
  15591. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15592. */
  15593. export interface IParticleEmitterType {
  15594. /**
  15595. * Called by the particle System when the direction is computed for the created particle.
  15596. * @param worldMatrix is the world matrix of the particle system
  15597. * @param directionToUpdate is the direction vector to update with the result
  15598. * @param particle is the particle we are computed the direction for
  15599. */
  15600. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15601. /**
  15602. * Called by the particle System when the position is computed for the created particle.
  15603. * @param worldMatrix is the world matrix of the particle system
  15604. * @param positionToUpdate is the position vector to update with the result
  15605. * @param particle is the particle we are computed the position for
  15606. */
  15607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15608. /**
  15609. * Clones the current emitter and returns a copy of it
  15610. * @returns the new emitter
  15611. */
  15612. clone(): IParticleEmitterType;
  15613. /**
  15614. * Called by the GPUParticleSystem to setup the update shader
  15615. * @param effect defines the update shader
  15616. */
  15617. applyToShader(effect: Effect): void;
  15618. /**
  15619. * Returns a string to use to update the GPU particles update shader
  15620. * @returns the effect defines string
  15621. */
  15622. getEffectDefines(): string;
  15623. /**
  15624. * Returns a string representing the class name
  15625. * @returns a string containing the class name
  15626. */
  15627. getClassName(): string;
  15628. /**
  15629. * Serializes the particle system to a JSON object.
  15630. * @returns the JSON object
  15631. */
  15632. serialize(): any;
  15633. /**
  15634. * Parse properties from a JSON object
  15635. * @param serializationObject defines the JSON object
  15636. */
  15637. parse(serializationObject: any): void;
  15638. }
  15639. }
  15640. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15641. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15642. import { Effect } from "babylonjs/Materials/effect";
  15643. import { Particle } from "babylonjs/Particles/particle";
  15644. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15645. /**
  15646. * Particle emitter emitting particles from the inside of a box.
  15647. * It emits the particles randomly between 2 given directions.
  15648. */
  15649. export class BoxParticleEmitter implements IParticleEmitterType {
  15650. /**
  15651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15652. */
  15653. direction1: Vector3;
  15654. /**
  15655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15656. */
  15657. direction2: Vector3;
  15658. /**
  15659. * 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.
  15660. */
  15661. minEmitBox: Vector3;
  15662. /**
  15663. * 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.
  15664. */
  15665. maxEmitBox: Vector3;
  15666. /**
  15667. * Creates a new instance BoxParticleEmitter
  15668. */
  15669. constructor();
  15670. /**
  15671. * Called by the particle System when the direction is computed for the created particle.
  15672. * @param worldMatrix is the world matrix of the particle system
  15673. * @param directionToUpdate is the direction vector to update with the result
  15674. * @param particle is the particle we are computed the direction for
  15675. */
  15676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15677. /**
  15678. * Called by the particle System when the position is computed for the created particle.
  15679. * @param worldMatrix is the world matrix of the particle system
  15680. * @param positionToUpdate is the position vector to update with the result
  15681. * @param particle is the particle we are computed the position for
  15682. */
  15683. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15684. /**
  15685. * Clones the current emitter and returns a copy of it
  15686. * @returns the new emitter
  15687. */
  15688. clone(): BoxParticleEmitter;
  15689. /**
  15690. * Called by the GPUParticleSystem to setup the update shader
  15691. * @param effect defines the update shader
  15692. */
  15693. applyToShader(effect: Effect): void;
  15694. /**
  15695. * Returns a string to use to update the GPU particles update shader
  15696. * @returns a string containng the defines string
  15697. */
  15698. getEffectDefines(): string;
  15699. /**
  15700. * Returns the string "BoxParticleEmitter"
  15701. * @returns a string containing the class name
  15702. */
  15703. getClassName(): string;
  15704. /**
  15705. * Serializes the particle system to a JSON object.
  15706. * @returns the JSON object
  15707. */
  15708. serialize(): any;
  15709. /**
  15710. * Parse properties from a JSON object
  15711. * @param serializationObject defines the JSON object
  15712. */
  15713. parse(serializationObject: any): void;
  15714. }
  15715. }
  15716. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15717. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15718. import { Effect } from "babylonjs/Materials/effect";
  15719. import { Particle } from "babylonjs/Particles/particle";
  15720. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15721. /**
  15722. * Particle emitter emitting particles from the inside of a cone.
  15723. * It emits the particles alongside the cone volume from the base to the particle.
  15724. * The emission direction might be randomized.
  15725. */
  15726. export class ConeParticleEmitter implements IParticleEmitterType {
  15727. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15728. directionRandomizer: number;
  15729. private _radius;
  15730. private _angle;
  15731. private _height;
  15732. /**
  15733. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15734. */
  15735. radiusRange: number;
  15736. /**
  15737. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15738. */
  15739. heightRange: number;
  15740. /**
  15741. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15742. */
  15743. emitFromSpawnPointOnly: boolean;
  15744. /**
  15745. * Gets or sets the radius of the emission cone
  15746. */
  15747. radius: number;
  15748. /**
  15749. * Gets or sets the angle of the emission cone
  15750. */
  15751. angle: number;
  15752. private _buildHeight;
  15753. /**
  15754. * Creates a new instance ConeParticleEmitter
  15755. * @param radius the radius of the emission cone (1 by default)
  15756. * @param angle the cone base angle (PI by default)
  15757. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15758. */
  15759. constructor(radius?: number, angle?: number,
  15760. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15761. directionRandomizer?: number);
  15762. /**
  15763. * Called by the particle System when the direction is computed for the created particle.
  15764. * @param worldMatrix is the world matrix of the particle system
  15765. * @param directionToUpdate is the direction vector to update with the result
  15766. * @param particle is the particle we are computed the direction for
  15767. */
  15768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15769. /**
  15770. * Called by the particle System when the position is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param positionToUpdate is the position vector to update with the result
  15773. * @param particle is the particle we are computed the position for
  15774. */
  15775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15776. /**
  15777. * Clones the current emitter and returns a copy of it
  15778. * @returns the new emitter
  15779. */
  15780. clone(): ConeParticleEmitter;
  15781. /**
  15782. * Called by the GPUParticleSystem to setup the update shader
  15783. * @param effect defines the update shader
  15784. */
  15785. applyToShader(effect: Effect): void;
  15786. /**
  15787. * Returns a string to use to update the GPU particles update shader
  15788. * @returns a string containng the defines string
  15789. */
  15790. getEffectDefines(): string;
  15791. /**
  15792. * Returns the string "ConeParticleEmitter"
  15793. * @returns a string containing the class name
  15794. */
  15795. getClassName(): string;
  15796. /**
  15797. * Serializes the particle system to a JSON object.
  15798. * @returns the JSON object
  15799. */
  15800. serialize(): any;
  15801. /**
  15802. * Parse properties from a JSON object
  15803. * @param serializationObject defines the JSON object
  15804. */
  15805. parse(serializationObject: any): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15809. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15810. import { Effect } from "babylonjs/Materials/effect";
  15811. import { Particle } from "babylonjs/Particles/particle";
  15812. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15813. /**
  15814. * Particle emitter emitting particles from the inside of a cylinder.
  15815. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15816. */
  15817. export class CylinderParticleEmitter implements IParticleEmitterType {
  15818. /**
  15819. * The radius of the emission cylinder.
  15820. */
  15821. radius: number;
  15822. /**
  15823. * The height of the emission cylinder.
  15824. */
  15825. height: number;
  15826. /**
  15827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15828. */
  15829. radiusRange: number;
  15830. /**
  15831. * How much to randomize the particle direction [0-1].
  15832. */
  15833. directionRandomizer: number;
  15834. /**
  15835. * Creates a new instance CylinderParticleEmitter
  15836. * @param radius the radius of the emission cylinder (1 by default)
  15837. * @param height the height of the emission cylinder (1 by default)
  15838. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15839. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15840. */
  15841. constructor(
  15842. /**
  15843. * The radius of the emission cylinder.
  15844. */
  15845. radius?: number,
  15846. /**
  15847. * The height of the emission cylinder.
  15848. */
  15849. height?: number,
  15850. /**
  15851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15852. */
  15853. radiusRange?: number,
  15854. /**
  15855. * How much to randomize the particle direction [0-1].
  15856. */
  15857. directionRandomizer?: number);
  15858. /**
  15859. * Called by the particle System when the direction is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param directionToUpdate is the direction vector to update with the result
  15862. * @param particle is the particle we are computed the direction for
  15863. */
  15864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15865. /**
  15866. * Called by the particle System when the position is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param positionToUpdate is the position vector to update with the result
  15869. * @param particle is the particle we are computed the position for
  15870. */
  15871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15872. /**
  15873. * Clones the current emitter and returns a copy of it
  15874. * @returns the new emitter
  15875. */
  15876. clone(): CylinderParticleEmitter;
  15877. /**
  15878. * Called by the GPUParticleSystem to setup the update shader
  15879. * @param effect defines the update shader
  15880. */
  15881. applyToShader(effect: Effect): void;
  15882. /**
  15883. * Returns a string to use to update the GPU particles update shader
  15884. * @returns a string containng the defines string
  15885. */
  15886. getEffectDefines(): string;
  15887. /**
  15888. * Returns the string "CylinderParticleEmitter"
  15889. * @returns a string containing the class name
  15890. */
  15891. getClassName(): string;
  15892. /**
  15893. * Serializes the particle system to a JSON object.
  15894. * @returns the JSON object
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Parse properties from a JSON object
  15899. * @param serializationObject defines the JSON object
  15900. */
  15901. parse(serializationObject: any): void;
  15902. }
  15903. /**
  15904. * Particle emitter emitting particles from the inside of a cylinder.
  15905. * It emits the particles randomly between two vectors.
  15906. */
  15907. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15908. /**
  15909. * The min limit of the emission direction.
  15910. */
  15911. direction1: Vector3;
  15912. /**
  15913. * The max limit of the emission direction.
  15914. */
  15915. direction2: Vector3;
  15916. /**
  15917. * Creates a new instance CylinderDirectedParticleEmitter
  15918. * @param radius the radius of the emission cylinder (1 by default)
  15919. * @param height the height of the emission cylinder (1 by default)
  15920. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15921. * @param direction1 the min limit of the emission direction (up vector by default)
  15922. * @param direction2 the max limit of the emission direction (up vector by default)
  15923. */
  15924. constructor(radius?: number, height?: number, radiusRange?: number,
  15925. /**
  15926. * The min limit of the emission direction.
  15927. */
  15928. direction1?: Vector3,
  15929. /**
  15930. * The max limit of the emission direction.
  15931. */
  15932. direction2?: Vector3);
  15933. /**
  15934. * Called by the particle System when the direction is computed for the created particle.
  15935. * @param worldMatrix is the world matrix of the particle system
  15936. * @param directionToUpdate is the direction vector to update with the result
  15937. * @param particle is the particle we are computed the direction for
  15938. */
  15939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15940. /**
  15941. * Clones the current emitter and returns a copy of it
  15942. * @returns the new emitter
  15943. */
  15944. clone(): CylinderDirectedParticleEmitter;
  15945. /**
  15946. * Called by the GPUParticleSystem to setup the update shader
  15947. * @param effect defines the update shader
  15948. */
  15949. applyToShader(effect: Effect): void;
  15950. /**
  15951. * Returns a string to use to update the GPU particles update shader
  15952. * @returns a string containng the defines string
  15953. */
  15954. getEffectDefines(): string;
  15955. /**
  15956. * Returns the string "CylinderDirectedParticleEmitter"
  15957. * @returns a string containing the class name
  15958. */
  15959. getClassName(): string;
  15960. /**
  15961. * Serializes the particle system to a JSON object.
  15962. * @returns the JSON object
  15963. */
  15964. serialize(): any;
  15965. /**
  15966. * Parse properties from a JSON object
  15967. * @param serializationObject defines the JSON object
  15968. */
  15969. parse(serializationObject: any): void;
  15970. }
  15971. }
  15972. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15973. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15974. import { Effect } from "babylonjs/Materials/effect";
  15975. import { Particle } from "babylonjs/Particles/particle";
  15976. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15977. /**
  15978. * Particle emitter emitting particles from the inside of a hemisphere.
  15979. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15980. */
  15981. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15982. /**
  15983. * The radius of the emission hemisphere.
  15984. */
  15985. radius: number;
  15986. /**
  15987. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15988. */
  15989. radiusRange: number;
  15990. /**
  15991. * How much to randomize the particle direction [0-1].
  15992. */
  15993. directionRandomizer: number;
  15994. /**
  15995. * Creates a new instance HemisphericParticleEmitter
  15996. * @param radius the radius of the emission hemisphere (1 by default)
  15997. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15998. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15999. */
  16000. constructor(
  16001. /**
  16002. * The radius of the emission hemisphere.
  16003. */
  16004. radius?: number,
  16005. /**
  16006. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16007. */
  16008. radiusRange?: number,
  16009. /**
  16010. * How much to randomize the particle direction [0-1].
  16011. */
  16012. directionRandomizer?: number);
  16013. /**
  16014. * Called by the particle System when the direction is computed for the created particle.
  16015. * @param worldMatrix is the world matrix of the particle system
  16016. * @param directionToUpdate is the direction vector to update with the result
  16017. * @param particle is the particle we are computed the direction for
  16018. */
  16019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16020. /**
  16021. * Called by the particle System when the position is computed for the created particle.
  16022. * @param worldMatrix is the world matrix of the particle system
  16023. * @param positionToUpdate is the position vector to update with the result
  16024. * @param particle is the particle we are computed the position for
  16025. */
  16026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16027. /**
  16028. * Clones the current emitter and returns a copy of it
  16029. * @returns the new emitter
  16030. */
  16031. clone(): HemisphericParticleEmitter;
  16032. /**
  16033. * Called by the GPUParticleSystem to setup the update shader
  16034. * @param effect defines the update shader
  16035. */
  16036. applyToShader(effect: Effect): void;
  16037. /**
  16038. * Returns a string to use to update the GPU particles update shader
  16039. * @returns a string containng the defines string
  16040. */
  16041. getEffectDefines(): string;
  16042. /**
  16043. * Returns the string "HemisphericParticleEmitter"
  16044. * @returns a string containing the class name
  16045. */
  16046. getClassName(): string;
  16047. /**
  16048. * Serializes the particle system to a JSON object.
  16049. * @returns the JSON object
  16050. */
  16051. serialize(): any;
  16052. /**
  16053. * Parse properties from a JSON object
  16054. * @param serializationObject defines the JSON object
  16055. */
  16056. parse(serializationObject: any): void;
  16057. }
  16058. }
  16059. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16060. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16061. import { Effect } from "babylonjs/Materials/effect";
  16062. import { Particle } from "babylonjs/Particles/particle";
  16063. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16064. /**
  16065. * Particle emitter emitting particles from a point.
  16066. * It emits the particles randomly between 2 given directions.
  16067. */
  16068. export class PointParticleEmitter implements IParticleEmitterType {
  16069. /**
  16070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16071. */
  16072. direction1: Vector3;
  16073. /**
  16074. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16075. */
  16076. direction2: Vector3;
  16077. /**
  16078. * Creates a new instance PointParticleEmitter
  16079. */
  16080. constructor();
  16081. /**
  16082. * Called by the particle System when the direction is computed for the created particle.
  16083. * @param worldMatrix is the world matrix of the particle system
  16084. * @param directionToUpdate is the direction vector to update with the result
  16085. * @param particle is the particle we are computed the direction for
  16086. */
  16087. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16088. /**
  16089. * Called by the particle System when the position is computed for the created particle.
  16090. * @param worldMatrix is the world matrix of the particle system
  16091. * @param positionToUpdate is the position vector to update with the result
  16092. * @param particle is the particle we are computed the position for
  16093. */
  16094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16095. /**
  16096. * Clones the current emitter and returns a copy of it
  16097. * @returns the new emitter
  16098. */
  16099. clone(): PointParticleEmitter;
  16100. /**
  16101. * Called by the GPUParticleSystem to setup the update shader
  16102. * @param effect defines the update shader
  16103. */
  16104. applyToShader(effect: Effect): void;
  16105. /**
  16106. * Returns a string to use to update the GPU particles update shader
  16107. * @returns a string containng the defines string
  16108. */
  16109. getEffectDefines(): string;
  16110. /**
  16111. * Returns the string "PointParticleEmitter"
  16112. * @returns a string containing the class name
  16113. */
  16114. getClassName(): string;
  16115. /**
  16116. * Serializes the particle system to a JSON object.
  16117. * @returns the JSON object
  16118. */
  16119. serialize(): any;
  16120. /**
  16121. * Parse properties from a JSON object
  16122. * @param serializationObject defines the JSON object
  16123. */
  16124. parse(serializationObject: any): void;
  16125. }
  16126. }
  16127. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16128. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16129. import { Effect } from "babylonjs/Materials/effect";
  16130. import { Particle } from "babylonjs/Particles/particle";
  16131. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16132. /**
  16133. * Particle emitter emitting particles from the inside of a sphere.
  16134. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16135. */
  16136. export class SphereParticleEmitter implements IParticleEmitterType {
  16137. /**
  16138. * The radius of the emission sphere.
  16139. */
  16140. radius: number;
  16141. /**
  16142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16143. */
  16144. radiusRange: number;
  16145. /**
  16146. * How much to randomize the particle direction [0-1].
  16147. */
  16148. directionRandomizer: number;
  16149. /**
  16150. * Creates a new instance SphereParticleEmitter
  16151. * @param radius the radius of the emission sphere (1 by default)
  16152. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16153. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16154. */
  16155. constructor(
  16156. /**
  16157. * The radius of the emission sphere.
  16158. */
  16159. radius?: number,
  16160. /**
  16161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16162. */
  16163. radiusRange?: number,
  16164. /**
  16165. * How much to randomize the particle direction [0-1].
  16166. */
  16167. directionRandomizer?: number);
  16168. /**
  16169. * Called by the particle System when the direction is computed for the created particle.
  16170. * @param worldMatrix is the world matrix of the particle system
  16171. * @param directionToUpdate is the direction vector to update with the result
  16172. * @param particle is the particle we are computed the direction for
  16173. */
  16174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16175. /**
  16176. * Called by the particle System when the position is computed for the created particle.
  16177. * @param worldMatrix is the world matrix of the particle system
  16178. * @param positionToUpdate is the position vector to update with the result
  16179. * @param particle is the particle we are computed the position for
  16180. */
  16181. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16182. /**
  16183. * Clones the current emitter and returns a copy of it
  16184. * @returns the new emitter
  16185. */
  16186. clone(): SphereParticleEmitter;
  16187. /**
  16188. * Called by the GPUParticleSystem to setup the update shader
  16189. * @param effect defines the update shader
  16190. */
  16191. applyToShader(effect: Effect): void;
  16192. /**
  16193. * Returns a string to use to update the GPU particles update shader
  16194. * @returns a string containng the defines string
  16195. */
  16196. getEffectDefines(): string;
  16197. /**
  16198. * Returns the string "SphereParticleEmitter"
  16199. * @returns a string containing the class name
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Serializes the particle system to a JSON object.
  16204. * @returns the JSON object
  16205. */
  16206. serialize(): any;
  16207. /**
  16208. * Parse properties from a JSON object
  16209. * @param serializationObject defines the JSON object
  16210. */
  16211. parse(serializationObject: any): void;
  16212. }
  16213. /**
  16214. * Particle emitter emitting particles from the inside of a sphere.
  16215. * It emits the particles randomly between two vectors.
  16216. */
  16217. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16218. /**
  16219. * The min limit of the emission direction.
  16220. */
  16221. direction1: Vector3;
  16222. /**
  16223. * The max limit of the emission direction.
  16224. */
  16225. direction2: Vector3;
  16226. /**
  16227. * Creates a new instance SphereDirectedParticleEmitter
  16228. * @param radius the radius of the emission sphere (1 by default)
  16229. * @param direction1 the min limit of the emission direction (up vector by default)
  16230. * @param direction2 the max limit of the emission direction (up vector by default)
  16231. */
  16232. constructor(radius?: number,
  16233. /**
  16234. * The min limit of the emission direction.
  16235. */
  16236. direction1?: Vector3,
  16237. /**
  16238. * The max limit of the emission direction.
  16239. */
  16240. direction2?: Vector3);
  16241. /**
  16242. * Called by the particle System when the direction is computed for the created particle.
  16243. * @param worldMatrix is the world matrix of the particle system
  16244. * @param directionToUpdate is the direction vector to update with the result
  16245. * @param particle is the particle we are computed the direction for
  16246. */
  16247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16248. /**
  16249. * Clones the current emitter and returns a copy of it
  16250. * @returns the new emitter
  16251. */
  16252. clone(): SphereDirectedParticleEmitter;
  16253. /**
  16254. * Called by the GPUParticleSystem to setup the update shader
  16255. * @param effect defines the update shader
  16256. */
  16257. applyToShader(effect: Effect): void;
  16258. /**
  16259. * Returns a string to use to update the GPU particles update shader
  16260. * @returns a string containng the defines string
  16261. */
  16262. getEffectDefines(): string;
  16263. /**
  16264. * Returns the string "SphereDirectedParticleEmitter"
  16265. * @returns a string containing the class name
  16266. */
  16267. getClassName(): string;
  16268. /**
  16269. * Serializes the particle system to a JSON object.
  16270. * @returns the JSON object
  16271. */
  16272. serialize(): any;
  16273. /**
  16274. * Parse properties from a JSON object
  16275. * @param serializationObject defines the JSON object
  16276. */
  16277. parse(serializationObject: any): void;
  16278. }
  16279. }
  16280. declare module "babylonjs/Particles/EmitterTypes/index" {
  16281. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16282. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16283. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16284. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16285. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16286. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16287. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16288. }
  16289. declare module "babylonjs/Particles/IParticleSystem" {
  16290. import { Nullable } from "babylonjs/types";
  16291. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16294. import { Texture } from "babylonjs/Materials/Textures/texture";
  16295. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16296. import { Scene } from "babylonjs/scene";
  16297. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16298. import { Animation } from "babylonjs/Animations/animation";
  16299. /**
  16300. * Interface representing a particle system in Babylon.js.
  16301. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16302. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16303. */
  16304. export interface IParticleSystem {
  16305. /**
  16306. * List of animations used by the particle system.
  16307. */
  16308. animations: Animation[];
  16309. /**
  16310. * The id of the Particle system.
  16311. */
  16312. id: string;
  16313. /**
  16314. * The name of the Particle system.
  16315. */
  16316. name: string;
  16317. /**
  16318. * The emitter represents the Mesh or position we are attaching the particle system to.
  16319. */
  16320. emitter: Nullable<AbstractMesh | Vector3>;
  16321. /**
  16322. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16323. */
  16324. isBillboardBased: boolean;
  16325. /**
  16326. * The rendering group used by the Particle system to chose when to render.
  16327. */
  16328. renderingGroupId: number;
  16329. /**
  16330. * The layer mask we are rendering the particles through.
  16331. */
  16332. layerMask: number;
  16333. /**
  16334. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16335. */
  16336. updateSpeed: number;
  16337. /**
  16338. * The amount of time the particle system is running (depends of the overall update speed).
  16339. */
  16340. targetStopDuration: number;
  16341. /**
  16342. * The texture used to render each particle. (this can be a spritesheet)
  16343. */
  16344. particleTexture: Nullable<Texture>;
  16345. /**
  16346. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16347. */
  16348. blendMode: number;
  16349. /**
  16350. * Minimum life time of emitting particles.
  16351. */
  16352. minLifeTime: number;
  16353. /**
  16354. * Maximum life time of emitting particles.
  16355. */
  16356. maxLifeTime: number;
  16357. /**
  16358. * Minimum Size of emitting particles.
  16359. */
  16360. minSize: number;
  16361. /**
  16362. * Maximum Size of emitting particles.
  16363. */
  16364. maxSize: number;
  16365. /**
  16366. * Minimum scale of emitting particles on X axis.
  16367. */
  16368. minScaleX: number;
  16369. /**
  16370. * Maximum scale of emitting particles on X axis.
  16371. */
  16372. maxScaleX: number;
  16373. /**
  16374. * Minimum scale of emitting particles on Y axis.
  16375. */
  16376. minScaleY: number;
  16377. /**
  16378. * Maximum scale of emitting particles on Y axis.
  16379. */
  16380. maxScaleY: number;
  16381. /**
  16382. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16383. */
  16384. color1: Color4;
  16385. /**
  16386. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16387. */
  16388. color2: Color4;
  16389. /**
  16390. * Color the particle will have at the end of its lifetime.
  16391. */
  16392. colorDead: Color4;
  16393. /**
  16394. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16395. */
  16396. emitRate: number;
  16397. /**
  16398. * You can use gravity if you want to give an orientation to your particles.
  16399. */
  16400. gravity: Vector3;
  16401. /**
  16402. * Minimum power of emitting particles.
  16403. */
  16404. minEmitPower: number;
  16405. /**
  16406. * Maximum power of emitting particles.
  16407. */
  16408. maxEmitPower: number;
  16409. /**
  16410. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16411. */
  16412. minAngularSpeed: number;
  16413. /**
  16414. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16415. */
  16416. maxAngularSpeed: number;
  16417. /**
  16418. * Gets or sets the minimal initial rotation in radians.
  16419. */
  16420. minInitialRotation: number;
  16421. /**
  16422. * Gets or sets the maximal initial rotation in radians.
  16423. */
  16424. maxInitialRotation: number;
  16425. /**
  16426. * The particle emitter type defines the emitter used by the particle system.
  16427. * It can be for example box, sphere, or cone...
  16428. */
  16429. particleEmitterType: Nullable<IParticleEmitterType>;
  16430. /**
  16431. * Defines the delay in milliseconds before starting the system (0 by default)
  16432. */
  16433. startDelay: number;
  16434. /**
  16435. * 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
  16436. */
  16437. preWarmCycles: number;
  16438. /**
  16439. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16440. */
  16441. preWarmStepOffset: number;
  16442. /**
  16443. * 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)
  16444. */
  16445. spriteCellChangeSpeed: number;
  16446. /**
  16447. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16448. */
  16449. startSpriteCellID: number;
  16450. /**
  16451. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16452. */
  16453. endSpriteCellID: number;
  16454. /**
  16455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16456. */
  16457. spriteCellWidth: number;
  16458. /**
  16459. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16460. */
  16461. spriteCellHeight: number;
  16462. /**
  16463. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16464. */
  16465. spriteRandomStartCell: boolean;
  16466. /**
  16467. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16468. */
  16469. isAnimationSheetEnabled: boolean;
  16470. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16471. translationPivot: Vector2;
  16472. /**
  16473. * Gets or sets a texture used to add random noise to particle positions
  16474. */
  16475. noiseTexture: Nullable<BaseTexture>;
  16476. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16477. noiseStrength: Vector3;
  16478. /**
  16479. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16480. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16481. */
  16482. billboardMode: number;
  16483. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16484. limitVelocityDamping: number;
  16485. /**
  16486. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16487. */
  16488. beginAnimationOnStart: boolean;
  16489. /**
  16490. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16491. */
  16492. beginAnimationFrom: number;
  16493. /**
  16494. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16495. */
  16496. beginAnimationTo: number;
  16497. /**
  16498. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16499. */
  16500. beginAnimationLoop: boolean;
  16501. /**
  16502. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16503. */
  16504. disposeOnStop: boolean;
  16505. /**
  16506. * Gets the maximum number of particles active at the same time.
  16507. * @returns The max number of active particles.
  16508. */
  16509. getCapacity(): number;
  16510. /**
  16511. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16512. * @returns True if it has been started, otherwise false.
  16513. */
  16514. isStarted(): boolean;
  16515. /**
  16516. * Animates the particle system for this frame.
  16517. */
  16518. animate(): void;
  16519. /**
  16520. * Renders the particle system in its current state.
  16521. * @returns the current number of particles
  16522. */
  16523. render(): number;
  16524. /**
  16525. * Dispose the particle system and frees its associated resources.
  16526. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16527. */
  16528. dispose(disposeTexture?: boolean): void;
  16529. /**
  16530. * Clones the particle system.
  16531. * @param name The name of the cloned object
  16532. * @param newEmitter The new emitter to use
  16533. * @returns the cloned particle system
  16534. */
  16535. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16536. /**
  16537. * Serializes the particle system to a JSON object.
  16538. * @returns the JSON object
  16539. */
  16540. serialize(): any;
  16541. /**
  16542. * Rebuild the particle system
  16543. */
  16544. rebuild(): void;
  16545. /**
  16546. * Starts the particle system and begins to emit
  16547. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16548. */
  16549. start(delay?: number): void;
  16550. /**
  16551. * Stops the particle system.
  16552. */
  16553. stop(): void;
  16554. /**
  16555. * Remove all active particles
  16556. */
  16557. reset(): void;
  16558. /**
  16559. * Is this system ready to be used/rendered
  16560. * @return true if the system is ready
  16561. */
  16562. isReady(): boolean;
  16563. /**
  16564. * Adds a new color gradient
  16565. * @param gradient defines the gradient to use (between 0 and 1)
  16566. * @param color1 defines the color to affect to the specified gradient
  16567. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16568. * @returns the current particle system
  16569. */
  16570. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16571. /**
  16572. * Remove a specific color gradient
  16573. * @param gradient defines the gradient to remove
  16574. * @returns the current particle system
  16575. */
  16576. removeColorGradient(gradient: number): IParticleSystem;
  16577. /**
  16578. * Adds a new size gradient
  16579. * @param gradient defines the gradient to use (between 0 and 1)
  16580. * @param factor defines the size factor to affect to the specified gradient
  16581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16582. * @returns the current particle system
  16583. */
  16584. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16585. /**
  16586. * Remove a specific size gradient
  16587. * @param gradient defines the gradient to remove
  16588. * @returns the current particle system
  16589. */
  16590. removeSizeGradient(gradient: number): IParticleSystem;
  16591. /**
  16592. * Gets the current list of color gradients.
  16593. * You must use addColorGradient and removeColorGradient to udpate this list
  16594. * @returns the list of color gradients
  16595. */
  16596. getColorGradients(): Nullable<Array<ColorGradient>>;
  16597. /**
  16598. * Gets the current list of size gradients.
  16599. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16600. * @returns the list of size gradients
  16601. */
  16602. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16603. /**
  16604. * Gets the current list of angular speed gradients.
  16605. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16606. * @returns the list of angular speed gradients
  16607. */
  16608. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16609. /**
  16610. * Adds a new angular speed gradient
  16611. * @param gradient defines the gradient to use (between 0 and 1)
  16612. * @param factor defines the angular speed to affect to the specified gradient
  16613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16614. * @returns the current particle system
  16615. */
  16616. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16617. /**
  16618. * Remove a specific angular speed gradient
  16619. * @param gradient defines the gradient to remove
  16620. * @returns the current particle system
  16621. */
  16622. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16623. /**
  16624. * Gets the current list of velocity gradients.
  16625. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16626. * @returns the list of velocity gradients
  16627. */
  16628. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16629. /**
  16630. * Adds a new velocity gradient
  16631. * @param gradient defines the gradient to use (between 0 and 1)
  16632. * @param factor defines the velocity to affect to the specified gradient
  16633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16634. * @returns the current particle system
  16635. */
  16636. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16637. /**
  16638. * Remove a specific velocity gradient
  16639. * @param gradient defines the gradient to remove
  16640. * @returns the current particle system
  16641. */
  16642. removeVelocityGradient(gradient: number): IParticleSystem;
  16643. /**
  16644. * Gets the current list of limit velocity gradients.
  16645. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16646. * @returns the list of limit velocity gradients
  16647. */
  16648. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16649. /**
  16650. * Adds a new limit velocity gradient
  16651. * @param gradient defines the gradient to use (between 0 and 1)
  16652. * @param factor defines the limit velocity to affect to the specified gradient
  16653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16654. * @returns the current particle system
  16655. */
  16656. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16657. /**
  16658. * Remove a specific limit velocity gradient
  16659. * @param gradient defines the gradient to remove
  16660. * @returns the current particle system
  16661. */
  16662. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16663. /**
  16664. * Adds a new drag gradient
  16665. * @param gradient defines the gradient to use (between 0 and 1)
  16666. * @param factor defines the drag to affect to the specified gradient
  16667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16668. * @returns the current particle system
  16669. */
  16670. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16671. /**
  16672. * Remove a specific drag gradient
  16673. * @param gradient defines the gradient to remove
  16674. * @returns the current particle system
  16675. */
  16676. removeDragGradient(gradient: number): IParticleSystem;
  16677. /**
  16678. * Gets the current list of drag gradients.
  16679. * You must use addDragGradient and removeDragGradient to udpate this list
  16680. * @returns the list of drag gradients
  16681. */
  16682. getDragGradients(): Nullable<Array<FactorGradient>>;
  16683. /**
  16684. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16685. * @param gradient defines the gradient to use (between 0 and 1)
  16686. * @param factor defines the emit rate to affect to the specified gradient
  16687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16688. * @returns the current particle system
  16689. */
  16690. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16691. /**
  16692. * Remove a specific emit rate gradient
  16693. * @param gradient defines the gradient to remove
  16694. * @returns the current particle system
  16695. */
  16696. removeEmitRateGradient(gradient: number): IParticleSystem;
  16697. /**
  16698. * Gets the current list of emit rate gradients.
  16699. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16700. * @returns the list of emit rate gradients
  16701. */
  16702. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16703. /**
  16704. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16705. * @param gradient defines the gradient to use (between 0 and 1)
  16706. * @param factor defines the start size to affect to the specified gradient
  16707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16708. * @returns the current particle system
  16709. */
  16710. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16711. /**
  16712. * Remove a specific start size gradient
  16713. * @param gradient defines the gradient to remove
  16714. * @returns the current particle system
  16715. */
  16716. removeStartSizeGradient(gradient: number): IParticleSystem;
  16717. /**
  16718. * Gets the current list of start size gradients.
  16719. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16720. * @returns the list of start size gradients
  16721. */
  16722. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16723. /**
  16724. * Adds a new life time gradient
  16725. * @param gradient defines the gradient to use (between 0 and 1)
  16726. * @param factor defines the life time factor to affect to the specified gradient
  16727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16728. * @returns the current particle system
  16729. */
  16730. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16731. /**
  16732. * Remove a specific life time gradient
  16733. * @param gradient defines the gradient to remove
  16734. * @returns the current particle system
  16735. */
  16736. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16737. /**
  16738. * Gets the current list of life time gradients.
  16739. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16740. * @returns the list of life time gradients
  16741. */
  16742. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16743. /**
  16744. * Gets the current list of color gradients.
  16745. * You must use addColorGradient and removeColorGradient to udpate this list
  16746. * @returns the list of color gradients
  16747. */
  16748. getColorGradients(): Nullable<Array<ColorGradient>>;
  16749. /**
  16750. * Adds a new ramp gradient used to remap particle colors
  16751. * @param gradient defines the gradient to use (between 0 and 1)
  16752. * @param color defines the color to affect to the specified gradient
  16753. * @returns the current particle system
  16754. */
  16755. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16756. /**
  16757. * Gets the current list of ramp gradients.
  16758. * You must use addRampGradient and removeRampGradient to udpate this list
  16759. * @returns the list of ramp gradients
  16760. */
  16761. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16762. /** Gets or sets a boolean indicating that ramp gradients must be used
  16763. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16764. */
  16765. useRampGradients: boolean;
  16766. /**
  16767. * Adds a new color remap gradient
  16768. * @param gradient defines the gradient to use (between 0 and 1)
  16769. * @param min defines the color remap minimal range
  16770. * @param max defines the color remap maximal range
  16771. * @returns the current particle system
  16772. */
  16773. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16774. /**
  16775. * Gets the current list of color remap gradients.
  16776. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16777. * @returns the list of color remap gradients
  16778. */
  16779. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16780. /**
  16781. * Adds a new alpha remap gradient
  16782. * @param gradient defines the gradient to use (between 0 and 1)
  16783. * @param min defines the alpha remap minimal range
  16784. * @param max defines the alpha remap maximal range
  16785. * @returns the current particle system
  16786. */
  16787. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16788. /**
  16789. * Gets the current list of alpha remap gradients.
  16790. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16791. * @returns the list of alpha remap gradients
  16792. */
  16793. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16794. /**
  16795. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16798. * @returns the emitter
  16799. */
  16800. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16801. /**
  16802. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16803. * @param radius The radius of the hemisphere to emit from
  16804. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16805. * @returns the emitter
  16806. */
  16807. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16808. /**
  16809. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16810. * @param radius The radius of the sphere to emit from
  16811. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16812. * @returns the emitter
  16813. */
  16814. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16815. /**
  16816. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16817. * @param radius The radius of the sphere to emit from
  16818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16820. * @returns the emitter
  16821. */
  16822. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16823. /**
  16824. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16825. * @param radius The radius of the emission cylinder
  16826. * @param height The height of the emission cylinder
  16827. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16828. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16829. * @returns the emitter
  16830. */
  16831. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16832. /**
  16833. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16834. * @param radius The radius of the cylinder to emit from
  16835. * @param height The height of the emission cylinder
  16836. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16839. * @returns the emitter
  16840. */
  16841. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16842. /**
  16843. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16844. * @param radius The radius of the cone to emit from
  16845. * @param angle The base angle of the cone
  16846. * @returns the emitter
  16847. */
  16848. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16849. /**
  16850. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16853. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16854. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16855. * @returns the emitter
  16856. */
  16857. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16858. /**
  16859. * Get hosting scene
  16860. * @returns the scene
  16861. */
  16862. getScene(): Scene;
  16863. }
  16864. }
  16865. declare module "babylonjs/Meshes/instancedMesh" {
  16866. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16867. import { Vector3 } from "babylonjs/Maths/math";
  16868. import { Camera } from "babylonjs/Cameras/camera";
  16869. import { Node } from "babylonjs/node";
  16870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16871. import { Mesh } from "babylonjs/Meshes/mesh";
  16872. import { Material } from "babylonjs/Materials/material";
  16873. import { Skeleton } from "babylonjs/Bones/skeleton";
  16874. /**
  16875. * Creates an instance based on a source mesh.
  16876. */
  16877. export class InstancedMesh extends AbstractMesh {
  16878. private _sourceMesh;
  16879. private _currentLOD;
  16880. /** @hidden */
  16881. _indexInSourceMeshInstanceArray: number;
  16882. constructor(name: string, source: Mesh);
  16883. /**
  16884. * Returns the string "InstancedMesh".
  16885. */
  16886. getClassName(): string;
  16887. /**
  16888. * If the source mesh receives shadows
  16889. */
  16890. readonly receiveShadows: boolean;
  16891. /**
  16892. * The material of the source mesh
  16893. */
  16894. readonly material: Nullable<Material>;
  16895. /**
  16896. * Visibility of the source mesh
  16897. */
  16898. readonly visibility: number;
  16899. /**
  16900. * Skeleton of the source mesh
  16901. */
  16902. readonly skeleton: Nullable<Skeleton>;
  16903. /**
  16904. * Rendering ground id of the source mesh
  16905. */
  16906. renderingGroupId: number;
  16907. /**
  16908. * Returns the total number of vertices (integer).
  16909. */
  16910. getTotalVertices(): number;
  16911. /**
  16912. * Returns a positive integer : the total number of indices in this mesh geometry.
  16913. * @returns the numner of indices or zero if the mesh has no geometry.
  16914. */
  16915. getTotalIndices(): number;
  16916. /**
  16917. * The source mesh of the instance
  16918. */
  16919. readonly sourceMesh: Mesh;
  16920. /**
  16921. * Is this node ready to be used/rendered
  16922. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16923. * @return {boolean} is it ready
  16924. */
  16925. isReady(completeCheck?: boolean): boolean;
  16926. /**
  16927. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16928. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16929. * @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.
  16930. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16931. */
  16932. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16933. /**
  16934. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16935. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16936. * The `data` are either a numeric array either a Float32Array.
  16937. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16938. * 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).
  16939. * Note that a new underlying VertexBuffer object is created each call.
  16940. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16941. *
  16942. * Possible `kind` values :
  16943. * - VertexBuffer.PositionKind
  16944. * - VertexBuffer.UVKind
  16945. * - VertexBuffer.UV2Kind
  16946. * - VertexBuffer.UV3Kind
  16947. * - VertexBuffer.UV4Kind
  16948. * - VertexBuffer.UV5Kind
  16949. * - VertexBuffer.UV6Kind
  16950. * - VertexBuffer.ColorKind
  16951. * - VertexBuffer.MatricesIndicesKind
  16952. * - VertexBuffer.MatricesIndicesExtraKind
  16953. * - VertexBuffer.MatricesWeightsKind
  16954. * - VertexBuffer.MatricesWeightsExtraKind
  16955. *
  16956. * Returns the Mesh.
  16957. */
  16958. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16959. /**
  16960. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16961. * If the mesh has no geometry, it is simply returned as it is.
  16962. * The `data` are either a numeric array either a Float32Array.
  16963. * No new underlying VertexBuffer object is created.
  16964. * 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.
  16965. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16966. *
  16967. * Possible `kind` values :
  16968. * - VertexBuffer.PositionKind
  16969. * - VertexBuffer.UVKind
  16970. * - VertexBuffer.UV2Kind
  16971. * - VertexBuffer.UV3Kind
  16972. * - VertexBuffer.UV4Kind
  16973. * - VertexBuffer.UV5Kind
  16974. * - VertexBuffer.UV6Kind
  16975. * - VertexBuffer.ColorKind
  16976. * - VertexBuffer.MatricesIndicesKind
  16977. * - VertexBuffer.MatricesIndicesExtraKind
  16978. * - VertexBuffer.MatricesWeightsKind
  16979. * - VertexBuffer.MatricesWeightsExtraKind
  16980. *
  16981. * Returns the Mesh.
  16982. */
  16983. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16984. /**
  16985. * Sets the mesh indices.
  16986. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16987. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16988. * This method creates a new index buffer each call.
  16989. * Returns the Mesh.
  16990. */
  16991. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16992. /**
  16993. * Boolean : True if the mesh owns the requested kind of data.
  16994. */
  16995. isVerticesDataPresent(kind: string): boolean;
  16996. /**
  16997. * Returns an array of indices (IndicesArray).
  16998. */
  16999. getIndices(): Nullable<IndicesArray>;
  17000. readonly _positions: Nullable<Vector3[]>;
  17001. /**
  17002. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17003. * This means the mesh underlying bounding box and sphere are recomputed.
  17004. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17005. * @returns the current mesh
  17006. */
  17007. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17008. /** @hidden */
  17009. _preActivate(): InstancedMesh;
  17010. /** @hidden */
  17011. _activate(renderId: number): InstancedMesh;
  17012. /**
  17013. * Returns the current associated LOD AbstractMesh.
  17014. */
  17015. getLOD(camera: Camera): AbstractMesh;
  17016. /** @hidden */
  17017. _syncSubMeshes(): InstancedMesh;
  17018. /** @hidden */
  17019. _generatePointsArray(): boolean;
  17020. /**
  17021. * Creates a new InstancedMesh from the current mesh.
  17022. * - name (string) : the cloned mesh name
  17023. * - newParent (optional Node) : the optional Node to parent the clone to.
  17024. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17025. *
  17026. * Returns the clone.
  17027. */
  17028. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17029. /**
  17030. * Disposes the InstancedMesh.
  17031. * Returns nothing.
  17032. */
  17033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17034. }
  17035. }
  17036. declare module "babylonjs/Materials/shaderMaterial" {
  17037. import { Scene } from "babylonjs/scene";
  17038. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17040. import { Mesh } from "babylonjs/Meshes/mesh";
  17041. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17043. import { Texture } from "babylonjs/Materials/Textures/texture";
  17044. import { Material } from "babylonjs/Materials/material";
  17045. /**
  17046. * Defines the options associated with the creation of a shader material.
  17047. */
  17048. export interface IShaderMaterialOptions {
  17049. /**
  17050. * Does the material work in alpha blend mode
  17051. */
  17052. needAlphaBlending: boolean;
  17053. /**
  17054. * Does the material work in alpha test mode
  17055. */
  17056. needAlphaTesting: boolean;
  17057. /**
  17058. * The list of attribute names used in the shader
  17059. */
  17060. attributes: string[];
  17061. /**
  17062. * The list of unifrom names used in the shader
  17063. */
  17064. uniforms: string[];
  17065. /**
  17066. * The list of UBO names used in the shader
  17067. */
  17068. uniformBuffers: string[];
  17069. /**
  17070. * The list of sampler names used in the shader
  17071. */
  17072. samplers: string[];
  17073. /**
  17074. * The list of defines used in the shader
  17075. */
  17076. defines: string[];
  17077. }
  17078. /**
  17079. * 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.
  17080. *
  17081. * This returned material effects how the mesh will look based on the code in the shaders.
  17082. *
  17083. * @see http://doc.babylonjs.com/how_to/shader_material
  17084. */
  17085. export class ShaderMaterial extends Material {
  17086. private _shaderPath;
  17087. private _options;
  17088. private _textures;
  17089. private _textureArrays;
  17090. private _floats;
  17091. private _ints;
  17092. private _floatsArrays;
  17093. private _colors3;
  17094. private _colors3Arrays;
  17095. private _colors4;
  17096. private _vectors2;
  17097. private _vectors3;
  17098. private _vectors4;
  17099. private _matrices;
  17100. private _matrices3x3;
  17101. private _matrices2x2;
  17102. private _vectors2Arrays;
  17103. private _vectors3Arrays;
  17104. private _cachedWorldViewMatrix;
  17105. private _renderId;
  17106. /**
  17107. * Instantiate a new shader material.
  17108. * 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.
  17109. * This returned material effects how the mesh will look based on the code in the shaders.
  17110. * @see http://doc.babylonjs.com/how_to/shader_material
  17111. * @param name Define the name of the material in the scene
  17112. * @param scene Define the scene the material belongs to
  17113. * @param shaderPath Defines the route to the shader code in one of three ways:
  17114. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17115. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17116. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17117. * @param options Define the options used to create the shader
  17118. */
  17119. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17120. /**
  17121. * Gets the options used to compile the shader.
  17122. * They can be modified to trigger a new compilation
  17123. */
  17124. readonly options: IShaderMaterialOptions;
  17125. /**
  17126. * Gets the current class name of the material e.g. "ShaderMaterial"
  17127. * Mainly use in serialization.
  17128. * @returns the class name
  17129. */
  17130. getClassName(): string;
  17131. /**
  17132. * Specifies if the material will require alpha blending
  17133. * @returns a boolean specifying if alpha blending is needed
  17134. */
  17135. needAlphaBlending(): boolean;
  17136. /**
  17137. * Specifies if this material should be rendered in alpha test mode
  17138. * @returns a boolean specifying if an alpha test is needed.
  17139. */
  17140. needAlphaTesting(): boolean;
  17141. private _checkUniform;
  17142. /**
  17143. * Set a texture in the shader.
  17144. * @param name Define the name of the uniform samplers as defined in the shader
  17145. * @param texture Define the texture to bind to this sampler
  17146. * @return the material itself allowing "fluent" like uniform updates
  17147. */
  17148. setTexture(name: string, texture: Texture): ShaderMaterial;
  17149. /**
  17150. * Set a texture array in the shader.
  17151. * @param name Define the name of the uniform sampler array as defined in the shader
  17152. * @param textures Define the list of textures to bind to this sampler
  17153. * @return the material itself allowing "fluent" like uniform updates
  17154. */
  17155. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17156. /**
  17157. * Set a float in the shader.
  17158. * @param name Define the name of the uniform as defined in the shader
  17159. * @param value Define the value to give to the uniform
  17160. * @return the material itself allowing "fluent" like uniform updates
  17161. */
  17162. setFloat(name: string, value: number): ShaderMaterial;
  17163. /**
  17164. * Set a int in the shader.
  17165. * @param name Define the name of the uniform as defined in the shader
  17166. * @param value Define the value to give to the uniform
  17167. * @return the material itself allowing "fluent" like uniform updates
  17168. */
  17169. setInt(name: string, value: number): ShaderMaterial;
  17170. /**
  17171. * Set an array of floats in the shader.
  17172. * @param name Define the name of the uniform as defined in the shader
  17173. * @param value Define the value to give to the uniform
  17174. * @return the material itself allowing "fluent" like uniform updates
  17175. */
  17176. setFloats(name: string, value: number[]): ShaderMaterial;
  17177. /**
  17178. * Set a vec3 in the shader from a Color3.
  17179. * @param name Define the name of the uniform as defined in the shader
  17180. * @param value Define the value to give to the uniform
  17181. * @return the material itself allowing "fluent" like uniform updates
  17182. */
  17183. setColor3(name: string, value: Color3): ShaderMaterial;
  17184. /**
  17185. * Set a vec3 array in the shader from a Color3 array.
  17186. * @param name Define the name of the uniform as defined in the shader
  17187. * @param value Define the value to give to the uniform
  17188. * @return the material itself allowing "fluent" like uniform updates
  17189. */
  17190. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17191. /**
  17192. * Set a vec4 in the shader from a Color4.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the material itself allowing "fluent" like uniform updates
  17196. */
  17197. setColor4(name: string, value: Color4): ShaderMaterial;
  17198. /**
  17199. * Set a vec2 in the shader from a Vector2.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the material itself allowing "fluent" like uniform updates
  17203. */
  17204. setVector2(name: string, value: Vector2): ShaderMaterial;
  17205. /**
  17206. * Set a vec3 in the shader from a Vector3.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the material itself allowing "fluent" like uniform updates
  17210. */
  17211. setVector3(name: string, value: Vector3): ShaderMaterial;
  17212. /**
  17213. * Set a vec4 in the shader from a Vector4.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the material itself allowing "fluent" like uniform updates
  17217. */
  17218. setVector4(name: string, value: Vector4): ShaderMaterial;
  17219. /**
  17220. * Set a mat4 in the shader from a Matrix.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the material itself allowing "fluent" like uniform updates
  17224. */
  17225. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17226. /**
  17227. * Set a mat3 in the shader from a Float32Array.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the material itself allowing "fluent" like uniform updates
  17231. */
  17232. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17233. /**
  17234. * Set a mat2 in the shader from a Float32Array.
  17235. * @param name Define the name of the uniform as defined in the shader
  17236. * @param value Define the value to give to the uniform
  17237. * @return the material itself allowing "fluent" like uniform updates
  17238. */
  17239. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17240. /**
  17241. * Set a vec2 array in the shader from a number array.
  17242. * @param name Define the name of the uniform as defined in the shader
  17243. * @param value Define the value to give to the uniform
  17244. * @return the material itself allowing "fluent" like uniform updates
  17245. */
  17246. setArray2(name: string, value: number[]): ShaderMaterial;
  17247. /**
  17248. * Set a vec3 array in the shader from a number array.
  17249. * @param name Define the name of the uniform as defined in the shader
  17250. * @param value Define the value to give to the uniform
  17251. * @return the material itself allowing "fluent" like uniform updates
  17252. */
  17253. setArray3(name: string, value: number[]): ShaderMaterial;
  17254. private _checkCache;
  17255. /**
  17256. * Specifies that the submesh is ready to be used
  17257. * @param mesh defines the mesh to check
  17258. * @param subMesh defines which submesh to check
  17259. * @param useInstances specifies that instances should be used
  17260. * @returns a boolean indicating that the submesh is ready or not
  17261. */
  17262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17263. /**
  17264. * Checks if the material is ready to render the requested mesh
  17265. * @param mesh Define the mesh to render
  17266. * @param useInstances Define whether or not the material is used with instances
  17267. * @returns true if ready, otherwise false
  17268. */
  17269. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17270. /**
  17271. * Binds the world matrix to the material
  17272. * @param world defines the world transformation matrix
  17273. */
  17274. bindOnlyWorldMatrix(world: Matrix): void;
  17275. /**
  17276. * Binds the material to the mesh
  17277. * @param world defines the world transformation matrix
  17278. * @param mesh defines the mesh to bind the material to
  17279. */
  17280. bind(world: Matrix, mesh?: Mesh): void;
  17281. /**
  17282. * Gets the active textures from the material
  17283. * @returns an array of textures
  17284. */
  17285. getActiveTextures(): BaseTexture[];
  17286. /**
  17287. * Specifies if the material uses a texture
  17288. * @param texture defines the texture to check against the material
  17289. * @returns a boolean specifying if the material uses the texture
  17290. */
  17291. hasTexture(texture: BaseTexture): boolean;
  17292. /**
  17293. * Makes a duplicate of the material, and gives it a new name
  17294. * @param name defines the new name for the duplicated material
  17295. * @returns the cloned material
  17296. */
  17297. clone(name: string): ShaderMaterial;
  17298. /**
  17299. * Disposes the material
  17300. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17301. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17302. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17303. */
  17304. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17305. /**
  17306. * Serializes this material in a JSON representation
  17307. * @returns the serialized material object
  17308. */
  17309. serialize(): any;
  17310. /**
  17311. * Creates a shader material from parsed shader material data
  17312. * @param source defines the JSON represnetation of the material
  17313. * @param scene defines the hosting scene
  17314. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17315. * @returns a new material
  17316. */
  17317. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17318. }
  17319. }
  17320. declare module "babylonjs/Shaders/color.fragment" {
  17321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17322. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17323. /** @hidden */
  17324. export var colorPixelShader: {
  17325. name: string;
  17326. shader: string;
  17327. };
  17328. }
  17329. declare module "babylonjs/Shaders/color.vertex" {
  17330. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17332. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17333. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17334. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17335. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17336. /** @hidden */
  17337. export var colorVertexShader: {
  17338. name: string;
  17339. shader: string;
  17340. };
  17341. }
  17342. declare module "babylonjs/Meshes/linesMesh" {
  17343. import { Nullable } from "babylonjs/types";
  17344. import { Scene } from "babylonjs/scene";
  17345. import { Color3 } from "babylonjs/Maths/math";
  17346. import { Node } from "babylonjs/node";
  17347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17348. import { Mesh } from "babylonjs/Meshes/mesh";
  17349. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17350. import { Effect } from "babylonjs/Materials/effect";
  17351. import { Material } from "babylonjs/Materials/material";
  17352. import "babylonjs/Shaders/color.fragment";
  17353. import "babylonjs/Shaders/color.vertex";
  17354. /**
  17355. * Line mesh
  17356. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17357. */
  17358. export class LinesMesh extends Mesh {
  17359. /**
  17360. * If vertex color should be applied to the mesh
  17361. */
  17362. useVertexColor?: boolean | undefined;
  17363. /**
  17364. * If vertex alpha should be applied to the mesh
  17365. */
  17366. useVertexAlpha?: boolean | undefined;
  17367. /**
  17368. * Color of the line (Default: White)
  17369. */
  17370. color: Color3;
  17371. /**
  17372. * Alpha of the line (Default: 1)
  17373. */
  17374. alpha: number;
  17375. /**
  17376. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17377. * This margin is expressed in world space coordinates, so its value may vary.
  17378. * Default value is 0.1
  17379. */
  17380. intersectionThreshold: number;
  17381. private _colorShader;
  17382. /**
  17383. * Creates a new LinesMesh
  17384. * @param name defines the name
  17385. * @param scene defines the hosting scene
  17386. * @param parent defines the parent mesh if any
  17387. * @param source defines the optional source LinesMesh used to clone data from
  17388. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17389. * When false, achieved by calling a clone(), also passing False.
  17390. * This will make creation of children, recursive.
  17391. * @param useVertexColor defines if this LinesMesh supports vertex color
  17392. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17393. */
  17394. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17395. /**
  17396. * If vertex color should be applied to the mesh
  17397. */
  17398. useVertexColor?: boolean | undefined,
  17399. /**
  17400. * If vertex alpha should be applied to the mesh
  17401. */
  17402. useVertexAlpha?: boolean | undefined);
  17403. private _addClipPlaneDefine;
  17404. private _removeClipPlaneDefine;
  17405. isReady(): boolean;
  17406. /**
  17407. * Returns the string "LineMesh"
  17408. */
  17409. getClassName(): string;
  17410. /**
  17411. * @hidden
  17412. */
  17413. /**
  17414. * @hidden
  17415. */
  17416. material: Material;
  17417. /**
  17418. * @hidden
  17419. */
  17420. readonly checkCollisions: boolean;
  17421. /** @hidden */
  17422. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17423. /** @hidden */
  17424. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17425. /**
  17426. * Disposes of the line mesh
  17427. * @param doNotRecurse If children should be disposed
  17428. */
  17429. dispose(doNotRecurse?: boolean): void;
  17430. /**
  17431. * Returns a new LineMesh object cloned from the current one.
  17432. */
  17433. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17434. /**
  17435. * Creates a new InstancedLinesMesh object from the mesh model.
  17436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17437. * @param name defines the name of the new instance
  17438. * @returns a new InstancedLinesMesh
  17439. */
  17440. createInstance(name: string): InstancedLinesMesh;
  17441. }
  17442. /**
  17443. * Creates an instance based on a source LinesMesh
  17444. */
  17445. export class InstancedLinesMesh extends InstancedMesh {
  17446. /**
  17447. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17448. * This margin is expressed in world space coordinates, so its value may vary.
  17449. * Initilized with the intersectionThreshold value of the source LinesMesh
  17450. */
  17451. intersectionThreshold: number;
  17452. constructor(name: string, source: LinesMesh);
  17453. /**
  17454. * Returns the string "InstancedLinesMesh".
  17455. */
  17456. getClassName(): string;
  17457. }
  17458. }
  17459. declare module "babylonjs/Shaders/line.fragment" {
  17460. /** @hidden */
  17461. export var linePixelShader: {
  17462. name: string;
  17463. shader: string;
  17464. };
  17465. }
  17466. declare module "babylonjs/Shaders/line.vertex" {
  17467. /** @hidden */
  17468. export var lineVertexShader: {
  17469. name: string;
  17470. shader: string;
  17471. };
  17472. }
  17473. declare module "babylonjs/Rendering/edgesRenderer" {
  17474. import { Nullable } from "babylonjs/types";
  17475. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17477. import { Vector3 } from "babylonjs/Maths/math";
  17478. import { IDisposable } from "babylonjs/scene";
  17479. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17480. import "babylonjs/Shaders/line.fragment";
  17481. import "babylonjs/Shaders/line.vertex";
  17482. module "babylonjs/Meshes/abstractMesh" {
  17483. interface AbstractMesh {
  17484. /**
  17485. * Disables the mesh edge rendering mode
  17486. * @returns the currentAbstractMesh
  17487. */
  17488. disableEdgesRendering(): AbstractMesh;
  17489. /**
  17490. * Enables the edge rendering mode on the mesh.
  17491. * This mode makes the mesh edges visible
  17492. * @param epsilon defines the maximal distance between two angles to detect a face
  17493. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17494. * @returns the currentAbstractMesh
  17495. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17496. */
  17497. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17498. /**
  17499. * Gets the edgesRenderer associated with the mesh
  17500. */
  17501. edgesRenderer: Nullable<EdgesRenderer>;
  17502. }
  17503. }
  17504. module "babylonjs/Meshes/linesMesh" {
  17505. interface LinesMesh {
  17506. /**
  17507. * Enables the edge rendering mode on the mesh.
  17508. * This mode makes the mesh edges visible
  17509. * @param epsilon defines the maximal distance between two angles to detect a face
  17510. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17511. * @returns the currentAbstractMesh
  17512. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17513. */
  17514. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17515. }
  17516. }
  17517. module "babylonjs/Meshes/linesMesh" {
  17518. interface InstancedLinesMesh {
  17519. /**
  17520. * Enables the edge rendering mode on the mesh.
  17521. * This mode makes the mesh edges visible
  17522. * @param epsilon defines the maximal distance between two angles to detect a face
  17523. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17524. * @returns the current InstancedLinesMesh
  17525. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17526. */
  17527. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17528. }
  17529. }
  17530. /**
  17531. * Defines the minimum contract an Edges renderer should follow.
  17532. */
  17533. export interface IEdgesRenderer extends IDisposable {
  17534. /**
  17535. * Gets or sets a boolean indicating if the edgesRenderer is active
  17536. */
  17537. isEnabled: boolean;
  17538. /**
  17539. * Renders the edges of the attached mesh,
  17540. */
  17541. render(): void;
  17542. /**
  17543. * Checks wether or not the edges renderer is ready to render.
  17544. * @return true if ready, otherwise false.
  17545. */
  17546. isReady(): boolean;
  17547. }
  17548. /**
  17549. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17550. */
  17551. export class EdgesRenderer implements IEdgesRenderer {
  17552. /**
  17553. * Define the size of the edges with an orthographic camera
  17554. */
  17555. edgesWidthScalerForOrthographic: number;
  17556. /**
  17557. * Define the size of the edges with a perspective camera
  17558. */
  17559. edgesWidthScalerForPerspective: number;
  17560. protected _source: AbstractMesh;
  17561. protected _linesPositions: number[];
  17562. protected _linesNormals: number[];
  17563. protected _linesIndices: number[];
  17564. protected _epsilon: number;
  17565. protected _indicesCount: number;
  17566. protected _lineShader: ShaderMaterial;
  17567. protected _ib: WebGLBuffer;
  17568. protected _buffers: {
  17569. [key: string]: Nullable<VertexBuffer>;
  17570. };
  17571. protected _checkVerticesInsteadOfIndices: boolean;
  17572. private _meshRebuildObserver;
  17573. private _meshDisposeObserver;
  17574. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17575. isEnabled: boolean;
  17576. /**
  17577. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17578. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17579. * @param source Mesh used to create edges
  17580. * @param epsilon sum of angles in adjacency to check for edge
  17581. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17582. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17583. */
  17584. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17585. protected _prepareRessources(): void;
  17586. /** @hidden */
  17587. _rebuild(): void;
  17588. /**
  17589. * Releases the required resources for the edges renderer
  17590. */
  17591. dispose(): void;
  17592. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17593. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17594. /**
  17595. * Checks if the pair of p0 and p1 is en edge
  17596. * @param faceIndex
  17597. * @param edge
  17598. * @param faceNormals
  17599. * @param p0
  17600. * @param p1
  17601. * @private
  17602. */
  17603. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17604. /**
  17605. * push line into the position, normal and index buffer
  17606. * @protected
  17607. */
  17608. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17609. /**
  17610. * Generates lines edges from adjacencjes
  17611. * @private
  17612. */
  17613. _generateEdgesLines(): void;
  17614. /**
  17615. * Checks wether or not the edges renderer is ready to render.
  17616. * @return true if ready, otherwise false.
  17617. */
  17618. isReady(): boolean;
  17619. /**
  17620. * Renders the edges of the attached mesh,
  17621. */
  17622. render(): void;
  17623. }
  17624. /**
  17625. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17626. */
  17627. export class LineEdgesRenderer extends EdgesRenderer {
  17628. /**
  17629. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17630. * @param source LineMesh used to generate edges
  17631. * @param epsilon not important (specified angle for edge detection)
  17632. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17633. */
  17634. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17635. /**
  17636. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17637. */
  17638. _generateEdgesLines(): void;
  17639. }
  17640. }
  17641. declare module "babylonjs/Rendering/renderingGroup" {
  17642. import { SmartArray } from "babylonjs/Misc/smartArray";
  17643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17645. import { Nullable } from "babylonjs/types";
  17646. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17647. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17648. import { Material } from "babylonjs/Materials/material";
  17649. import { Scene } from "babylonjs/scene";
  17650. /**
  17651. * This represents the object necessary to create a rendering group.
  17652. * This is exclusively used and created by the rendering manager.
  17653. * To modify the behavior, you use the available helpers in your scene or meshes.
  17654. * @hidden
  17655. */
  17656. export class RenderingGroup {
  17657. index: number;
  17658. private _scene;
  17659. private _opaqueSubMeshes;
  17660. private _transparentSubMeshes;
  17661. private _alphaTestSubMeshes;
  17662. private _depthOnlySubMeshes;
  17663. private _particleSystems;
  17664. private _spriteManagers;
  17665. private _opaqueSortCompareFn;
  17666. private _alphaTestSortCompareFn;
  17667. private _transparentSortCompareFn;
  17668. private _renderOpaque;
  17669. private _renderAlphaTest;
  17670. private _renderTransparent;
  17671. private _edgesRenderers;
  17672. onBeforeTransparentRendering: () => void;
  17673. /**
  17674. * Set the opaque sort comparison function.
  17675. * If null the sub meshes will be render in the order they were created
  17676. */
  17677. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17678. /**
  17679. * Set the alpha test sort comparison function.
  17680. * If null the sub meshes will be render in the order they were created
  17681. */
  17682. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17683. /**
  17684. * Set the transparent sort comparison function.
  17685. * If null the sub meshes will be render in the order they were created
  17686. */
  17687. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17688. /**
  17689. * Creates a new rendering group.
  17690. * @param index The rendering group index
  17691. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17692. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17693. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17694. */
  17695. 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>);
  17696. /**
  17697. * Render all the sub meshes contained in the group.
  17698. * @param customRenderFunction Used to override the default render behaviour of the group.
  17699. * @returns true if rendered some submeshes.
  17700. */
  17701. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17702. /**
  17703. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17704. * @param subMeshes The submeshes to render
  17705. */
  17706. private renderOpaqueSorted;
  17707. /**
  17708. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17709. * @param subMeshes The submeshes to render
  17710. */
  17711. private renderAlphaTestSorted;
  17712. /**
  17713. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17714. * @param subMeshes The submeshes to render
  17715. */
  17716. private renderTransparentSorted;
  17717. /**
  17718. * Renders the submeshes in a specified order.
  17719. * @param subMeshes The submeshes to sort before render
  17720. * @param sortCompareFn The comparison function use to sort
  17721. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17722. * @param transparent Specifies to activate blending if true
  17723. */
  17724. private static renderSorted;
  17725. /**
  17726. * Renders the submeshes in the order they were dispatched (no sort applied).
  17727. * @param subMeshes The submeshes to render
  17728. */
  17729. private static renderUnsorted;
  17730. /**
  17731. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17732. * are rendered back to front if in the same alpha index.
  17733. *
  17734. * @param a The first submesh
  17735. * @param b The second submesh
  17736. * @returns The result of the comparison
  17737. */
  17738. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17739. /**
  17740. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17741. * are rendered back to front.
  17742. *
  17743. * @param a The first submesh
  17744. * @param b The second submesh
  17745. * @returns The result of the comparison
  17746. */
  17747. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17748. /**
  17749. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17750. * are rendered front to back (prevent overdraw).
  17751. *
  17752. * @param a The first submesh
  17753. * @param b The second submesh
  17754. * @returns The result of the comparison
  17755. */
  17756. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17757. /**
  17758. * Resets the different lists of submeshes to prepare a new frame.
  17759. */
  17760. prepare(): void;
  17761. dispose(): void;
  17762. /**
  17763. * Inserts the submesh in its correct queue depending on its material.
  17764. * @param subMesh The submesh to dispatch
  17765. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17766. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17767. */
  17768. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17769. dispatchSprites(spriteManager: ISpriteManager): void;
  17770. dispatchParticles(particleSystem: IParticleSystem): void;
  17771. private _renderParticles;
  17772. private _renderSprites;
  17773. }
  17774. }
  17775. declare module "babylonjs/Rendering/renderingManager" {
  17776. import { Nullable } from "babylonjs/types";
  17777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17778. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17779. import { SmartArray } from "babylonjs/Misc/smartArray";
  17780. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17781. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17782. import { Material } from "babylonjs/Materials/material";
  17783. import { Scene } from "babylonjs/scene";
  17784. import { Camera } from "babylonjs/Cameras/camera";
  17785. /**
  17786. * Interface describing the different options available in the rendering manager
  17787. * regarding Auto Clear between groups.
  17788. */
  17789. export interface IRenderingManagerAutoClearSetup {
  17790. /**
  17791. * Defines whether or not autoclear is enable.
  17792. */
  17793. autoClear: boolean;
  17794. /**
  17795. * Defines whether or not to autoclear the depth buffer.
  17796. */
  17797. depth: boolean;
  17798. /**
  17799. * Defines whether or not to autoclear the stencil buffer.
  17800. */
  17801. stencil: boolean;
  17802. }
  17803. /**
  17804. * This class is used by the onRenderingGroupObservable
  17805. */
  17806. export class RenderingGroupInfo {
  17807. /**
  17808. * The Scene that being rendered
  17809. */
  17810. scene: Scene;
  17811. /**
  17812. * The camera currently used for the rendering pass
  17813. */
  17814. camera: Nullable<Camera>;
  17815. /**
  17816. * The ID of the renderingGroup being processed
  17817. */
  17818. renderingGroupId: number;
  17819. }
  17820. /**
  17821. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17822. * It is enable to manage the different groups as well as the different necessary sort functions.
  17823. * This should not be used directly aside of the few static configurations
  17824. */
  17825. export class RenderingManager {
  17826. /**
  17827. * The max id used for rendering groups (not included)
  17828. */
  17829. static MAX_RENDERINGGROUPS: number;
  17830. /**
  17831. * The min id used for rendering groups (included)
  17832. */
  17833. static MIN_RENDERINGGROUPS: number;
  17834. /**
  17835. * Used to globally prevent autoclearing scenes.
  17836. */
  17837. static AUTOCLEAR: boolean;
  17838. /**
  17839. * @hidden
  17840. */
  17841. _useSceneAutoClearSetup: boolean;
  17842. private _scene;
  17843. private _renderingGroups;
  17844. private _depthStencilBufferAlreadyCleaned;
  17845. private _autoClearDepthStencil;
  17846. private _customOpaqueSortCompareFn;
  17847. private _customAlphaTestSortCompareFn;
  17848. private _customTransparentSortCompareFn;
  17849. private _renderingGroupInfo;
  17850. /**
  17851. * Instantiates a new rendering group for a particular scene
  17852. * @param scene Defines the scene the groups belongs to
  17853. */
  17854. constructor(scene: Scene);
  17855. private _clearDepthStencilBuffer;
  17856. /**
  17857. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17858. * @hidden
  17859. */
  17860. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17861. /**
  17862. * Resets the different information of the group to prepare a new frame
  17863. * @hidden
  17864. */
  17865. reset(): void;
  17866. /**
  17867. * Dispose and release the group and its associated resources.
  17868. * @hidden
  17869. */
  17870. dispose(): void;
  17871. /**
  17872. * Clear the info related to rendering groups preventing retention points during dispose.
  17873. */
  17874. freeRenderingGroups(): void;
  17875. private _prepareRenderingGroup;
  17876. /**
  17877. * Add a sprite manager to the rendering manager in order to render it this frame.
  17878. * @param spriteManager Define the sprite manager to render
  17879. */
  17880. dispatchSprites(spriteManager: ISpriteManager): void;
  17881. /**
  17882. * Add a particle system to the rendering manager in order to render it this frame.
  17883. * @param particleSystem Define the particle system to render
  17884. */
  17885. dispatchParticles(particleSystem: IParticleSystem): void;
  17886. /**
  17887. * Add a submesh to the manager in order to render it this frame
  17888. * @param subMesh The submesh to dispatch
  17889. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17890. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17891. */
  17892. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17893. /**
  17894. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17895. * This allowed control for front to back rendering or reversly depending of the special needs.
  17896. *
  17897. * @param renderingGroupId The rendering group id corresponding to its index
  17898. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17899. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17900. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17901. */
  17902. 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;
  17903. /**
  17904. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17905. *
  17906. * @param renderingGroupId The rendering group id corresponding to its index
  17907. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17908. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17909. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17910. */
  17911. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17912. /**
  17913. * Gets the current auto clear configuration for one rendering group of the rendering
  17914. * manager.
  17915. * @param index the rendering group index to get the information for
  17916. * @returns The auto clear setup for the requested rendering group
  17917. */
  17918. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17919. }
  17920. }
  17921. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17922. import { Observable } from "babylonjs/Misc/observable";
  17923. import { SmartArray } from "babylonjs/Misc/smartArray";
  17924. import { Nullable } from "babylonjs/types";
  17925. import { Camera } from "babylonjs/Cameras/camera";
  17926. import { Scene } from "babylonjs/scene";
  17927. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17928. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17932. import { Texture } from "babylonjs/Materials/Textures/texture";
  17933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17934. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17935. import { Engine } from "babylonjs/Engines/engine";
  17936. /**
  17937. * This Helps creating a texture that will be created from a camera in your scene.
  17938. * It is basically a dynamic texture that could be used to create special effects for instance.
  17939. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17940. */
  17941. export class RenderTargetTexture extends Texture {
  17942. isCube: boolean;
  17943. /**
  17944. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17945. */
  17946. static readonly REFRESHRATE_RENDER_ONCE: number;
  17947. /**
  17948. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17949. */
  17950. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17951. /**
  17952. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17953. * the central point of your effect and can save a lot of performances.
  17954. */
  17955. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17956. /**
  17957. * Use this predicate to dynamically define the list of mesh you want to render.
  17958. * If set, the renderList property will be overwritten.
  17959. */
  17960. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17961. private _renderList;
  17962. /**
  17963. * Use this list to define the list of mesh you want to render.
  17964. */
  17965. renderList: Nullable<Array<AbstractMesh>>;
  17966. private _hookArray;
  17967. /**
  17968. * Define if particles should be rendered in your texture.
  17969. */
  17970. renderParticles: boolean;
  17971. /**
  17972. * Define if sprites should be rendered in your texture.
  17973. */
  17974. renderSprites: boolean;
  17975. /**
  17976. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17977. */
  17978. coordinatesMode: number;
  17979. /**
  17980. * Define the camera used to render the texture.
  17981. */
  17982. activeCamera: Nullable<Camera>;
  17983. /**
  17984. * Override the render function of the texture with your own one.
  17985. */
  17986. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17987. /**
  17988. * Define if camera post processes should be use while rendering the texture.
  17989. */
  17990. useCameraPostProcesses: boolean;
  17991. /**
  17992. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17993. */
  17994. ignoreCameraViewport: boolean;
  17995. private _postProcessManager;
  17996. private _postProcesses;
  17997. private _resizeObserver;
  17998. /**
  17999. * An event triggered when the texture is unbind.
  18000. */
  18001. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18002. /**
  18003. * An event triggered when the texture is unbind.
  18004. */
  18005. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18006. private _onAfterUnbindObserver;
  18007. /**
  18008. * Set a after unbind callback in the texture.
  18009. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18010. */
  18011. onAfterUnbind: () => void;
  18012. /**
  18013. * An event triggered before rendering the texture
  18014. */
  18015. onBeforeRenderObservable: Observable<number>;
  18016. private _onBeforeRenderObserver;
  18017. /**
  18018. * Set a before render callback in the texture.
  18019. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18020. */
  18021. onBeforeRender: (faceIndex: number) => void;
  18022. /**
  18023. * An event triggered after rendering the texture
  18024. */
  18025. onAfterRenderObservable: Observable<number>;
  18026. private _onAfterRenderObserver;
  18027. /**
  18028. * Set a after render callback in the texture.
  18029. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18030. */
  18031. onAfterRender: (faceIndex: number) => void;
  18032. /**
  18033. * An event triggered after the texture clear
  18034. */
  18035. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18036. private _onClearObserver;
  18037. /**
  18038. * Set a clear callback in the texture.
  18039. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18040. */
  18041. onClear: (Engine: Engine) => void;
  18042. /**
  18043. * Define the clear color of the Render Target if it should be different from the scene.
  18044. */
  18045. clearColor: Color4;
  18046. protected _size: number | {
  18047. width: number;
  18048. height: number;
  18049. };
  18050. protected _initialSizeParameter: number | {
  18051. width: number;
  18052. height: number;
  18053. } | {
  18054. ratio: number;
  18055. };
  18056. protected _sizeRatio: Nullable<number>;
  18057. /** @hidden */
  18058. _generateMipMaps: boolean;
  18059. protected _renderingManager: RenderingManager;
  18060. /** @hidden */
  18061. _waitingRenderList: string[];
  18062. protected _doNotChangeAspectRatio: boolean;
  18063. protected _currentRefreshId: number;
  18064. protected _refreshRate: number;
  18065. protected _textureMatrix: Matrix;
  18066. protected _samples: number;
  18067. protected _renderTargetOptions: RenderTargetCreationOptions;
  18068. /**
  18069. * Gets render target creation options that were used.
  18070. */
  18071. readonly renderTargetOptions: RenderTargetCreationOptions;
  18072. protected _engine: Engine;
  18073. protected _onRatioRescale(): void;
  18074. /**
  18075. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18076. * It must define where the camera used to render the texture is set
  18077. */
  18078. boundingBoxPosition: Vector3;
  18079. private _boundingBoxSize;
  18080. /**
  18081. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18082. * When defined, the cubemap will switch to local mode
  18083. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18084. * @example https://www.babylonjs-playground.com/#RNASML
  18085. */
  18086. boundingBoxSize: Vector3;
  18087. /**
  18088. * In case the RTT has been created with a depth texture, get the associated
  18089. * depth texture.
  18090. * Otherwise, return null.
  18091. */
  18092. depthStencilTexture: Nullable<InternalTexture>;
  18093. /**
  18094. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18095. * or used a shadow, depth texture...
  18096. * @param name The friendly name of the texture
  18097. * @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)
  18098. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18099. * @param generateMipMaps True if mip maps need to be generated after render.
  18100. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18101. * @param type The type of the buffer in the RTT (int, half float, float...)
  18102. * @param isCube True if a cube texture needs to be created
  18103. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18104. * @param generateDepthBuffer True to generate a depth buffer
  18105. * @param generateStencilBuffer True to generate a stencil buffer
  18106. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18107. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18108. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18109. */
  18110. constructor(name: string, size: number | {
  18111. width: number;
  18112. height: number;
  18113. } | {
  18114. ratio: number;
  18115. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18116. /**
  18117. * Creates a depth stencil texture.
  18118. * This is only available in WebGL 2 or with the depth texture extension available.
  18119. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18120. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18121. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18122. */
  18123. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18124. private _processSizeParameter;
  18125. /**
  18126. * Define the number of samples to use in case of MSAA.
  18127. * It defaults to one meaning no MSAA has been enabled.
  18128. */
  18129. samples: number;
  18130. /**
  18131. * Resets the refresh counter of the texture and start bak from scratch.
  18132. * Could be useful to regenerate the texture if it is setup to render only once.
  18133. */
  18134. resetRefreshCounter(): void;
  18135. /**
  18136. * Define the refresh rate of the texture or the rendering frequency.
  18137. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18138. */
  18139. refreshRate: number;
  18140. /**
  18141. * Adds a post process to the render target rendering passes.
  18142. * @param postProcess define the post process to add
  18143. */
  18144. addPostProcess(postProcess: PostProcess): void;
  18145. /**
  18146. * Clear all the post processes attached to the render target
  18147. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18148. */
  18149. clearPostProcesses(dispose?: boolean): void;
  18150. /**
  18151. * Remove one of the post process from the list of attached post processes to the texture
  18152. * @param postProcess define the post process to remove from the list
  18153. */
  18154. removePostProcess(postProcess: PostProcess): void;
  18155. /** @hidden */
  18156. _shouldRender(): boolean;
  18157. /**
  18158. * Gets the actual render size of the texture.
  18159. * @returns the width of the render size
  18160. */
  18161. getRenderSize(): number;
  18162. /**
  18163. * Gets the actual render width of the texture.
  18164. * @returns the width of the render size
  18165. */
  18166. getRenderWidth(): number;
  18167. /**
  18168. * Gets the actual render height of the texture.
  18169. * @returns the height of the render size
  18170. */
  18171. getRenderHeight(): number;
  18172. /**
  18173. * Get if the texture can be rescaled or not.
  18174. */
  18175. readonly canRescale: boolean;
  18176. /**
  18177. * Resize the texture using a ratio.
  18178. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18179. */
  18180. scale(ratio: number): void;
  18181. /**
  18182. * Get the texture reflection matrix used to rotate/transform the reflection.
  18183. * @returns the reflection matrix
  18184. */
  18185. getReflectionTextureMatrix(): Matrix;
  18186. /**
  18187. * Resize the texture to a new desired size.
  18188. * Be carrefull as it will recreate all the data in the new texture.
  18189. * @param size Define the new size. It can be:
  18190. * - a number for squared texture,
  18191. * - an object containing { width: number, height: number }
  18192. * - or an object containing a ratio { ratio: number }
  18193. */
  18194. resize(size: number | {
  18195. width: number;
  18196. height: number;
  18197. } | {
  18198. ratio: number;
  18199. }): void;
  18200. /**
  18201. * Renders all the objects from the render list into the texture.
  18202. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18203. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18204. */
  18205. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18206. private _bestReflectionRenderTargetDimension;
  18207. /**
  18208. * @hidden
  18209. * @param faceIndex face index to bind to if this is a cubetexture
  18210. */
  18211. _bindFrameBuffer(faceIndex?: number): void;
  18212. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18213. private renderToTarget;
  18214. /**
  18215. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18216. * This allowed control for front to back rendering or reversly depending of the special needs.
  18217. *
  18218. * @param renderingGroupId The rendering group id corresponding to its index
  18219. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18220. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18221. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18222. */
  18223. 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;
  18224. /**
  18225. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18226. *
  18227. * @param renderingGroupId The rendering group id corresponding to its index
  18228. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18229. */
  18230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18231. /**
  18232. * Clones the texture.
  18233. * @returns the cloned texture
  18234. */
  18235. clone(): RenderTargetTexture;
  18236. /**
  18237. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18238. * @returns The JSON representation of the texture
  18239. */
  18240. serialize(): any;
  18241. /**
  18242. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18243. */
  18244. disposeFramebufferObjects(): void;
  18245. /**
  18246. * Dispose the texture and release its associated resources.
  18247. */
  18248. dispose(): void;
  18249. /** @hidden */
  18250. _rebuild(): void;
  18251. /**
  18252. * Clear the info related to rendering groups preventing retention point in material dispose.
  18253. */
  18254. freeRenderingGroups(): void;
  18255. /**
  18256. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18257. * @returns the view count
  18258. */
  18259. getViewCount(): number;
  18260. }
  18261. }
  18262. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18263. import { Scene } from "babylonjs/scene";
  18264. import { Plane } from "babylonjs/Maths/math";
  18265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18266. /**
  18267. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18268. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18269. * You can then easily use it as a reflectionTexture on a flat surface.
  18270. * In case the surface is not a plane, please consider relying on reflection probes.
  18271. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18272. */
  18273. export class MirrorTexture extends RenderTargetTexture {
  18274. private scene;
  18275. /**
  18276. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18277. * 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.
  18278. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18279. */
  18280. mirrorPlane: Plane;
  18281. /**
  18282. * Define the blur ratio used to blur the reflection if needed.
  18283. */
  18284. blurRatio: number;
  18285. /**
  18286. * Define the adaptive blur kernel used to blur the reflection if needed.
  18287. * This will autocompute the closest best match for the `blurKernel`
  18288. */
  18289. adaptiveBlurKernel: number;
  18290. /**
  18291. * Define the blur kernel used to blur the reflection if needed.
  18292. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18293. */
  18294. blurKernel: number;
  18295. /**
  18296. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18297. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18298. */
  18299. blurKernelX: number;
  18300. /**
  18301. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18302. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18303. */
  18304. blurKernelY: number;
  18305. private _autoComputeBlurKernel;
  18306. protected _onRatioRescale(): void;
  18307. private _updateGammaSpace;
  18308. private _imageProcessingConfigChangeObserver;
  18309. private _transformMatrix;
  18310. private _mirrorMatrix;
  18311. private _savedViewMatrix;
  18312. private _blurX;
  18313. private _blurY;
  18314. private _adaptiveBlurKernel;
  18315. private _blurKernelX;
  18316. private _blurKernelY;
  18317. private _blurRatio;
  18318. /**
  18319. * Instantiates a Mirror Texture.
  18320. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18321. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18322. * You can then easily use it as a reflectionTexture on a flat surface.
  18323. * In case the surface is not a plane, please consider relying on reflection probes.
  18324. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18325. * @param name
  18326. * @param size
  18327. * @param scene
  18328. * @param generateMipMaps
  18329. * @param type
  18330. * @param samplingMode
  18331. * @param generateDepthBuffer
  18332. */
  18333. constructor(name: string, size: number | {
  18334. width: number;
  18335. height: number;
  18336. } | {
  18337. ratio: number;
  18338. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18339. private _preparePostProcesses;
  18340. /**
  18341. * Clone the mirror texture.
  18342. * @returns the cloned texture
  18343. */
  18344. clone(): MirrorTexture;
  18345. /**
  18346. * Serialize the texture to a JSON representation you could use in Parse later on
  18347. * @returns the serialized JSON representation
  18348. */
  18349. serialize(): any;
  18350. /**
  18351. * Dispose the texture and release its associated resources.
  18352. */
  18353. dispose(): void;
  18354. }
  18355. }
  18356. declare module "babylonjs/Materials/Textures/texture" {
  18357. import { Observable } from "babylonjs/Misc/observable";
  18358. import { Nullable } from "babylonjs/types";
  18359. import { Scene } from "babylonjs/scene";
  18360. import { Matrix } from "babylonjs/Maths/math";
  18361. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18362. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18363. /**
  18364. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18365. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18366. */
  18367. export class Texture extends BaseTexture {
  18368. /** @hidden */
  18369. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18370. /** @hidden */
  18371. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18372. /** @hidden */
  18373. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18374. /** nearest is mag = nearest and min = nearest and mip = linear */
  18375. static readonly NEAREST_SAMPLINGMODE: number;
  18376. /** nearest is mag = nearest and min = nearest and mip = linear */
  18377. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18379. static readonly BILINEAR_SAMPLINGMODE: number;
  18380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18381. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18382. /** Trilinear is mag = linear and min = linear and mip = linear */
  18383. static readonly TRILINEAR_SAMPLINGMODE: number;
  18384. /** Trilinear is mag = linear and min = linear and mip = linear */
  18385. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18386. /** mag = nearest and min = nearest and mip = nearest */
  18387. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18388. /** mag = nearest and min = linear and mip = nearest */
  18389. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18390. /** mag = nearest and min = linear and mip = linear */
  18391. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18392. /** mag = nearest and min = linear and mip = none */
  18393. static readonly NEAREST_LINEAR: number;
  18394. /** mag = nearest and min = nearest and mip = none */
  18395. static readonly NEAREST_NEAREST: number;
  18396. /** mag = linear and min = nearest and mip = nearest */
  18397. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18398. /** mag = linear and min = nearest and mip = linear */
  18399. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18400. /** mag = linear and min = linear and mip = none */
  18401. static readonly LINEAR_LINEAR: number;
  18402. /** mag = linear and min = nearest and mip = none */
  18403. static readonly LINEAR_NEAREST: number;
  18404. /** Explicit coordinates mode */
  18405. static readonly EXPLICIT_MODE: number;
  18406. /** Spherical coordinates mode */
  18407. static readonly SPHERICAL_MODE: number;
  18408. /** Planar coordinates mode */
  18409. static readonly PLANAR_MODE: number;
  18410. /** Cubic coordinates mode */
  18411. static readonly CUBIC_MODE: number;
  18412. /** Projection coordinates mode */
  18413. static readonly PROJECTION_MODE: number;
  18414. /** Inverse Cubic coordinates mode */
  18415. static readonly SKYBOX_MODE: number;
  18416. /** Inverse Cubic coordinates mode */
  18417. static readonly INVCUBIC_MODE: number;
  18418. /** Equirectangular coordinates mode */
  18419. static readonly EQUIRECTANGULAR_MODE: number;
  18420. /** Equirectangular Fixed coordinates mode */
  18421. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18422. /** Equirectangular Fixed Mirrored coordinates mode */
  18423. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18424. /** Texture is not repeating outside of 0..1 UVs */
  18425. static readonly CLAMP_ADDRESSMODE: number;
  18426. /** Texture is repeating outside of 0..1 UVs */
  18427. static readonly WRAP_ADDRESSMODE: number;
  18428. /** Texture is repeating and mirrored */
  18429. static readonly MIRROR_ADDRESSMODE: number;
  18430. /**
  18431. * 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
  18432. */
  18433. static UseSerializedUrlIfAny: boolean;
  18434. /**
  18435. * Define the url of the texture.
  18436. */
  18437. url: Nullable<string>;
  18438. /**
  18439. * Define an offset on the texture to offset the u coordinates of the UVs
  18440. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18441. */
  18442. uOffset: number;
  18443. /**
  18444. * Define an offset on the texture to offset the v coordinates of the UVs
  18445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18446. */
  18447. vOffset: number;
  18448. /**
  18449. * Define an offset on the texture to scale the u coordinates of the UVs
  18450. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18451. */
  18452. uScale: number;
  18453. /**
  18454. * Define an offset on the texture to scale the v coordinates of the UVs
  18455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18456. */
  18457. vScale: number;
  18458. /**
  18459. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18460. * @see http://doc.babylonjs.com/how_to/more_materials
  18461. */
  18462. uAng: number;
  18463. /**
  18464. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18465. * @see http://doc.babylonjs.com/how_to/more_materials
  18466. */
  18467. vAng: number;
  18468. /**
  18469. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18470. * @see http://doc.babylonjs.com/how_to/more_materials
  18471. */
  18472. wAng: number;
  18473. /**
  18474. * Defines the center of rotation (U)
  18475. */
  18476. uRotationCenter: number;
  18477. /**
  18478. * Defines the center of rotation (V)
  18479. */
  18480. vRotationCenter: number;
  18481. /**
  18482. * Defines the center of rotation (W)
  18483. */
  18484. wRotationCenter: number;
  18485. /**
  18486. * Are mip maps generated for this texture or not.
  18487. */
  18488. readonly noMipmap: boolean;
  18489. /**
  18490. * List of inspectable custom properties (used by the Inspector)
  18491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18492. */
  18493. inspectableCustomProperties: IInspectable[];
  18494. private _noMipmap;
  18495. /** @hidden */
  18496. _invertY: boolean;
  18497. private _rowGenerationMatrix;
  18498. private _cachedTextureMatrix;
  18499. private _projectionModeMatrix;
  18500. private _t0;
  18501. private _t1;
  18502. private _t2;
  18503. private _cachedUOffset;
  18504. private _cachedVOffset;
  18505. private _cachedUScale;
  18506. private _cachedVScale;
  18507. private _cachedUAng;
  18508. private _cachedVAng;
  18509. private _cachedWAng;
  18510. private _cachedProjectionMatrixId;
  18511. private _cachedCoordinatesMode;
  18512. /** @hidden */
  18513. protected _initialSamplingMode: number;
  18514. /** @hidden */
  18515. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18516. private _deleteBuffer;
  18517. protected _format: Nullable<number>;
  18518. private _delayedOnLoad;
  18519. private _delayedOnError;
  18520. /**
  18521. * Observable triggered once the texture has been loaded.
  18522. */
  18523. onLoadObservable: Observable<Texture>;
  18524. protected _isBlocking: boolean;
  18525. /**
  18526. * Is the texture preventing material to render while loading.
  18527. * If false, a default texture will be used instead of the loading one during the preparation step.
  18528. */
  18529. isBlocking: boolean;
  18530. /**
  18531. * Get the current sampling mode associated with the texture.
  18532. */
  18533. readonly samplingMode: number;
  18534. /**
  18535. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18536. */
  18537. readonly invertY: boolean;
  18538. /**
  18539. * Instantiates a new texture.
  18540. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18541. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18542. * @param url define the url of the picture to load as a texture
  18543. * @param scene define the scene the texture will belong to
  18544. * @param noMipmap define if the texture will require mip maps or not
  18545. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18546. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18547. * @param onLoad define a callback triggered when the texture has been loaded
  18548. * @param onError define a callback triggered when an error occurred during the loading session
  18549. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18550. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18551. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18552. */
  18553. 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);
  18554. /**
  18555. * Update the url (and optional buffer) of this texture if url was null during construction.
  18556. * @param url the url of the texture
  18557. * @param buffer the buffer of the texture (defaults to null)
  18558. * @param onLoad callback called when the texture is loaded (defaults to null)
  18559. */
  18560. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18561. /**
  18562. * Finish the loading sequence of a texture flagged as delayed load.
  18563. * @hidden
  18564. */
  18565. delayLoad(): void;
  18566. private _prepareRowForTextureGeneration;
  18567. /**
  18568. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18569. * @returns the transform matrix of the texture.
  18570. */
  18571. getTextureMatrix(): Matrix;
  18572. /**
  18573. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18574. * @returns The reflection texture transform
  18575. */
  18576. getReflectionTextureMatrix(): Matrix;
  18577. /**
  18578. * Clones the texture.
  18579. * @returns the cloned texture
  18580. */
  18581. clone(): Texture;
  18582. /**
  18583. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18584. * @returns The JSON representation of the texture
  18585. */
  18586. serialize(): any;
  18587. /**
  18588. * Get the current class name of the texture useful for serialization or dynamic coding.
  18589. * @returns "Texture"
  18590. */
  18591. getClassName(): string;
  18592. /**
  18593. * Dispose the texture and release its associated resources.
  18594. */
  18595. dispose(): void;
  18596. /**
  18597. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18598. * @param parsedTexture Define the JSON representation of the texture
  18599. * @param scene Define the scene the parsed texture should be instantiated in
  18600. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18601. * @returns The parsed texture if successful
  18602. */
  18603. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18604. /**
  18605. * Creates a texture from its base 64 representation.
  18606. * @param data Define the base64 payload without the data: prefix
  18607. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18608. * @param scene Define the scene the texture should belong to
  18609. * @param noMipmap Forces the texture to not create mip map information if true
  18610. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18611. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18612. * @param onLoad define a callback triggered when the texture has been loaded
  18613. * @param onError define a callback triggered when an error occurred during the loading session
  18614. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18615. * @returns the created texture
  18616. */
  18617. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18618. /**
  18619. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18620. * @param data Define the base64 payload without the data: prefix
  18621. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18622. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18623. * @param scene Define the scene the texture should belong to
  18624. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18625. * @param noMipmap Forces the texture to not create mip map information if true
  18626. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18627. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18628. * @param onLoad define a callback triggered when the texture has been loaded
  18629. * @param onError define a callback triggered when an error occurred during the loading session
  18630. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18631. * @returns the created texture
  18632. */
  18633. 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;
  18634. }
  18635. }
  18636. declare module "babylonjs/Materials/Textures/rawTexture" {
  18637. import { Scene } from "babylonjs/scene";
  18638. import { Texture } from "babylonjs/Materials/Textures/texture";
  18639. /**
  18640. * Raw texture can help creating a texture directly from an array of data.
  18641. * This can be super useful if you either get the data from an uncompressed source or
  18642. * if you wish to create your texture pixel by pixel.
  18643. */
  18644. export class RawTexture extends Texture {
  18645. /**
  18646. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18647. */
  18648. format: number;
  18649. private _engine;
  18650. /**
  18651. * Instantiates a new RawTexture.
  18652. * Raw texture can help creating a texture directly from an array of data.
  18653. * This can be super useful if you either get the data from an uncompressed source or
  18654. * if you wish to create your texture pixel by pixel.
  18655. * @param data define the array of data to use to create the texture
  18656. * @param width define the width of the texture
  18657. * @param height define the height of the texture
  18658. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18659. * @param scene define the scene the texture belongs to
  18660. * @param generateMipMaps define whether mip maps should be generated or not
  18661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18663. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18664. */
  18665. constructor(data: ArrayBufferView, width: number, height: number,
  18666. /**
  18667. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18668. */
  18669. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18670. /**
  18671. * Updates the texture underlying data.
  18672. * @param data Define the new data of the texture
  18673. */
  18674. update(data: ArrayBufferView): void;
  18675. /**
  18676. * Creates a luminance texture from some data.
  18677. * @param data Define the texture data
  18678. * @param width Define the width of the texture
  18679. * @param height Define the height of the texture
  18680. * @param scene Define the scene the texture belongs to
  18681. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18684. * @returns the luminance texture
  18685. */
  18686. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18687. /**
  18688. * Creates a luminance alpha texture from some data.
  18689. * @param data Define the texture data
  18690. * @param width Define the width of the texture
  18691. * @param height Define the height of the texture
  18692. * @param scene Define the scene the texture belongs to
  18693. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18694. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18695. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18696. * @returns the luminance alpha texture
  18697. */
  18698. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18699. /**
  18700. * Creates an alpha texture from some data.
  18701. * @param data Define the texture data
  18702. * @param width Define the width of the texture
  18703. * @param height Define the height of the texture
  18704. * @param scene Define the scene the texture belongs to
  18705. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18706. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18707. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18708. * @returns the alpha texture
  18709. */
  18710. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18711. /**
  18712. * Creates a RGB texture from some data.
  18713. * @param data Define the texture data
  18714. * @param width Define the width of the texture
  18715. * @param height Define the height of the texture
  18716. * @param scene Define the scene the texture belongs to
  18717. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18718. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18719. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18720. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18721. * @returns the RGB alpha texture
  18722. */
  18723. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18724. /**
  18725. * Creates a RGBA texture from some data.
  18726. * @param data Define the texture data
  18727. * @param width Define the width of the texture
  18728. * @param height Define the height of the texture
  18729. * @param scene Define the scene the texture belongs to
  18730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18733. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18734. * @returns the RGBA texture
  18735. */
  18736. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18737. /**
  18738. * Creates a R texture from some data.
  18739. * @param data Define the texture data
  18740. * @param width Define the width of the texture
  18741. * @param height Define the height of the texture
  18742. * @param scene Define the scene the texture belongs to
  18743. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18744. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18745. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18746. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18747. * @returns the R texture
  18748. */
  18749. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18750. }
  18751. }
  18752. declare module "babylonjs/Animations/runtimeAnimation" {
  18753. import { Animation } from "babylonjs/Animations/animation";
  18754. import { Animatable } from "babylonjs/Animations/animatable";
  18755. import { Scene } from "babylonjs/scene";
  18756. /**
  18757. * Defines a runtime animation
  18758. */
  18759. export class RuntimeAnimation {
  18760. private _events;
  18761. /**
  18762. * The current frame of the runtime animation
  18763. */
  18764. private _currentFrame;
  18765. /**
  18766. * The animation used by the runtime animation
  18767. */
  18768. private _animation;
  18769. /**
  18770. * The target of the runtime animation
  18771. */
  18772. private _target;
  18773. /**
  18774. * The initiating animatable
  18775. */
  18776. private _host;
  18777. /**
  18778. * The original value of the runtime animation
  18779. */
  18780. private _originalValue;
  18781. /**
  18782. * The original blend value of the runtime animation
  18783. */
  18784. private _originalBlendValue;
  18785. /**
  18786. * The offsets cache of the runtime animation
  18787. */
  18788. private _offsetsCache;
  18789. /**
  18790. * The high limits cache of the runtime animation
  18791. */
  18792. private _highLimitsCache;
  18793. /**
  18794. * Specifies if the runtime animation has been stopped
  18795. */
  18796. private _stopped;
  18797. /**
  18798. * The blending factor of the runtime animation
  18799. */
  18800. private _blendingFactor;
  18801. /**
  18802. * The BabylonJS scene
  18803. */
  18804. private _scene;
  18805. /**
  18806. * The current value of the runtime animation
  18807. */
  18808. private _currentValue;
  18809. /** @hidden */
  18810. _workValue: any;
  18811. /**
  18812. * The active target of the runtime animation
  18813. */
  18814. private _activeTarget;
  18815. /**
  18816. * The target path of the runtime animation
  18817. */
  18818. private _targetPath;
  18819. /**
  18820. * The weight of the runtime animation
  18821. */
  18822. private _weight;
  18823. /**
  18824. * The ratio offset of the runtime animation
  18825. */
  18826. private _ratioOffset;
  18827. /**
  18828. * The previous delay of the runtime animation
  18829. */
  18830. private _previousDelay;
  18831. /**
  18832. * The previous ratio of the runtime animation
  18833. */
  18834. private _previousRatio;
  18835. /**
  18836. * Gets the current frame of the runtime animation
  18837. */
  18838. readonly currentFrame: number;
  18839. /**
  18840. * Gets the weight of the runtime animation
  18841. */
  18842. readonly weight: number;
  18843. /**
  18844. * Gets the current value of the runtime animation
  18845. */
  18846. readonly currentValue: any;
  18847. /**
  18848. * Gets the target path of the runtime animation
  18849. */
  18850. readonly targetPath: string;
  18851. /**
  18852. * Gets the actual target of the runtime animation
  18853. */
  18854. readonly target: any;
  18855. /**
  18856. * Create a new RuntimeAnimation object
  18857. * @param target defines the target of the animation
  18858. * @param animation defines the source animation object
  18859. * @param scene defines the hosting scene
  18860. * @param host defines the initiating Animatable
  18861. */
  18862. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18863. /**
  18864. * Gets the animation from the runtime animation
  18865. */
  18866. readonly animation: Animation;
  18867. /**
  18868. * Resets the runtime animation to the beginning
  18869. * @param restoreOriginal defines whether to restore the target property to the original value
  18870. */
  18871. reset(restoreOriginal?: boolean): void;
  18872. /**
  18873. * Specifies if the runtime animation is stopped
  18874. * @returns Boolean specifying if the runtime animation is stopped
  18875. */
  18876. isStopped(): boolean;
  18877. /**
  18878. * Disposes of the runtime animation
  18879. */
  18880. dispose(): void;
  18881. /**
  18882. * Interpolates the animation from the current frame
  18883. * @param currentFrame The frame to interpolate the animation to
  18884. * @param repeatCount The number of times that the animation should loop
  18885. * @param loopMode The type of looping mode to use
  18886. * @param offsetValue Animation offset value
  18887. * @param highLimitValue The high limit value
  18888. * @returns The interpolated value
  18889. */
  18890. private _interpolate;
  18891. /**
  18892. * Apply the interpolated value to the target
  18893. * @param currentValue defines the value computed by the animation
  18894. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18895. */
  18896. setValue(currentValue: any, weight?: number): void;
  18897. private _setValue;
  18898. /**
  18899. * Gets the loop pmode of the runtime animation
  18900. * @returns Loop Mode
  18901. */
  18902. private _getCorrectLoopMode;
  18903. /**
  18904. * Move the current animation to a given frame
  18905. * @param frame defines the frame to move to
  18906. */
  18907. goToFrame(frame: number): void;
  18908. /**
  18909. * @hidden Internal use only
  18910. */
  18911. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18912. /**
  18913. * Execute the current animation
  18914. * @param delay defines the delay to add to the current frame
  18915. * @param from defines the lower bound of the animation range
  18916. * @param to defines the upper bound of the animation range
  18917. * @param loop defines if the current animation must loop
  18918. * @param speedRatio defines the current speed ratio
  18919. * @param weight defines the weight of the animation (default is -1 so no weight)
  18920. * @param onLoop optional callback called when animation loops
  18921. * @returns a boolean indicating if the animation is running
  18922. */
  18923. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18924. }
  18925. }
  18926. declare module "babylonjs/Animations/animatable" {
  18927. import { Animation } from "babylonjs/Animations/animation";
  18928. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18929. import { Nullable } from "babylonjs/types";
  18930. import { Observable } from "babylonjs/Misc/observable";
  18931. import { Scene } from "babylonjs/scene";
  18932. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18933. import { Node } from "babylonjs/node";
  18934. /**
  18935. * Class used to store an actual running animation
  18936. */
  18937. export class Animatable {
  18938. /** defines the target object */
  18939. target: any;
  18940. /** defines the starting frame number (default is 0) */
  18941. fromFrame: number;
  18942. /** defines the ending frame number (default is 100) */
  18943. toFrame: number;
  18944. /** defines if the animation must loop (default is false) */
  18945. loopAnimation: boolean;
  18946. /** defines a callback to call when animation ends if it is not looping */
  18947. onAnimationEnd?: (() => void) | null | undefined;
  18948. /** defines a callback to call when animation loops */
  18949. onAnimationLoop?: (() => void) | null | undefined;
  18950. private _localDelayOffset;
  18951. private _pausedDelay;
  18952. private _runtimeAnimations;
  18953. private _paused;
  18954. private _scene;
  18955. private _speedRatio;
  18956. private _weight;
  18957. private _syncRoot;
  18958. /**
  18959. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18960. * This will only apply for non looping animation (default is true)
  18961. */
  18962. disposeOnEnd: boolean;
  18963. /**
  18964. * Gets a boolean indicating if the animation has started
  18965. */
  18966. animationStarted: boolean;
  18967. /**
  18968. * Observer raised when the animation ends
  18969. */
  18970. onAnimationEndObservable: Observable<Animatable>;
  18971. /**
  18972. * Observer raised when the animation loops
  18973. */
  18974. onAnimationLoopObservable: Observable<Animatable>;
  18975. /**
  18976. * Gets the root Animatable used to synchronize and normalize animations
  18977. */
  18978. readonly syncRoot: Animatable;
  18979. /**
  18980. * Gets the current frame of the first RuntimeAnimation
  18981. * Used to synchronize Animatables
  18982. */
  18983. readonly masterFrame: number;
  18984. /**
  18985. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18986. */
  18987. weight: number;
  18988. /**
  18989. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18990. */
  18991. speedRatio: number;
  18992. /**
  18993. * Creates a new Animatable
  18994. * @param scene defines the hosting scene
  18995. * @param target defines the target object
  18996. * @param fromFrame defines the starting frame number (default is 0)
  18997. * @param toFrame defines the ending frame number (default is 100)
  18998. * @param loopAnimation defines if the animation must loop (default is false)
  18999. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19000. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19001. * @param animations defines a group of animation to add to the new Animatable
  19002. * @param onAnimationLoop defines a callback to call when animation loops
  19003. */
  19004. constructor(scene: Scene,
  19005. /** defines the target object */
  19006. target: any,
  19007. /** defines the starting frame number (default is 0) */
  19008. fromFrame?: number,
  19009. /** defines the ending frame number (default is 100) */
  19010. toFrame?: number,
  19011. /** defines if the animation must loop (default is false) */
  19012. loopAnimation?: boolean, speedRatio?: number,
  19013. /** defines a callback to call when animation ends if it is not looping */
  19014. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19015. /** defines a callback to call when animation loops */
  19016. onAnimationLoop?: (() => void) | null | undefined);
  19017. /**
  19018. * Synchronize and normalize current Animatable with a source Animatable
  19019. * This is useful when using animation weights and when animations are not of the same length
  19020. * @param root defines the root Animatable to synchronize with
  19021. * @returns the current Animatable
  19022. */
  19023. syncWith(root: Animatable): Animatable;
  19024. /**
  19025. * Gets the list of runtime animations
  19026. * @returns an array of RuntimeAnimation
  19027. */
  19028. getAnimations(): RuntimeAnimation[];
  19029. /**
  19030. * Adds more animations to the current animatable
  19031. * @param target defines the target of the animations
  19032. * @param animations defines the new animations to add
  19033. */
  19034. appendAnimations(target: any, animations: Animation[]): void;
  19035. /**
  19036. * Gets the source animation for a specific property
  19037. * @param property defines the propertyu to look for
  19038. * @returns null or the source animation for the given property
  19039. */
  19040. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19041. /**
  19042. * Gets the runtime animation for a specific property
  19043. * @param property defines the propertyu to look for
  19044. * @returns null or the runtime animation for the given property
  19045. */
  19046. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19047. /**
  19048. * Resets the animatable to its original state
  19049. */
  19050. reset(): void;
  19051. /**
  19052. * Allows the animatable to blend with current running animations
  19053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19054. * @param blendingSpeed defines the blending speed to use
  19055. */
  19056. enableBlending(blendingSpeed: number): void;
  19057. /**
  19058. * Disable animation blending
  19059. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19060. */
  19061. disableBlending(): void;
  19062. /**
  19063. * Jump directly to a given frame
  19064. * @param frame defines the frame to jump to
  19065. */
  19066. goToFrame(frame: number): void;
  19067. /**
  19068. * Pause the animation
  19069. */
  19070. pause(): void;
  19071. /**
  19072. * Restart the animation
  19073. */
  19074. restart(): void;
  19075. private _raiseOnAnimationEnd;
  19076. /**
  19077. * Stop and delete the current animation
  19078. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19079. * @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)
  19080. */
  19081. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19082. /**
  19083. * Wait asynchronously for the animation to end
  19084. * @returns a promise which will be fullfilled when the animation ends
  19085. */
  19086. waitAsync(): Promise<Animatable>;
  19087. /** @hidden */
  19088. _animate(delay: number): boolean;
  19089. }
  19090. module "babylonjs/scene" {
  19091. interface Scene {
  19092. /** @hidden */
  19093. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19094. /** @hidden */
  19095. _processLateAnimationBindingsForMatrices(holder: {
  19096. totalWeight: number;
  19097. animations: RuntimeAnimation[];
  19098. originalValue: Matrix;
  19099. }): any;
  19100. /** @hidden */
  19101. _processLateAnimationBindingsForQuaternions(holder: {
  19102. totalWeight: number;
  19103. animations: RuntimeAnimation[];
  19104. originalValue: Quaternion;
  19105. }, refQuaternion: Quaternion): Quaternion;
  19106. /** @hidden */
  19107. _processLateAnimationBindings(): void;
  19108. /**
  19109. * Will start the animation sequence of a given target
  19110. * @param target defines the target
  19111. * @param from defines from which frame should animation start
  19112. * @param to defines until which frame should animation run.
  19113. * @param weight defines the weight to apply to the animation (1.0 by default)
  19114. * @param loop defines if the animation loops
  19115. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19116. * @param onAnimationEnd defines the function to be executed when the animation ends
  19117. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19119. * @param onAnimationLoop defines the callback to call when an animation loops
  19120. * @returns the animatable object created for this animation
  19121. */
  19122. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19123. /**
  19124. * Will start the animation sequence of a given target
  19125. * @param target defines the target
  19126. * @param from defines from which frame should animation start
  19127. * @param to defines until which frame should animation run.
  19128. * @param loop defines if the animation loops
  19129. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19130. * @param onAnimationEnd defines the function to be executed when the animation ends
  19131. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19132. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19133. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19134. * @param onAnimationLoop defines the callback to call when an animation loops
  19135. * @returns the animatable object created for this animation
  19136. */
  19137. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19138. /**
  19139. * Will start the animation sequence of a given target and its hierarchy
  19140. * @param target defines the target
  19141. * @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.
  19142. * @param from defines from which frame should animation start
  19143. * @param to defines until which frame should animation run.
  19144. * @param loop defines if the animation loops
  19145. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19146. * @param onAnimationEnd defines the function to be executed when the animation ends
  19147. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19148. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19149. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19150. * @param onAnimationLoop defines the callback to call when an animation loops
  19151. * @returns the list of created animatables
  19152. */
  19153. 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[];
  19154. /**
  19155. * Begin a new animation on a given node
  19156. * @param target defines the target where the animation will take place
  19157. * @param animations defines the list of animations to start
  19158. * @param from defines the initial value
  19159. * @param to defines the final value
  19160. * @param loop defines if you want animation to loop (off by default)
  19161. * @param speedRatio defines the speed ratio to apply to all animations
  19162. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19163. * @param onAnimationLoop defines the callback to call when an animation loops
  19164. * @returns the list of created animatables
  19165. */
  19166. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19167. /**
  19168. * Begin a new animation on a given node and its hierarchy
  19169. * @param target defines the root node where the animation will take place
  19170. * @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.
  19171. * @param animations defines the list of animations to start
  19172. * @param from defines the initial value
  19173. * @param to defines the final value
  19174. * @param loop defines if you want animation to loop (off by default)
  19175. * @param speedRatio defines the speed ratio to apply to all animations
  19176. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19177. * @param onAnimationLoop defines the callback to call when an animation loops
  19178. * @returns the list of animatables created for all nodes
  19179. */
  19180. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19181. /**
  19182. * Gets the animatable associated with a specific target
  19183. * @param target defines the target of the animatable
  19184. * @returns the required animatable if found
  19185. */
  19186. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19187. /**
  19188. * Gets all animatables associated with a given target
  19189. * @param target defines the target to look animatables for
  19190. * @returns an array of Animatables
  19191. */
  19192. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19193. /**
  19194. * Will stop the animation of the given target
  19195. * @param target - the target
  19196. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19197. * @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)
  19198. */
  19199. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19200. /**
  19201. * Stops and removes all animations that have been applied to the scene
  19202. */
  19203. stopAllAnimations(): void;
  19204. }
  19205. }
  19206. module "babylonjs/Bones/bone" {
  19207. interface Bone {
  19208. /**
  19209. * Copy an animation range from another bone
  19210. * @param source defines the source bone
  19211. * @param rangeName defines the range name to copy
  19212. * @param frameOffset defines the frame offset
  19213. * @param rescaleAsRequired defines if rescaling must be applied if required
  19214. * @param skelDimensionsRatio defines the scaling ratio
  19215. * @returns true if operation was successful
  19216. */
  19217. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19218. }
  19219. }
  19220. }
  19221. declare module "babylonjs/Bones/skeleton" {
  19222. import { Bone } from "babylonjs/Bones/bone";
  19223. import { IAnimatable } from "babylonjs/Misc/tools";
  19224. import { Observable } from "babylonjs/Misc/observable";
  19225. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19226. import { Scene } from "babylonjs/scene";
  19227. import { Nullable } from "babylonjs/types";
  19228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19230. import { Animatable } from "babylonjs/Animations/animatable";
  19231. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19232. import { Animation } from "babylonjs/Animations/animation";
  19233. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19235. /**
  19236. * Class used to handle skinning animations
  19237. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19238. */
  19239. export class Skeleton implements IAnimatable {
  19240. /** defines the skeleton name */
  19241. name: string;
  19242. /** defines the skeleton Id */
  19243. id: string;
  19244. /**
  19245. * Defines the list of child bones
  19246. */
  19247. bones: Bone[];
  19248. /**
  19249. * Defines an estimate of the dimension of the skeleton at rest
  19250. */
  19251. dimensionsAtRest: Vector3;
  19252. /**
  19253. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19254. */
  19255. needInitialSkinMatrix: boolean;
  19256. /**
  19257. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19258. */
  19259. overrideMesh: Nullable<AbstractMesh>;
  19260. /**
  19261. * Gets the list of animations attached to this skeleton
  19262. */
  19263. animations: Array<Animation>;
  19264. private _scene;
  19265. private _isDirty;
  19266. private _transformMatrices;
  19267. private _transformMatrixTexture;
  19268. private _meshesWithPoseMatrix;
  19269. private _animatables;
  19270. private _identity;
  19271. private _synchronizedWithMesh;
  19272. private _ranges;
  19273. private _lastAbsoluteTransformsUpdateId;
  19274. private _canUseTextureForBones;
  19275. private _uniqueId;
  19276. /** @hidden */
  19277. _numBonesWithLinkedTransformNode: number;
  19278. /**
  19279. * Specifies if the skeleton should be serialized
  19280. */
  19281. doNotSerialize: boolean;
  19282. private _useTextureToStoreBoneMatrices;
  19283. /**
  19284. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19285. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19286. */
  19287. useTextureToStoreBoneMatrices: boolean;
  19288. private _animationPropertiesOverride;
  19289. /**
  19290. * Gets or sets the animation properties override
  19291. */
  19292. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19293. /**
  19294. * List of inspectable custom properties (used by the Inspector)
  19295. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19296. */
  19297. inspectableCustomProperties: IInspectable[];
  19298. /**
  19299. * An observable triggered before computing the skeleton's matrices
  19300. */
  19301. onBeforeComputeObservable: Observable<Skeleton>;
  19302. /**
  19303. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19304. */
  19305. readonly isUsingTextureForMatrices: boolean;
  19306. /**
  19307. * Gets the unique ID of this skeleton
  19308. */
  19309. readonly uniqueId: number;
  19310. /**
  19311. * Creates a new skeleton
  19312. * @param name defines the skeleton name
  19313. * @param id defines the skeleton Id
  19314. * @param scene defines the hosting scene
  19315. */
  19316. constructor(
  19317. /** defines the skeleton name */
  19318. name: string,
  19319. /** defines the skeleton Id */
  19320. id: string, scene: Scene);
  19321. /**
  19322. * Gets the current object class name.
  19323. * @return the class name
  19324. */
  19325. getClassName(): string;
  19326. /**
  19327. * Returns an array containing the root bones
  19328. * @returns an array containing the root bones
  19329. */
  19330. getChildren(): Array<Bone>;
  19331. /**
  19332. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19333. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19334. * @returns a Float32Array containing matrices data
  19335. */
  19336. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19337. /**
  19338. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19339. * @returns a raw texture containing the data
  19340. */
  19341. getTransformMatrixTexture(): Nullable<RawTexture>;
  19342. /**
  19343. * Gets the current hosting scene
  19344. * @returns a scene object
  19345. */
  19346. getScene(): Scene;
  19347. /**
  19348. * Gets a string representing the current skeleton data
  19349. * @param fullDetails defines a boolean indicating if we want a verbose version
  19350. * @returns a string representing the current skeleton data
  19351. */
  19352. toString(fullDetails?: boolean): string;
  19353. /**
  19354. * Get bone's index searching by name
  19355. * @param name defines bone's name to search for
  19356. * @return the indice of the bone. Returns -1 if not found
  19357. */
  19358. getBoneIndexByName(name: string): number;
  19359. /**
  19360. * Creater a new animation range
  19361. * @param name defines the name of the range
  19362. * @param from defines the start key
  19363. * @param to defines the end key
  19364. */
  19365. createAnimationRange(name: string, from: number, to: number): void;
  19366. /**
  19367. * Delete a specific animation range
  19368. * @param name defines the name of the range
  19369. * @param deleteFrames defines if frames must be removed as well
  19370. */
  19371. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19372. /**
  19373. * Gets a specific animation range
  19374. * @param name defines the name of the range to look for
  19375. * @returns the requested animation range or null if not found
  19376. */
  19377. getAnimationRange(name: string): Nullable<AnimationRange>;
  19378. /**
  19379. * Gets the list of all animation ranges defined on this skeleton
  19380. * @returns an array
  19381. */
  19382. getAnimationRanges(): Nullable<AnimationRange>[];
  19383. /**
  19384. * Copy animation range from a source skeleton.
  19385. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19386. * @param source defines the source skeleton
  19387. * @param name defines the name of the range to copy
  19388. * @param rescaleAsRequired defines if rescaling must be applied if required
  19389. * @returns true if operation was successful
  19390. */
  19391. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19392. /**
  19393. * Forces the skeleton to go to rest pose
  19394. */
  19395. returnToRest(): void;
  19396. private _getHighestAnimationFrame;
  19397. /**
  19398. * Begin a specific animation range
  19399. * @param name defines the name of the range to start
  19400. * @param loop defines if looping must be turned on (false by default)
  19401. * @param speedRatio defines the speed ratio to apply (1 by default)
  19402. * @param onAnimationEnd defines a callback which will be called when animation will end
  19403. * @returns a new animatable
  19404. */
  19405. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19406. /** @hidden */
  19407. _markAsDirty(): void;
  19408. /** @hidden */
  19409. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19410. /** @hidden */
  19411. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19412. private _computeTransformMatrices;
  19413. /**
  19414. * Build all resources required to render a skeleton
  19415. */
  19416. prepare(): void;
  19417. /**
  19418. * Gets the list of animatables currently running for this skeleton
  19419. * @returns an array of animatables
  19420. */
  19421. getAnimatables(): IAnimatable[];
  19422. /**
  19423. * Clone the current skeleton
  19424. * @param name defines the name of the new skeleton
  19425. * @param id defines the id of the enw skeleton
  19426. * @returns the new skeleton
  19427. */
  19428. clone(name: string, id: string): Skeleton;
  19429. /**
  19430. * Enable animation blending for this skeleton
  19431. * @param blendingSpeed defines the blending speed to apply
  19432. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19433. */
  19434. enableBlending(blendingSpeed?: number): void;
  19435. /**
  19436. * Releases all resources associated with the current skeleton
  19437. */
  19438. dispose(): void;
  19439. /**
  19440. * Serialize the skeleton in a JSON object
  19441. * @returns a JSON object
  19442. */
  19443. serialize(): any;
  19444. /**
  19445. * Creates a new skeleton from serialized data
  19446. * @param parsedSkeleton defines the serialized data
  19447. * @param scene defines the hosting scene
  19448. * @returns a new skeleton
  19449. */
  19450. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19451. /**
  19452. * Compute all node absolute transforms
  19453. * @param forceUpdate defines if computation must be done even if cache is up to date
  19454. */
  19455. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19456. /**
  19457. * Gets the root pose matrix
  19458. * @returns a matrix
  19459. */
  19460. getPoseMatrix(): Nullable<Matrix>;
  19461. /**
  19462. * Sorts bones per internal index
  19463. */
  19464. sortBones(): void;
  19465. private _sortBones;
  19466. }
  19467. }
  19468. declare module "babylonjs/Morph/morphTarget" {
  19469. import { IAnimatable } from "babylonjs/Misc/tools";
  19470. import { Observable } from "babylonjs/Misc/observable";
  19471. import { Nullable, FloatArray } from "babylonjs/types";
  19472. import { Scene } from "babylonjs/scene";
  19473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19474. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19475. /**
  19476. * Defines a target to use with MorphTargetManager
  19477. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19478. */
  19479. export class MorphTarget implements IAnimatable {
  19480. /** defines the name of the target */
  19481. name: string;
  19482. /**
  19483. * Gets or sets the list of animations
  19484. */
  19485. animations: import("babylonjs/Animations/animation").Animation[];
  19486. private _scene;
  19487. private _positions;
  19488. private _normals;
  19489. private _tangents;
  19490. private _influence;
  19491. /**
  19492. * Observable raised when the influence changes
  19493. */
  19494. onInfluenceChanged: Observable<boolean>;
  19495. /** @hidden */
  19496. _onDataLayoutChanged: Observable<void>;
  19497. /**
  19498. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19499. */
  19500. influence: number;
  19501. /**
  19502. * Gets or sets the id of the morph Target
  19503. */
  19504. id: string;
  19505. private _animationPropertiesOverride;
  19506. /**
  19507. * Gets or sets the animation properties override
  19508. */
  19509. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19510. /**
  19511. * Creates a new MorphTarget
  19512. * @param name defines the name of the target
  19513. * @param influence defines the influence to use
  19514. * @param scene defines the scene the morphtarget belongs to
  19515. */
  19516. constructor(
  19517. /** defines the name of the target */
  19518. name: string, influence?: number, scene?: Nullable<Scene>);
  19519. /**
  19520. * Gets a boolean defining if the target contains position data
  19521. */
  19522. readonly hasPositions: boolean;
  19523. /**
  19524. * Gets a boolean defining if the target contains normal data
  19525. */
  19526. readonly hasNormals: boolean;
  19527. /**
  19528. * Gets a boolean defining if the target contains tangent data
  19529. */
  19530. readonly hasTangents: boolean;
  19531. /**
  19532. * Affects position data to this target
  19533. * @param data defines the position data to use
  19534. */
  19535. setPositions(data: Nullable<FloatArray>): void;
  19536. /**
  19537. * Gets the position data stored in this target
  19538. * @returns a FloatArray containing the position data (or null if not present)
  19539. */
  19540. getPositions(): Nullable<FloatArray>;
  19541. /**
  19542. * Affects normal data to this target
  19543. * @param data defines the normal data to use
  19544. */
  19545. setNormals(data: Nullable<FloatArray>): void;
  19546. /**
  19547. * Gets the normal data stored in this target
  19548. * @returns a FloatArray containing the normal data (or null if not present)
  19549. */
  19550. getNormals(): Nullable<FloatArray>;
  19551. /**
  19552. * Affects tangent data to this target
  19553. * @param data defines the tangent data to use
  19554. */
  19555. setTangents(data: Nullable<FloatArray>): void;
  19556. /**
  19557. * Gets the tangent data stored in this target
  19558. * @returns a FloatArray containing the tangent data (or null if not present)
  19559. */
  19560. getTangents(): Nullable<FloatArray>;
  19561. /**
  19562. * Serializes the current target into a Serialization object
  19563. * @returns the serialized object
  19564. */
  19565. serialize(): any;
  19566. /**
  19567. * Returns the string "MorphTarget"
  19568. * @returns "MorphTarget"
  19569. */
  19570. getClassName(): string;
  19571. /**
  19572. * Creates a new target from serialized data
  19573. * @param serializationObject defines the serialized data to use
  19574. * @returns a new MorphTarget
  19575. */
  19576. static Parse(serializationObject: any): MorphTarget;
  19577. /**
  19578. * Creates a MorphTarget from mesh data
  19579. * @param mesh defines the source mesh
  19580. * @param name defines the name to use for the new target
  19581. * @param influence defines the influence to attach to the target
  19582. * @returns a new MorphTarget
  19583. */
  19584. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19585. }
  19586. }
  19587. declare module "babylonjs/Morph/morphTargetManager" {
  19588. import { Nullable } from "babylonjs/types";
  19589. import { Scene } from "babylonjs/scene";
  19590. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19591. /**
  19592. * This class is used to deform meshes using morphing between different targets
  19593. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19594. */
  19595. export class MorphTargetManager {
  19596. private _targets;
  19597. private _targetInfluenceChangedObservers;
  19598. private _targetDataLayoutChangedObservers;
  19599. private _activeTargets;
  19600. private _scene;
  19601. private _influences;
  19602. private _supportsNormals;
  19603. private _supportsTangents;
  19604. private _vertexCount;
  19605. private _uniqueId;
  19606. private _tempInfluences;
  19607. /**
  19608. * Creates a new MorphTargetManager
  19609. * @param scene defines the current scene
  19610. */
  19611. constructor(scene?: Nullable<Scene>);
  19612. /**
  19613. * Gets the unique ID of this manager
  19614. */
  19615. readonly uniqueId: number;
  19616. /**
  19617. * Gets the number of vertices handled by this manager
  19618. */
  19619. readonly vertexCount: number;
  19620. /**
  19621. * Gets a boolean indicating if this manager supports morphing of normals
  19622. */
  19623. readonly supportsNormals: boolean;
  19624. /**
  19625. * Gets a boolean indicating if this manager supports morphing of tangents
  19626. */
  19627. readonly supportsTangents: boolean;
  19628. /**
  19629. * Gets the number of targets stored in this manager
  19630. */
  19631. readonly numTargets: number;
  19632. /**
  19633. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19634. */
  19635. readonly numInfluencers: number;
  19636. /**
  19637. * Gets the list of influences (one per target)
  19638. */
  19639. readonly influences: Float32Array;
  19640. /**
  19641. * Gets the active target at specified index. An active target is a target with an influence > 0
  19642. * @param index defines the index to check
  19643. * @returns the requested target
  19644. */
  19645. getActiveTarget(index: number): MorphTarget;
  19646. /**
  19647. * Gets the target at specified index
  19648. * @param index defines the index to check
  19649. * @returns the requested target
  19650. */
  19651. getTarget(index: number): MorphTarget;
  19652. /**
  19653. * Add a new target to this manager
  19654. * @param target defines the target to add
  19655. */
  19656. addTarget(target: MorphTarget): void;
  19657. /**
  19658. * Removes a target from the manager
  19659. * @param target defines the target to remove
  19660. */
  19661. removeTarget(target: MorphTarget): void;
  19662. /**
  19663. * Serializes the current manager into a Serialization object
  19664. * @returns the serialized object
  19665. */
  19666. serialize(): any;
  19667. private _syncActiveTargets;
  19668. /**
  19669. * Syncrhonize the targets with all the meshes using this morph target manager
  19670. */
  19671. synchronize(): void;
  19672. /**
  19673. * Creates a new MorphTargetManager from serialized data
  19674. * @param serializationObject defines the serialized data
  19675. * @param scene defines the hosting scene
  19676. * @returns the new MorphTargetManager
  19677. */
  19678. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19679. }
  19680. }
  19681. declare module "babylonjs/Meshes/groundMesh" {
  19682. import { Scene } from "babylonjs/scene";
  19683. import { Vector3 } from "babylonjs/Maths/math";
  19684. import { Mesh } from "babylonjs/Meshes/mesh";
  19685. /**
  19686. * Mesh representing the gorund
  19687. */
  19688. export class GroundMesh extends Mesh {
  19689. /** If octree should be generated */
  19690. generateOctree: boolean;
  19691. private _heightQuads;
  19692. /** @hidden */
  19693. _subdivisionsX: number;
  19694. /** @hidden */
  19695. _subdivisionsY: number;
  19696. /** @hidden */
  19697. _width: number;
  19698. /** @hidden */
  19699. _height: number;
  19700. /** @hidden */
  19701. _minX: number;
  19702. /** @hidden */
  19703. _maxX: number;
  19704. /** @hidden */
  19705. _minZ: number;
  19706. /** @hidden */
  19707. _maxZ: number;
  19708. constructor(name: string, scene: Scene);
  19709. /**
  19710. * "GroundMesh"
  19711. * @returns "GroundMesh"
  19712. */
  19713. getClassName(): string;
  19714. /**
  19715. * The minimum of x and y subdivisions
  19716. */
  19717. readonly subdivisions: number;
  19718. /**
  19719. * X subdivisions
  19720. */
  19721. readonly subdivisionsX: number;
  19722. /**
  19723. * Y subdivisions
  19724. */
  19725. readonly subdivisionsY: number;
  19726. /**
  19727. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19728. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19729. * @param chunksCount the number of subdivisions for x and y
  19730. * @param octreeBlocksSize (Default: 32)
  19731. */
  19732. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19733. /**
  19734. * Returns a height (y) value in the Worl system :
  19735. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19736. * @param x x coordinate
  19737. * @param z z coordinate
  19738. * @returns the ground y position if (x, z) are outside the ground surface.
  19739. */
  19740. getHeightAtCoordinates(x: number, z: number): number;
  19741. /**
  19742. * Returns a normalized vector (Vector3) orthogonal to the ground
  19743. * at the ground coordinates (x, z) expressed in the World system.
  19744. * @param x x coordinate
  19745. * @param z z coordinate
  19746. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19747. */
  19748. getNormalAtCoordinates(x: number, z: number): Vector3;
  19749. /**
  19750. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19751. * at the ground coordinates (x, z) expressed in the World system.
  19752. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19753. * @param x x coordinate
  19754. * @param z z coordinate
  19755. * @param ref vector to store the result
  19756. * @returns the GroundMesh.
  19757. */
  19758. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19759. /**
  19760. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19761. * if the ground has been updated.
  19762. * This can be used in the render loop.
  19763. * @returns the GroundMesh.
  19764. */
  19765. updateCoordinateHeights(): GroundMesh;
  19766. private _getFacetAt;
  19767. private _initHeightQuads;
  19768. private _computeHeightQuads;
  19769. /**
  19770. * Serializes this ground mesh
  19771. * @param serializationObject object to write serialization to
  19772. */
  19773. serialize(serializationObject: any): void;
  19774. /**
  19775. * Parses a serialized ground mesh
  19776. * @param parsedMesh the serialized mesh
  19777. * @param scene the scene to create the ground mesh in
  19778. * @returns the created ground mesh
  19779. */
  19780. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19781. }
  19782. }
  19783. declare module "babylonjs/Physics/physicsJoint" {
  19784. import { Vector3 } from "babylonjs/Maths/math";
  19785. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19786. /**
  19787. * Interface for Physics-Joint data
  19788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19789. */
  19790. export interface PhysicsJointData {
  19791. /**
  19792. * The main pivot of the joint
  19793. */
  19794. mainPivot?: Vector3;
  19795. /**
  19796. * The connected pivot of the joint
  19797. */
  19798. connectedPivot?: Vector3;
  19799. /**
  19800. * The main axis of the joint
  19801. */
  19802. mainAxis?: Vector3;
  19803. /**
  19804. * The connected axis of the joint
  19805. */
  19806. connectedAxis?: Vector3;
  19807. /**
  19808. * The collision of the joint
  19809. */
  19810. collision?: boolean;
  19811. /**
  19812. * Native Oimo/Cannon/Energy data
  19813. */
  19814. nativeParams?: any;
  19815. }
  19816. /**
  19817. * This is a holder class for the physics joint created by the physics plugin
  19818. * It holds a set of functions to control the underlying joint
  19819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19820. */
  19821. export class PhysicsJoint {
  19822. /**
  19823. * The type of the physics joint
  19824. */
  19825. type: number;
  19826. /**
  19827. * The data for the physics joint
  19828. */
  19829. jointData: PhysicsJointData;
  19830. private _physicsJoint;
  19831. protected _physicsPlugin: IPhysicsEnginePlugin;
  19832. /**
  19833. * Initializes the physics joint
  19834. * @param type The type of the physics joint
  19835. * @param jointData The data for the physics joint
  19836. */
  19837. constructor(
  19838. /**
  19839. * The type of the physics joint
  19840. */
  19841. type: number,
  19842. /**
  19843. * The data for the physics joint
  19844. */
  19845. jointData: PhysicsJointData);
  19846. /**
  19847. * Gets the physics joint
  19848. */
  19849. /**
  19850. * Sets the physics joint
  19851. */
  19852. physicsJoint: any;
  19853. /**
  19854. * Sets the physics plugin
  19855. */
  19856. physicsPlugin: IPhysicsEnginePlugin;
  19857. /**
  19858. * Execute a function that is physics-plugin specific.
  19859. * @param {Function} func the function that will be executed.
  19860. * It accepts two parameters: the physics world and the physics joint
  19861. */
  19862. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19863. /**
  19864. * Distance-Joint type
  19865. */
  19866. static DistanceJoint: number;
  19867. /**
  19868. * Hinge-Joint type
  19869. */
  19870. static HingeJoint: number;
  19871. /**
  19872. * Ball-and-Socket joint type
  19873. */
  19874. static BallAndSocketJoint: number;
  19875. /**
  19876. * Wheel-Joint type
  19877. */
  19878. static WheelJoint: number;
  19879. /**
  19880. * Slider-Joint type
  19881. */
  19882. static SliderJoint: number;
  19883. /**
  19884. * Prismatic-Joint type
  19885. */
  19886. static PrismaticJoint: number;
  19887. /**
  19888. * Universal-Joint type
  19889. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19890. */
  19891. static UniversalJoint: number;
  19892. /**
  19893. * Hinge-Joint 2 type
  19894. */
  19895. static Hinge2Joint: number;
  19896. /**
  19897. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19898. */
  19899. static PointToPointJoint: number;
  19900. /**
  19901. * Spring-Joint type
  19902. */
  19903. static SpringJoint: number;
  19904. /**
  19905. * Lock-Joint type
  19906. */
  19907. static LockJoint: number;
  19908. }
  19909. /**
  19910. * A class representing a physics distance joint
  19911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19912. */
  19913. export class DistanceJoint extends PhysicsJoint {
  19914. /**
  19915. *
  19916. * @param jointData The data for the Distance-Joint
  19917. */
  19918. constructor(jointData: DistanceJointData);
  19919. /**
  19920. * Update the predefined distance.
  19921. * @param maxDistance The maximum preferred distance
  19922. * @param minDistance The minimum preferred distance
  19923. */
  19924. updateDistance(maxDistance: number, minDistance?: number): void;
  19925. }
  19926. /**
  19927. * Represents a Motor-Enabled Joint
  19928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19929. */
  19930. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19931. /**
  19932. * Initializes the Motor-Enabled Joint
  19933. * @param type The type of the joint
  19934. * @param jointData The physica joint data for the joint
  19935. */
  19936. constructor(type: number, jointData: PhysicsJointData);
  19937. /**
  19938. * Set the motor values.
  19939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19940. * @param force the force to apply
  19941. * @param maxForce max force for this motor.
  19942. */
  19943. setMotor(force?: number, maxForce?: number): void;
  19944. /**
  19945. * Set the motor's limits.
  19946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19947. * @param upperLimit The upper limit of the motor
  19948. * @param lowerLimit The lower limit of the motor
  19949. */
  19950. setLimit(upperLimit: number, lowerLimit?: number): void;
  19951. }
  19952. /**
  19953. * This class represents a single physics Hinge-Joint
  19954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19955. */
  19956. export class HingeJoint extends MotorEnabledJoint {
  19957. /**
  19958. * Initializes the Hinge-Joint
  19959. * @param jointData The joint data for the Hinge-Joint
  19960. */
  19961. constructor(jointData: PhysicsJointData);
  19962. /**
  19963. * Set the motor values.
  19964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19965. * @param {number} force the force to apply
  19966. * @param {number} maxForce max force for this motor.
  19967. */
  19968. setMotor(force?: number, maxForce?: number): void;
  19969. /**
  19970. * Set the motor's limits.
  19971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19972. * @param upperLimit The upper limit of the motor
  19973. * @param lowerLimit The lower limit of the motor
  19974. */
  19975. setLimit(upperLimit: number, lowerLimit?: number): void;
  19976. }
  19977. /**
  19978. * This class represents a dual hinge physics joint (same as wheel joint)
  19979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19980. */
  19981. export class Hinge2Joint extends MotorEnabledJoint {
  19982. /**
  19983. * Initializes the Hinge2-Joint
  19984. * @param jointData The joint data for the Hinge2-Joint
  19985. */
  19986. constructor(jointData: PhysicsJointData);
  19987. /**
  19988. * Set the motor values.
  19989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19990. * @param {number} targetSpeed the speed the motor is to reach
  19991. * @param {number} maxForce max force for this motor.
  19992. * @param {motorIndex} the motor's index, 0 or 1.
  19993. */
  19994. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19995. /**
  19996. * Set the motor limits.
  19997. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19998. * @param {number} upperLimit the upper limit
  19999. * @param {number} lowerLimit lower limit
  20000. * @param {motorIndex} the motor's index, 0 or 1.
  20001. */
  20002. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20003. }
  20004. /**
  20005. * Interface for a motor enabled joint
  20006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20007. */
  20008. export interface IMotorEnabledJoint {
  20009. /**
  20010. * Physics joint
  20011. */
  20012. physicsJoint: any;
  20013. /**
  20014. * Sets the motor of the motor-enabled joint
  20015. * @param force The force of the motor
  20016. * @param maxForce The maximum force of the motor
  20017. * @param motorIndex The index of the motor
  20018. */
  20019. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20020. /**
  20021. * Sets the limit of the motor
  20022. * @param upperLimit The upper limit of the motor
  20023. * @param lowerLimit The lower limit of the motor
  20024. * @param motorIndex The index of the motor
  20025. */
  20026. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20027. }
  20028. /**
  20029. * Joint data for a Distance-Joint
  20030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20031. */
  20032. export interface DistanceJointData extends PhysicsJointData {
  20033. /**
  20034. * Max distance the 2 joint objects can be apart
  20035. */
  20036. maxDistance: number;
  20037. }
  20038. /**
  20039. * Joint data from a spring joint
  20040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20041. */
  20042. export interface SpringJointData extends PhysicsJointData {
  20043. /**
  20044. * Length of the spring
  20045. */
  20046. length: number;
  20047. /**
  20048. * Stiffness of the spring
  20049. */
  20050. stiffness: number;
  20051. /**
  20052. * Damping of the spring
  20053. */
  20054. damping: number;
  20055. /** this callback will be called when applying the force to the impostors. */
  20056. forceApplicationCallback: () => void;
  20057. }
  20058. }
  20059. declare module "babylonjs/Physics/physicsRaycastResult" {
  20060. import { Vector3 } from "babylonjs/Maths/math";
  20061. /**
  20062. * Holds the data for the raycast result
  20063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20064. */
  20065. export class PhysicsRaycastResult {
  20066. private _hasHit;
  20067. private _hitDistance;
  20068. private _hitNormalWorld;
  20069. private _hitPointWorld;
  20070. private _rayFromWorld;
  20071. private _rayToWorld;
  20072. /**
  20073. * Gets if there was a hit
  20074. */
  20075. readonly hasHit: boolean;
  20076. /**
  20077. * Gets the distance from the hit
  20078. */
  20079. readonly hitDistance: number;
  20080. /**
  20081. * Gets the hit normal/direction in the world
  20082. */
  20083. readonly hitNormalWorld: Vector3;
  20084. /**
  20085. * Gets the hit point in the world
  20086. */
  20087. readonly hitPointWorld: Vector3;
  20088. /**
  20089. * Gets the ray "start point" of the ray in the world
  20090. */
  20091. readonly rayFromWorld: Vector3;
  20092. /**
  20093. * Gets the ray "end point" of the ray in the world
  20094. */
  20095. readonly rayToWorld: Vector3;
  20096. /**
  20097. * Sets the hit data (normal & point in world space)
  20098. * @param hitNormalWorld defines the normal in world space
  20099. * @param hitPointWorld defines the point in world space
  20100. */
  20101. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20102. /**
  20103. * Sets the distance from the start point to the hit point
  20104. * @param distance
  20105. */
  20106. setHitDistance(distance: number): void;
  20107. /**
  20108. * Calculates the distance manually
  20109. */
  20110. calculateHitDistance(): void;
  20111. /**
  20112. * Resets all the values to default
  20113. * @param from The from point on world space
  20114. * @param to The to point on world space
  20115. */
  20116. reset(from?: Vector3, to?: Vector3): void;
  20117. }
  20118. /**
  20119. * Interface for the size containing width and height
  20120. */
  20121. interface IXYZ {
  20122. /**
  20123. * X
  20124. */
  20125. x: number;
  20126. /**
  20127. * Y
  20128. */
  20129. y: number;
  20130. /**
  20131. * Z
  20132. */
  20133. z: number;
  20134. }
  20135. }
  20136. declare module "babylonjs/Physics/IPhysicsEngine" {
  20137. import { Nullable } from "babylonjs/types";
  20138. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20140. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20141. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20142. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20143. /**
  20144. * Interface used to describe a physics joint
  20145. */
  20146. export interface PhysicsImpostorJoint {
  20147. /** Defines the main impostor to which the joint is linked */
  20148. mainImpostor: PhysicsImpostor;
  20149. /** Defines the impostor that is connected to the main impostor using this joint */
  20150. connectedImpostor: PhysicsImpostor;
  20151. /** Defines the joint itself */
  20152. joint: PhysicsJoint;
  20153. }
  20154. /** @hidden */
  20155. export interface IPhysicsEnginePlugin {
  20156. world: any;
  20157. name: string;
  20158. setGravity(gravity: Vector3): void;
  20159. setTimeStep(timeStep: number): void;
  20160. getTimeStep(): number;
  20161. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20162. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20164. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20165. removePhysicsBody(impostor: PhysicsImpostor): void;
  20166. generateJoint(joint: PhysicsImpostorJoint): void;
  20167. removeJoint(joint: PhysicsImpostorJoint): void;
  20168. isSupported(): boolean;
  20169. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20170. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20171. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20172. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20173. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20174. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20175. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20176. getBodyMass(impostor: PhysicsImpostor): number;
  20177. getBodyFriction(impostor: PhysicsImpostor): number;
  20178. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20179. getBodyRestitution(impostor: PhysicsImpostor): number;
  20180. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20181. getBodyPressure?(impostor: PhysicsImpostor): number;
  20182. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20183. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20184. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20185. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20186. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20187. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20188. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20189. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20190. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20191. sleepBody(impostor: PhysicsImpostor): void;
  20192. wakeUpBody(impostor: PhysicsImpostor): void;
  20193. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20194. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20195. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20197. getRadius(impostor: PhysicsImpostor): number;
  20198. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20199. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20200. dispose(): void;
  20201. }
  20202. /**
  20203. * Interface used to define a physics engine
  20204. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20205. */
  20206. export interface IPhysicsEngine {
  20207. /**
  20208. * Gets the gravity vector used by the simulation
  20209. */
  20210. gravity: Vector3;
  20211. /**
  20212. * Sets the gravity vector used by the simulation
  20213. * @param gravity defines the gravity vector to use
  20214. */
  20215. setGravity(gravity: Vector3): void;
  20216. /**
  20217. * Set the time step of the physics engine.
  20218. * Default is 1/60.
  20219. * To slow it down, enter 1/600 for example.
  20220. * To speed it up, 1/30
  20221. * @param newTimeStep the new timestep to apply to this world.
  20222. */
  20223. setTimeStep(newTimeStep: number): void;
  20224. /**
  20225. * Get the time step of the physics engine.
  20226. * @returns the current time step
  20227. */
  20228. getTimeStep(): number;
  20229. /**
  20230. * Release all resources
  20231. */
  20232. dispose(): void;
  20233. /**
  20234. * Gets the name of the current physics plugin
  20235. * @returns the name of the plugin
  20236. */
  20237. getPhysicsPluginName(): string;
  20238. /**
  20239. * Adding a new impostor for the impostor tracking.
  20240. * This will be done by the impostor itself.
  20241. * @param impostor the impostor to add
  20242. */
  20243. addImpostor(impostor: PhysicsImpostor): void;
  20244. /**
  20245. * Remove an impostor from the engine.
  20246. * This impostor and its mesh will not longer be updated by the physics engine.
  20247. * @param impostor the impostor to remove
  20248. */
  20249. removeImpostor(impostor: PhysicsImpostor): void;
  20250. /**
  20251. * Add a joint to the physics engine
  20252. * @param mainImpostor defines the main impostor to which the joint is added.
  20253. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20254. * @param joint defines the joint that will connect both impostors.
  20255. */
  20256. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20257. /**
  20258. * Removes a joint from the simulation
  20259. * @param mainImpostor defines the impostor used with the joint
  20260. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20261. * @param joint defines the joint to remove
  20262. */
  20263. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20264. /**
  20265. * Gets the current plugin used to run the simulation
  20266. * @returns current plugin
  20267. */
  20268. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20269. /**
  20270. * Gets the list of physic impostors
  20271. * @returns an array of PhysicsImpostor
  20272. */
  20273. getImpostors(): Array<PhysicsImpostor>;
  20274. /**
  20275. * Gets the impostor for a physics enabled object
  20276. * @param object defines the object impersonated by the impostor
  20277. * @returns the PhysicsImpostor or null if not found
  20278. */
  20279. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20280. /**
  20281. * Gets the impostor for a physics body object
  20282. * @param body defines physics body used by the impostor
  20283. * @returns the PhysicsImpostor or null if not found
  20284. */
  20285. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20286. /**
  20287. * Does a raycast in the physics world
  20288. * @param from when should the ray start?
  20289. * @param to when should the ray end?
  20290. * @returns PhysicsRaycastResult
  20291. */
  20292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20293. /**
  20294. * Called by the scene. No need to call it.
  20295. * @param delta defines the timespam between frames
  20296. */
  20297. _step(delta: number): void;
  20298. }
  20299. }
  20300. declare module "babylonjs/Physics/physicsImpostor" {
  20301. import { Nullable, IndicesArray } from "babylonjs/types";
  20302. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20303. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20305. import { Scene } from "babylonjs/scene";
  20306. import { Bone } from "babylonjs/Bones/bone";
  20307. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20308. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20309. /**
  20310. * The interface for the physics imposter parameters
  20311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20312. */
  20313. export interface PhysicsImpostorParameters {
  20314. /**
  20315. * The mass of the physics imposter
  20316. */
  20317. mass: number;
  20318. /**
  20319. * The friction of the physics imposter
  20320. */
  20321. friction?: number;
  20322. /**
  20323. * The coefficient of restitution of the physics imposter
  20324. */
  20325. restitution?: number;
  20326. /**
  20327. * The native options of the physics imposter
  20328. */
  20329. nativeOptions?: any;
  20330. /**
  20331. * Specifies if the parent should be ignored
  20332. */
  20333. ignoreParent?: boolean;
  20334. /**
  20335. * Specifies if bi-directional transformations should be disabled
  20336. */
  20337. disableBidirectionalTransformation?: boolean;
  20338. /**
  20339. * The pressure inside the physics imposter, soft object only
  20340. */
  20341. pressure?: number;
  20342. /**
  20343. * The stiffness the physics imposter, soft object only
  20344. */
  20345. stiffness?: number;
  20346. /**
  20347. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20348. */
  20349. velocityIterations?: number;
  20350. /**
  20351. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20352. */
  20353. positionIterations?: number;
  20354. /**
  20355. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20356. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20357. * Add to fix multiple points
  20358. */
  20359. fixedPoints?: number;
  20360. /**
  20361. * The collision margin around a soft object
  20362. */
  20363. margin?: number;
  20364. /**
  20365. * The collision margin around a soft object
  20366. */
  20367. damping?: number;
  20368. /**
  20369. * The path for a rope based on an extrusion
  20370. */
  20371. path?: any;
  20372. /**
  20373. * The shape of an extrusion used for a rope based on an extrusion
  20374. */
  20375. shape?: any;
  20376. }
  20377. /**
  20378. * Interface for a physics-enabled object
  20379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20380. */
  20381. export interface IPhysicsEnabledObject {
  20382. /**
  20383. * The position of the physics-enabled object
  20384. */
  20385. position: Vector3;
  20386. /**
  20387. * The rotation of the physics-enabled object
  20388. */
  20389. rotationQuaternion: Nullable<Quaternion>;
  20390. /**
  20391. * The scale of the physics-enabled object
  20392. */
  20393. scaling: Vector3;
  20394. /**
  20395. * The rotation of the physics-enabled object
  20396. */
  20397. rotation?: Vector3;
  20398. /**
  20399. * The parent of the physics-enabled object
  20400. */
  20401. parent?: any;
  20402. /**
  20403. * The bounding info of the physics-enabled object
  20404. * @returns The bounding info of the physics-enabled object
  20405. */
  20406. getBoundingInfo(): BoundingInfo;
  20407. /**
  20408. * Computes the world matrix
  20409. * @param force Specifies if the world matrix should be computed by force
  20410. * @returns A world matrix
  20411. */
  20412. computeWorldMatrix(force: boolean): Matrix;
  20413. /**
  20414. * Gets the world matrix
  20415. * @returns A world matrix
  20416. */
  20417. getWorldMatrix?(): Matrix;
  20418. /**
  20419. * Gets the child meshes
  20420. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20421. * @returns An array of abstract meshes
  20422. */
  20423. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20424. /**
  20425. * Gets the vertex data
  20426. * @param kind The type of vertex data
  20427. * @returns A nullable array of numbers, or a float32 array
  20428. */
  20429. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20430. /**
  20431. * Gets the indices from the mesh
  20432. * @returns A nullable array of index arrays
  20433. */
  20434. getIndices?(): Nullable<IndicesArray>;
  20435. /**
  20436. * Gets the scene from the mesh
  20437. * @returns the indices array or null
  20438. */
  20439. getScene?(): Scene;
  20440. /**
  20441. * Gets the absolute position from the mesh
  20442. * @returns the absolute position
  20443. */
  20444. getAbsolutePosition(): Vector3;
  20445. /**
  20446. * Gets the absolute pivot point from the mesh
  20447. * @returns the absolute pivot point
  20448. */
  20449. getAbsolutePivotPoint(): Vector3;
  20450. /**
  20451. * Rotates the mesh
  20452. * @param axis The axis of rotation
  20453. * @param amount The amount of rotation
  20454. * @param space The space of the rotation
  20455. * @returns The rotation transform node
  20456. */
  20457. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20458. /**
  20459. * Translates the mesh
  20460. * @param axis The axis of translation
  20461. * @param distance The distance of translation
  20462. * @param space The space of the translation
  20463. * @returns The transform node
  20464. */
  20465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20466. /**
  20467. * Sets the absolute position of the mesh
  20468. * @param absolutePosition The absolute position of the mesh
  20469. * @returns The transform node
  20470. */
  20471. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20472. /**
  20473. * Gets the class name of the mesh
  20474. * @returns The class name
  20475. */
  20476. getClassName(): string;
  20477. }
  20478. /**
  20479. * Represents a physics imposter
  20480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20481. */
  20482. export class PhysicsImpostor {
  20483. /**
  20484. * The physics-enabled object used as the physics imposter
  20485. */
  20486. object: IPhysicsEnabledObject;
  20487. /**
  20488. * The type of the physics imposter
  20489. */
  20490. type: number;
  20491. private _options;
  20492. private _scene?;
  20493. /**
  20494. * The default object size of the imposter
  20495. */
  20496. static DEFAULT_OBJECT_SIZE: Vector3;
  20497. /**
  20498. * The identity quaternion of the imposter
  20499. */
  20500. static IDENTITY_QUATERNION: Quaternion;
  20501. /** @hidden */
  20502. _pluginData: any;
  20503. private _physicsEngine;
  20504. private _physicsBody;
  20505. private _bodyUpdateRequired;
  20506. private _onBeforePhysicsStepCallbacks;
  20507. private _onAfterPhysicsStepCallbacks;
  20508. /** @hidden */
  20509. _onPhysicsCollideCallbacks: Array<{
  20510. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20511. otherImpostors: Array<PhysicsImpostor>;
  20512. }>;
  20513. private _deltaPosition;
  20514. private _deltaRotation;
  20515. private _deltaRotationConjugated;
  20516. /** hidden */
  20517. _isFromLine: boolean;
  20518. private _parent;
  20519. private _isDisposed;
  20520. private static _tmpVecs;
  20521. private static _tmpQuat;
  20522. /**
  20523. * Specifies if the physics imposter is disposed
  20524. */
  20525. readonly isDisposed: boolean;
  20526. /**
  20527. * Gets the mass of the physics imposter
  20528. */
  20529. mass: number;
  20530. /**
  20531. * Gets the coefficient of friction
  20532. */
  20533. /**
  20534. * Sets the coefficient of friction
  20535. */
  20536. friction: number;
  20537. /**
  20538. * Gets the coefficient of restitution
  20539. */
  20540. /**
  20541. * Sets the coefficient of restitution
  20542. */
  20543. restitution: number;
  20544. /**
  20545. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20546. */
  20547. /**
  20548. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20549. */
  20550. pressure: number;
  20551. /**
  20552. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20553. */
  20554. /**
  20555. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20556. */
  20557. stiffness: number;
  20558. /**
  20559. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20560. */
  20561. /**
  20562. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20563. */
  20564. velocityIterations: number;
  20565. /**
  20566. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20567. */
  20568. /**
  20569. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20570. */
  20571. positionIterations: number;
  20572. /**
  20573. * The unique id of the physics imposter
  20574. * set by the physics engine when adding this impostor to the array
  20575. */
  20576. uniqueId: number;
  20577. /**
  20578. * @hidden
  20579. */
  20580. soft: boolean;
  20581. /**
  20582. * @hidden
  20583. */
  20584. segments: number;
  20585. private _joints;
  20586. /**
  20587. * Initializes the physics imposter
  20588. * @param object The physics-enabled object used as the physics imposter
  20589. * @param type The type of the physics imposter
  20590. * @param _options The options for the physics imposter
  20591. * @param _scene The Babylon scene
  20592. */
  20593. constructor(
  20594. /**
  20595. * The physics-enabled object used as the physics imposter
  20596. */
  20597. object: IPhysicsEnabledObject,
  20598. /**
  20599. * The type of the physics imposter
  20600. */
  20601. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20602. /**
  20603. * This function will completly initialize this impostor.
  20604. * It will create a new body - but only if this mesh has no parent.
  20605. * If it has, this impostor will not be used other than to define the impostor
  20606. * of the child mesh.
  20607. * @hidden
  20608. */
  20609. _init(): void;
  20610. private _getPhysicsParent;
  20611. /**
  20612. * Should a new body be generated.
  20613. * @returns boolean specifying if body initialization is required
  20614. */
  20615. isBodyInitRequired(): boolean;
  20616. /**
  20617. * Sets the updated scaling
  20618. * @param updated Specifies if the scaling is updated
  20619. */
  20620. setScalingUpdated(): void;
  20621. /**
  20622. * Force a regeneration of this or the parent's impostor's body.
  20623. * Use under cautious - This will remove all joints already implemented.
  20624. */
  20625. forceUpdate(): void;
  20626. /**
  20627. * Gets the body that holds this impostor. Either its own, or its parent.
  20628. */
  20629. /**
  20630. * Set the physics body. Used mainly by the physics engine/plugin
  20631. */
  20632. physicsBody: any;
  20633. /**
  20634. * Get the parent of the physics imposter
  20635. * @returns Physics imposter or null
  20636. */
  20637. /**
  20638. * Sets the parent of the physics imposter
  20639. */
  20640. parent: Nullable<PhysicsImpostor>;
  20641. /**
  20642. * Resets the update flags
  20643. */
  20644. resetUpdateFlags(): void;
  20645. /**
  20646. * Gets the object extend size
  20647. * @returns the object extend size
  20648. */
  20649. getObjectExtendSize(): Vector3;
  20650. /**
  20651. * Gets the object center
  20652. * @returns The object center
  20653. */
  20654. getObjectCenter(): Vector3;
  20655. /**
  20656. * Get a specific parametes from the options parameter
  20657. * @param paramName The object parameter name
  20658. * @returns The object parameter
  20659. */
  20660. getParam(paramName: string): any;
  20661. /**
  20662. * Sets a specific parameter in the options given to the physics plugin
  20663. * @param paramName The parameter name
  20664. * @param value The value of the parameter
  20665. */
  20666. setParam(paramName: string, value: number): void;
  20667. /**
  20668. * Specifically change the body's mass option. Won't recreate the physics body object
  20669. * @param mass The mass of the physics imposter
  20670. */
  20671. setMass(mass: number): void;
  20672. /**
  20673. * Gets the linear velocity
  20674. * @returns linear velocity or null
  20675. */
  20676. getLinearVelocity(): Nullable<Vector3>;
  20677. /**
  20678. * Sets the linear velocity
  20679. * @param velocity linear velocity or null
  20680. */
  20681. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20682. /**
  20683. * Gets the angular velocity
  20684. * @returns angular velocity or null
  20685. */
  20686. getAngularVelocity(): Nullable<Vector3>;
  20687. /**
  20688. * Sets the angular velocity
  20689. * @param velocity The velocity or null
  20690. */
  20691. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20692. /**
  20693. * Execute a function with the physics plugin native code
  20694. * Provide a function the will have two variables - the world object and the physics body object
  20695. * @param func The function to execute with the physics plugin native code
  20696. */
  20697. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20698. /**
  20699. * Register a function that will be executed before the physics world is stepping forward
  20700. * @param func The function to execute before the physics world is stepped forward
  20701. */
  20702. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20703. /**
  20704. * Unregister a function that will be executed before the physics world is stepping forward
  20705. * @param func The function to execute before the physics world is stepped forward
  20706. */
  20707. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20708. /**
  20709. * Register a function that will be executed after the physics step
  20710. * @param func The function to execute after physics step
  20711. */
  20712. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20713. /**
  20714. * Unregisters a function that will be executed after the physics step
  20715. * @param func The function to execute after physics step
  20716. */
  20717. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20718. /**
  20719. * register a function that will be executed when this impostor collides against a different body
  20720. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20721. * @param func Callback that is executed on collision
  20722. */
  20723. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20724. /**
  20725. * Unregisters the physics imposter on contact
  20726. * @param collideAgainst The physics object to collide against
  20727. * @param func Callback to execute on collision
  20728. */
  20729. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20730. private _tmpQuat;
  20731. private _tmpQuat2;
  20732. /**
  20733. * Get the parent rotation
  20734. * @returns The parent rotation
  20735. */
  20736. getParentsRotation(): Quaternion;
  20737. /**
  20738. * this function is executed by the physics engine.
  20739. */
  20740. beforeStep: () => void;
  20741. /**
  20742. * this function is executed by the physics engine
  20743. */
  20744. afterStep: () => void;
  20745. /**
  20746. * Legacy collision detection event support
  20747. */
  20748. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20749. /**
  20750. * event and body object due to cannon's event-based architecture.
  20751. */
  20752. onCollide: (e: {
  20753. body: any;
  20754. }) => void;
  20755. /**
  20756. * Apply a force
  20757. * @param force The force to apply
  20758. * @param contactPoint The contact point for the force
  20759. * @returns The physics imposter
  20760. */
  20761. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20762. /**
  20763. * Apply an impulse
  20764. * @param force The impulse force
  20765. * @param contactPoint The contact point for the impulse force
  20766. * @returns The physics imposter
  20767. */
  20768. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20769. /**
  20770. * A help function to create a joint
  20771. * @param otherImpostor A physics imposter used to create a joint
  20772. * @param jointType The type of joint
  20773. * @param jointData The data for the joint
  20774. * @returns The physics imposter
  20775. */
  20776. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20777. /**
  20778. * Add a joint to this impostor with a different impostor
  20779. * @param otherImpostor A physics imposter used to add a joint
  20780. * @param joint The joint to add
  20781. * @returns The physics imposter
  20782. */
  20783. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20784. /**
  20785. * Add an anchor to a cloth impostor
  20786. * @param otherImpostor rigid impostor to anchor to
  20787. * @param width ratio across width from 0 to 1
  20788. * @param height ratio up height from 0 to 1
  20789. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20790. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20791. * @returns impostor the soft imposter
  20792. */
  20793. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20794. /**
  20795. * Add a hook to a rope impostor
  20796. * @param otherImpostor rigid impostor to anchor to
  20797. * @param length ratio across rope from 0 to 1
  20798. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20799. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20800. * @returns impostor the rope imposter
  20801. */
  20802. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20803. /**
  20804. * Will keep this body still, in a sleep mode.
  20805. * @returns the physics imposter
  20806. */
  20807. sleep(): PhysicsImpostor;
  20808. /**
  20809. * Wake the body up.
  20810. * @returns The physics imposter
  20811. */
  20812. wakeUp(): PhysicsImpostor;
  20813. /**
  20814. * Clones the physics imposter
  20815. * @param newObject The physics imposter clones to this physics-enabled object
  20816. * @returns A nullable physics imposter
  20817. */
  20818. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20819. /**
  20820. * Disposes the physics imposter
  20821. */
  20822. dispose(): void;
  20823. /**
  20824. * Sets the delta position
  20825. * @param position The delta position amount
  20826. */
  20827. setDeltaPosition(position: Vector3): void;
  20828. /**
  20829. * Sets the delta rotation
  20830. * @param rotation The delta rotation amount
  20831. */
  20832. setDeltaRotation(rotation: Quaternion): void;
  20833. /**
  20834. * Gets the box size of the physics imposter and stores the result in the input parameter
  20835. * @param result Stores the box size
  20836. * @returns The physics imposter
  20837. */
  20838. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20839. /**
  20840. * Gets the radius of the physics imposter
  20841. * @returns Radius of the physics imposter
  20842. */
  20843. getRadius(): number;
  20844. /**
  20845. * Sync a bone with this impostor
  20846. * @param bone The bone to sync to the impostor.
  20847. * @param boneMesh The mesh that the bone is influencing.
  20848. * @param jointPivot The pivot of the joint / bone in local space.
  20849. * @param distToJoint Optional distance from the impostor to the joint.
  20850. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20851. */
  20852. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20853. /**
  20854. * Sync impostor to a bone
  20855. * @param bone The bone that the impostor will be synced to.
  20856. * @param boneMesh The mesh that the bone is influencing.
  20857. * @param jointPivot The pivot of the joint / bone in local space.
  20858. * @param distToJoint Optional distance from the impostor to the joint.
  20859. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20860. * @param boneAxis Optional vector3 axis the bone is aligned with
  20861. */
  20862. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20863. /**
  20864. * No-Imposter type
  20865. */
  20866. static NoImpostor: number;
  20867. /**
  20868. * Sphere-Imposter type
  20869. */
  20870. static SphereImpostor: number;
  20871. /**
  20872. * Box-Imposter type
  20873. */
  20874. static BoxImpostor: number;
  20875. /**
  20876. * Plane-Imposter type
  20877. */
  20878. static PlaneImpostor: number;
  20879. /**
  20880. * Mesh-imposter type
  20881. */
  20882. static MeshImpostor: number;
  20883. /**
  20884. * Cylinder-Imposter type
  20885. */
  20886. static CylinderImpostor: number;
  20887. /**
  20888. * Particle-Imposter type
  20889. */
  20890. static ParticleImpostor: number;
  20891. /**
  20892. * Heightmap-Imposter type
  20893. */
  20894. static HeightmapImpostor: number;
  20895. /**
  20896. * ConvexHull-Impostor type (Ammo.js plugin only)
  20897. */
  20898. static ConvexHullImpostor: number;
  20899. /**
  20900. * Rope-Imposter type
  20901. */
  20902. static RopeImpostor: number;
  20903. /**
  20904. * Cloth-Imposter type
  20905. */
  20906. static ClothImpostor: number;
  20907. /**
  20908. * Softbody-Imposter type
  20909. */
  20910. static SoftbodyImpostor: number;
  20911. }
  20912. }
  20913. declare module "babylonjs/Meshes/mesh" {
  20914. import { Observable } from "babylonjs/Misc/observable";
  20915. import { IAnimatable } from "babylonjs/Misc/tools";
  20916. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20917. import { Camera } from "babylonjs/Cameras/camera";
  20918. import { Scene } from "babylonjs/scene";
  20919. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20920. import { Engine } from "babylonjs/Engines/engine";
  20921. import { Node } from "babylonjs/node";
  20922. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20923. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20924. import { Buffer } from "babylonjs/Meshes/buffer";
  20925. import { Geometry } from "babylonjs/Meshes/geometry";
  20926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20927. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20928. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20929. import { Effect } from "babylonjs/Materials/effect";
  20930. import { Material } from "babylonjs/Materials/material";
  20931. import { Skeleton } from "babylonjs/Bones/skeleton";
  20932. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20933. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20934. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20935. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20936. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20937. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20938. /**
  20939. * Class used to represent a specific level of detail of a mesh
  20940. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20941. */
  20942. export class MeshLODLevel {
  20943. /** Defines the distance where this level should star being displayed */
  20944. distance: number;
  20945. /** Defines the mesh to use to render this level */
  20946. mesh: Nullable<Mesh>;
  20947. /**
  20948. * Creates a new LOD level
  20949. * @param distance defines the distance where this level should star being displayed
  20950. * @param mesh defines the mesh to use to render this level
  20951. */
  20952. constructor(
  20953. /** Defines the distance where this level should star being displayed */
  20954. distance: number,
  20955. /** Defines the mesh to use to render this level */
  20956. mesh: Nullable<Mesh>);
  20957. }
  20958. /**
  20959. * @hidden
  20960. **/
  20961. export class _CreationDataStorage {
  20962. closePath?: boolean;
  20963. closeArray?: boolean;
  20964. idx: number[];
  20965. dashSize: number;
  20966. gapSize: number;
  20967. path3D: Path3D;
  20968. pathArray: Vector3[][];
  20969. arc: number;
  20970. radius: number;
  20971. cap: number;
  20972. tessellation: number;
  20973. }
  20974. /**
  20975. * @hidden
  20976. **/
  20977. class _InstanceDataStorage {
  20978. visibleInstances: any;
  20979. renderIdForInstances: number[];
  20980. batchCache: _InstancesBatch;
  20981. instancesBufferSize: number;
  20982. instancesBuffer: Nullable<Buffer>;
  20983. instancesData: Float32Array;
  20984. overridenInstanceCount: number;
  20985. }
  20986. /**
  20987. * @hidden
  20988. **/
  20989. export class _InstancesBatch {
  20990. mustReturn: boolean;
  20991. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20992. renderSelf: boolean[];
  20993. }
  20994. /**
  20995. * Class used to represent renderable models
  20996. */
  20997. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20998. /**
  20999. * Mesh side orientation : usually the external or front surface
  21000. */
  21001. static readonly FRONTSIDE: number;
  21002. /**
  21003. * Mesh side orientation : usually the internal or back surface
  21004. */
  21005. static readonly BACKSIDE: number;
  21006. /**
  21007. * Mesh side orientation : both internal and external or front and back surfaces
  21008. */
  21009. static readonly DOUBLESIDE: number;
  21010. /**
  21011. * Mesh side orientation : by default, `FRONTSIDE`
  21012. */
  21013. static readonly DEFAULTSIDE: number;
  21014. /**
  21015. * Mesh cap setting : no cap
  21016. */
  21017. static readonly NO_CAP: number;
  21018. /**
  21019. * Mesh cap setting : one cap at the beginning of the mesh
  21020. */
  21021. static readonly CAP_START: number;
  21022. /**
  21023. * Mesh cap setting : one cap at the end of the mesh
  21024. */
  21025. static readonly CAP_END: number;
  21026. /**
  21027. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21028. */
  21029. static readonly CAP_ALL: number;
  21030. /**
  21031. * Gets the default side orientation.
  21032. * @param orientation the orientation to value to attempt to get
  21033. * @returns the default orientation
  21034. * @hidden
  21035. */
  21036. static _GetDefaultSideOrientation(orientation?: number): number;
  21037. private _onBeforeRenderObservable;
  21038. private _onBeforeBindObservable;
  21039. private _onAfterRenderObservable;
  21040. private _onBeforeDrawObservable;
  21041. /**
  21042. * An event triggered before rendering the mesh
  21043. */
  21044. readonly onBeforeRenderObservable: Observable<Mesh>;
  21045. /**
  21046. * An event triggered before binding the mesh
  21047. */
  21048. readonly onBeforeBindObservable: Observable<Mesh>;
  21049. /**
  21050. * An event triggered after rendering the mesh
  21051. */
  21052. readonly onAfterRenderObservable: Observable<Mesh>;
  21053. /**
  21054. * An event triggered before drawing the mesh
  21055. */
  21056. readonly onBeforeDrawObservable: Observable<Mesh>;
  21057. private _onBeforeDrawObserver;
  21058. /**
  21059. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21060. */
  21061. onBeforeDraw: () => void;
  21062. /**
  21063. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21064. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21065. */
  21066. delayLoadState: number;
  21067. /**
  21068. * Gets the list of instances created from this mesh
  21069. * it is not supposed to be modified manually.
  21070. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21071. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21072. */
  21073. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21074. /**
  21075. * Gets the file containing delay loading data for this mesh
  21076. */
  21077. delayLoadingFile: string;
  21078. /** @hidden */
  21079. _binaryInfo: any;
  21080. private _LODLevels;
  21081. /**
  21082. * User defined function used to change how LOD level selection is done
  21083. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21084. */
  21085. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21086. private _morphTargetManager;
  21087. /**
  21088. * Gets or sets the morph target manager
  21089. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21090. */
  21091. morphTargetManager: Nullable<MorphTargetManager>;
  21092. /** @hidden */
  21093. _creationDataStorage: Nullable<_CreationDataStorage>;
  21094. /** @hidden */
  21095. _geometry: Nullable<Geometry>;
  21096. /** @hidden */
  21097. _delayInfo: Array<string>;
  21098. /** @hidden */
  21099. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21100. /** @hidden */
  21101. _instanceDataStorage: _InstanceDataStorage;
  21102. private _effectiveMaterial;
  21103. /** @hidden */
  21104. _shouldGenerateFlatShading: boolean;
  21105. private _preActivateId;
  21106. /** @hidden */
  21107. _originalBuilderSideOrientation: number;
  21108. /**
  21109. * Use this property to change the original side orientation defined at construction time
  21110. */
  21111. overrideMaterialSideOrientation: Nullable<number>;
  21112. private _areNormalsFrozen;
  21113. private _sourcePositions;
  21114. private _sourceNormals;
  21115. private _source;
  21116. private meshMap;
  21117. /**
  21118. * Gets the source mesh (the one used to clone this one from)
  21119. */
  21120. readonly source: Nullable<Mesh>;
  21121. /**
  21122. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21123. */
  21124. isUnIndexed: boolean;
  21125. /**
  21126. * @constructor
  21127. * @param name The value used by scene.getMeshByName() to do a lookup.
  21128. * @param scene The scene to add this mesh to.
  21129. * @param parent The parent of this mesh, if it has one
  21130. * @param source An optional Mesh from which geometry is shared, cloned.
  21131. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21132. * When false, achieved by calling a clone(), also passing False.
  21133. * This will make creation of children, recursive.
  21134. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21135. */
  21136. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21137. /**
  21138. * Gets the class name
  21139. * @returns the string "Mesh".
  21140. */
  21141. getClassName(): string;
  21142. /** @hidden */
  21143. readonly _isMesh: boolean;
  21144. /**
  21145. * Returns a description of this mesh
  21146. * @param fullDetails define if full details about this mesh must be used
  21147. * @returns a descriptive string representing this mesh
  21148. */
  21149. toString(fullDetails?: boolean): string;
  21150. /** @hidden */
  21151. _unBindEffect(): void;
  21152. /**
  21153. * Gets a boolean indicating if this mesh has LOD
  21154. */
  21155. readonly hasLODLevels: boolean;
  21156. /**
  21157. * Gets the list of MeshLODLevel associated with the current mesh
  21158. * @returns an array of MeshLODLevel
  21159. */
  21160. getLODLevels(): MeshLODLevel[];
  21161. private _sortLODLevels;
  21162. /**
  21163. * Add a mesh as LOD level triggered at the given distance.
  21164. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21165. * @param distance The distance from the center of the object to show this level
  21166. * @param mesh The mesh to be added as LOD level (can be null)
  21167. * @return This mesh (for chaining)
  21168. */
  21169. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21170. /**
  21171. * Returns the LOD level mesh at the passed distance or null if not found.
  21172. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21173. * @param distance The distance from the center of the object to show this level
  21174. * @returns a Mesh or `null`
  21175. */
  21176. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21177. /**
  21178. * Remove a mesh from the LOD array
  21179. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21180. * @param mesh defines the mesh to be removed
  21181. * @return This mesh (for chaining)
  21182. */
  21183. removeLODLevel(mesh: Mesh): Mesh;
  21184. /**
  21185. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21187. * @param camera defines the camera to use to compute distance
  21188. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21189. * @return This mesh (for chaining)
  21190. */
  21191. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21192. /**
  21193. * Gets the mesh internal Geometry object
  21194. */
  21195. readonly geometry: Nullable<Geometry>;
  21196. /**
  21197. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21198. * @returns the total number of vertices
  21199. */
  21200. getTotalVertices(): number;
  21201. /**
  21202. * Returns the content of an associated vertex buffer
  21203. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21204. * - VertexBuffer.PositionKind
  21205. * - VertexBuffer.UVKind
  21206. * - VertexBuffer.UV2Kind
  21207. * - VertexBuffer.UV3Kind
  21208. * - VertexBuffer.UV4Kind
  21209. * - VertexBuffer.UV5Kind
  21210. * - VertexBuffer.UV6Kind
  21211. * - VertexBuffer.ColorKind
  21212. * - VertexBuffer.MatricesIndicesKind
  21213. * - VertexBuffer.MatricesIndicesExtraKind
  21214. * - VertexBuffer.MatricesWeightsKind
  21215. * - VertexBuffer.MatricesWeightsExtraKind
  21216. * @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
  21217. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21218. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21219. */
  21220. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21221. /**
  21222. * Returns the mesh VertexBuffer object from the requested `kind`
  21223. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21224. * - VertexBuffer.PositionKind
  21225. * - VertexBuffer.UVKind
  21226. * - VertexBuffer.UV2Kind
  21227. * - VertexBuffer.UV3Kind
  21228. * - VertexBuffer.UV4Kind
  21229. * - VertexBuffer.UV5Kind
  21230. * - VertexBuffer.UV6Kind
  21231. * - VertexBuffer.ColorKind
  21232. * - VertexBuffer.MatricesIndicesKind
  21233. * - VertexBuffer.MatricesIndicesExtraKind
  21234. * - VertexBuffer.MatricesWeightsKind
  21235. * - VertexBuffer.MatricesWeightsExtraKind
  21236. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21237. */
  21238. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21239. /**
  21240. * Tests if a specific vertex buffer is associated with this mesh
  21241. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21242. * - VertexBuffer.PositionKind
  21243. * - VertexBuffer.UVKind
  21244. * - VertexBuffer.UV2Kind
  21245. * - VertexBuffer.UV3Kind
  21246. * - VertexBuffer.UV4Kind
  21247. * - VertexBuffer.UV5Kind
  21248. * - VertexBuffer.UV6Kind
  21249. * - VertexBuffer.ColorKind
  21250. * - VertexBuffer.MatricesIndicesKind
  21251. * - VertexBuffer.MatricesIndicesExtraKind
  21252. * - VertexBuffer.MatricesWeightsKind
  21253. * - VertexBuffer.MatricesWeightsExtraKind
  21254. * @returns a boolean
  21255. */
  21256. isVerticesDataPresent(kind: string): boolean;
  21257. /**
  21258. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21259. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21260. * - VertexBuffer.PositionKind
  21261. * - VertexBuffer.UVKind
  21262. * - VertexBuffer.UV2Kind
  21263. * - VertexBuffer.UV3Kind
  21264. * - VertexBuffer.UV4Kind
  21265. * - VertexBuffer.UV5Kind
  21266. * - VertexBuffer.UV6Kind
  21267. * - VertexBuffer.ColorKind
  21268. * - VertexBuffer.MatricesIndicesKind
  21269. * - VertexBuffer.MatricesIndicesExtraKind
  21270. * - VertexBuffer.MatricesWeightsKind
  21271. * - VertexBuffer.MatricesWeightsExtraKind
  21272. * @returns a boolean
  21273. */
  21274. isVertexBufferUpdatable(kind: string): boolean;
  21275. /**
  21276. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21277. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21278. * - VertexBuffer.PositionKind
  21279. * - VertexBuffer.UVKind
  21280. * - VertexBuffer.UV2Kind
  21281. * - VertexBuffer.UV3Kind
  21282. * - VertexBuffer.UV4Kind
  21283. * - VertexBuffer.UV5Kind
  21284. * - VertexBuffer.UV6Kind
  21285. * - VertexBuffer.ColorKind
  21286. * - VertexBuffer.MatricesIndicesKind
  21287. * - VertexBuffer.MatricesIndicesExtraKind
  21288. * - VertexBuffer.MatricesWeightsKind
  21289. * - VertexBuffer.MatricesWeightsExtraKind
  21290. * @returns an array of strings
  21291. */
  21292. getVerticesDataKinds(): string[];
  21293. /**
  21294. * Returns a positive integer : the total number of indices in this mesh geometry.
  21295. * @returns the numner of indices or zero if the mesh has no geometry.
  21296. */
  21297. getTotalIndices(): number;
  21298. /**
  21299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21300. * @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.
  21301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21302. * @returns the indices array or an empty array if the mesh has no geometry
  21303. */
  21304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21305. readonly isBlocked: boolean;
  21306. /**
  21307. * Determine if the current mesh is ready to be rendered
  21308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21310. * @returns true if all associated assets are ready (material, textures, shaders)
  21311. */
  21312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21313. /**
  21314. * 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.
  21315. */
  21316. readonly areNormalsFrozen: boolean;
  21317. /**
  21318. * 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.
  21319. * @returns the current mesh
  21320. */
  21321. freezeNormals(): Mesh;
  21322. /**
  21323. * 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
  21324. * @returns the current mesh
  21325. */
  21326. unfreezeNormals(): Mesh;
  21327. /**
  21328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21329. */
  21330. overridenInstanceCount: number;
  21331. /** @hidden */
  21332. _preActivate(): Mesh;
  21333. /** @hidden */
  21334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21335. /** @hidden */
  21336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21337. /**
  21338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21339. * This means the mesh underlying bounding box and sphere are recomputed.
  21340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21341. * @returns the current mesh
  21342. */
  21343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21344. /** @hidden */
  21345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21346. /**
  21347. * This function will subdivide the mesh into multiple submeshes
  21348. * @param count defines the expected number of submeshes
  21349. */
  21350. subdivide(count: number): void;
  21351. /**
  21352. * Copy a FloatArray into a specific associated vertex buffer
  21353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21354. * - VertexBuffer.PositionKind
  21355. * - VertexBuffer.UVKind
  21356. * - VertexBuffer.UV2Kind
  21357. * - VertexBuffer.UV3Kind
  21358. * - VertexBuffer.UV4Kind
  21359. * - VertexBuffer.UV5Kind
  21360. * - VertexBuffer.UV6Kind
  21361. * - VertexBuffer.ColorKind
  21362. * - VertexBuffer.MatricesIndicesKind
  21363. * - VertexBuffer.MatricesIndicesExtraKind
  21364. * - VertexBuffer.MatricesWeightsKind
  21365. * - VertexBuffer.MatricesWeightsExtraKind
  21366. * @param data defines the data source
  21367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21368. * @param stride defines the data stride size (can be null)
  21369. * @returns the current mesh
  21370. */
  21371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21372. /**
  21373. * Flags an associated vertex buffer as updatable
  21374. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21375. * - VertexBuffer.PositionKind
  21376. * - VertexBuffer.UVKind
  21377. * - VertexBuffer.UV2Kind
  21378. * - VertexBuffer.UV3Kind
  21379. * - VertexBuffer.UV4Kind
  21380. * - VertexBuffer.UV5Kind
  21381. * - VertexBuffer.UV6Kind
  21382. * - VertexBuffer.ColorKind
  21383. * - VertexBuffer.MatricesIndicesKind
  21384. * - VertexBuffer.MatricesIndicesExtraKind
  21385. * - VertexBuffer.MatricesWeightsKind
  21386. * - VertexBuffer.MatricesWeightsExtraKind
  21387. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21388. */
  21389. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21390. /**
  21391. * Sets the mesh global Vertex Buffer
  21392. * @param buffer defines the buffer to use
  21393. * @returns the current mesh
  21394. */
  21395. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21396. /**
  21397. * Update a specific associated vertex buffer
  21398. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21399. * - VertexBuffer.PositionKind
  21400. * - VertexBuffer.UVKind
  21401. * - VertexBuffer.UV2Kind
  21402. * - VertexBuffer.UV3Kind
  21403. * - VertexBuffer.UV4Kind
  21404. * - VertexBuffer.UV5Kind
  21405. * - VertexBuffer.UV6Kind
  21406. * - VertexBuffer.ColorKind
  21407. * - VertexBuffer.MatricesIndicesKind
  21408. * - VertexBuffer.MatricesIndicesExtraKind
  21409. * - VertexBuffer.MatricesWeightsKind
  21410. * - VertexBuffer.MatricesWeightsExtraKind
  21411. * @param data defines the data source
  21412. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21413. * @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)
  21414. * @returns the current mesh
  21415. */
  21416. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21417. /**
  21418. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21419. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21420. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21421. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21422. * @returns the current mesh
  21423. */
  21424. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21425. /**
  21426. * Creates a un-shared specific occurence of the geometry for the mesh.
  21427. * @returns the current mesh
  21428. */
  21429. makeGeometryUnique(): Mesh;
  21430. /**
  21431. * Set the index buffer of this mesh
  21432. * @param indices defines the source data
  21433. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21434. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21435. * @returns the current mesh
  21436. */
  21437. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21438. /**
  21439. * Update the current index buffer
  21440. * @param indices defines the source data
  21441. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21442. * @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)
  21443. * @returns the current mesh
  21444. */
  21445. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21446. /**
  21447. * Invert the geometry to move from a right handed system to a left handed one.
  21448. * @returns the current mesh
  21449. */
  21450. toLeftHanded(): Mesh;
  21451. /** @hidden */
  21452. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21453. /** @hidden */
  21454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21455. /**
  21456. * Registers for this mesh a javascript function called just before the rendering process
  21457. * @param func defines the function to call before rendering this mesh
  21458. * @returns the current mesh
  21459. */
  21460. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21461. /**
  21462. * Disposes a previously registered javascript function called before the rendering
  21463. * @param func defines the function to remove
  21464. * @returns the current mesh
  21465. */
  21466. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21467. /**
  21468. * Registers for this mesh a javascript function called just after the rendering is complete
  21469. * @param func defines the function to call after rendering this mesh
  21470. * @returns the current mesh
  21471. */
  21472. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21473. /**
  21474. * Disposes a previously registered javascript function called after the rendering.
  21475. * @param func defines the function to remove
  21476. * @returns the current mesh
  21477. */
  21478. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21479. /** @hidden */
  21480. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21481. /** @hidden */
  21482. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21483. /** @hidden */
  21484. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21485. /**
  21486. * 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
  21487. * @param subMesh defines the subMesh to render
  21488. * @param enableAlphaMode defines if alpha mode can be changed
  21489. * @returns the current mesh
  21490. */
  21491. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21492. private _onBeforeDraw;
  21493. /**
  21494. * Renormalize the mesh and patch it up if there are no weights
  21495. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21496. * However in the case of zero weights then we set just a single influence to 1.
  21497. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21498. */
  21499. cleanMatrixWeights(): void;
  21500. private normalizeSkinFourWeights;
  21501. private normalizeSkinWeightsAndExtra;
  21502. /**
  21503. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21504. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21505. * the user know there was an issue with importing the mesh
  21506. * @returns a validation object with skinned, valid and report string
  21507. */
  21508. validateSkinning(): {
  21509. skinned: boolean;
  21510. valid: boolean;
  21511. report: string;
  21512. };
  21513. /** @hidden */
  21514. _checkDelayState(): Mesh;
  21515. private _queueLoad;
  21516. /**
  21517. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21518. * A mesh is in the frustum if its bounding box intersects the frustum
  21519. * @param frustumPlanes defines the frustum to test
  21520. * @returns true if the mesh is in the frustum planes
  21521. */
  21522. isInFrustum(frustumPlanes: Plane[]): boolean;
  21523. /**
  21524. * Sets the mesh material by the material or multiMaterial `id` property
  21525. * @param id is a string identifying the material or the multiMaterial
  21526. * @returns the current mesh
  21527. */
  21528. setMaterialByID(id: string): Mesh;
  21529. /**
  21530. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21531. * @returns an array of IAnimatable
  21532. */
  21533. getAnimatables(): IAnimatable[];
  21534. /**
  21535. * Modifies the mesh geometry according to the passed transformation matrix.
  21536. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21537. * The mesh normals are modified using the same transformation.
  21538. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21539. * @param transform defines the transform matrix to use
  21540. * @see http://doc.babylonjs.com/resources/baking_transformations
  21541. * @returns the current mesh
  21542. */
  21543. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21544. /**
  21545. * Modifies the mesh geometry according to its own current World Matrix.
  21546. * The mesh World Matrix is then reset.
  21547. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21548. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21549. * @see http://doc.babylonjs.com/resources/baking_transformations
  21550. * @returns the current mesh
  21551. */
  21552. bakeCurrentTransformIntoVertices(): Mesh;
  21553. /** @hidden */
  21554. readonly _positions: Nullable<Vector3[]>;
  21555. /** @hidden */
  21556. _resetPointsArrayCache(): Mesh;
  21557. /** @hidden */
  21558. _generatePointsArray(): boolean;
  21559. /**
  21560. * Returns a new Mesh object generated from the current mesh properties.
  21561. * This method must not get confused with createInstance()
  21562. * @param name is a string, the name given to the new mesh
  21563. * @param newParent can be any Node object (default `null`)
  21564. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21565. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21566. * @returns a new mesh
  21567. */
  21568. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21569. /**
  21570. * Releases resources associated with this mesh.
  21571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21573. */
  21574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21575. /**
  21576. * Modifies the mesh geometry according to a displacement map.
  21577. * 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.
  21578. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21579. * @param url is a string, the URL from the image file is to be downloaded.
  21580. * @param minHeight is the lower limit of the displacement.
  21581. * @param maxHeight is the upper limit of the displacement.
  21582. * @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.
  21583. * @param uvOffset is an optional vector2 used to offset UV.
  21584. * @param uvScale is an optional vector2 used to scale UV.
  21585. * @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.
  21586. * @returns the Mesh.
  21587. */
  21588. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21589. /**
  21590. * Modifies the mesh geometry according to a displacementMap buffer.
  21591. * 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.
  21592. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21593. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21594. * @param heightMapWidth is the width of the buffer image.
  21595. * @param heightMapHeight is the height of the buffer image.
  21596. * @param minHeight is the lower limit of the displacement.
  21597. * @param maxHeight is the upper limit of the displacement.
  21598. * @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.
  21599. * @param uvOffset is an optional vector2 used to offset UV.
  21600. * @param uvScale is an optional vector2 used to scale UV.
  21601. * @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.
  21602. * @returns the Mesh.
  21603. */
  21604. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21605. /**
  21606. * Modify the mesh to get a flat shading rendering.
  21607. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21608. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21609. * @returns current mesh
  21610. */
  21611. convertToFlatShadedMesh(): Mesh;
  21612. /**
  21613. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21614. * In other words, more vertices, no more indices and a single bigger VBO.
  21615. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21616. * @returns current mesh
  21617. */
  21618. convertToUnIndexedMesh(): Mesh;
  21619. /**
  21620. * Inverses facet orientations.
  21621. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21622. * @param flipNormals will also inverts the normals
  21623. * @returns current mesh
  21624. */
  21625. flipFaces(flipNormals?: boolean): Mesh;
  21626. /**
  21627. * Increase the number of facets and hence vertices in a mesh
  21628. * Vertex normals are interpolated from existing vertex normals
  21629. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21630. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21631. */
  21632. increaseVertices(numberPerEdge: number): void;
  21633. /**
  21634. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21635. * This will undo any application of covertToFlatShadedMesh
  21636. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21637. */
  21638. forceSharedVertices(): void;
  21639. /** @hidden */
  21640. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21641. /** @hidden */
  21642. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21643. /**
  21644. * Creates a new InstancedMesh object from the mesh model.
  21645. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21646. * @param name defines the name of the new instance
  21647. * @returns a new InstancedMesh
  21648. */
  21649. createInstance(name: string): InstancedMesh;
  21650. /**
  21651. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21652. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21653. * @returns the current mesh
  21654. */
  21655. synchronizeInstances(): Mesh;
  21656. /**
  21657. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21658. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21659. * This should be used together with the simplification to avoid disappearing triangles.
  21660. * @param successCallback an optional success callback to be called after the optimization finished.
  21661. * @returns the current mesh
  21662. */
  21663. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21664. /**
  21665. * Serialize current mesh
  21666. * @param serializationObject defines the object which will receive the serialization data
  21667. */
  21668. serialize(serializationObject: any): void;
  21669. /** @hidden */
  21670. _syncGeometryWithMorphTargetManager(): void;
  21671. /** @hidden */
  21672. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21673. /**
  21674. * Returns a new Mesh object parsed from the source provided.
  21675. * @param parsedMesh is the source
  21676. * @param scene defines the hosting scene
  21677. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21678. * @returns a new Mesh
  21679. */
  21680. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21681. /**
  21682. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21683. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21684. * @param name defines the name of the mesh to create
  21685. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21686. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21687. * @param closePath creates a seam between the first and the last points of each path of the path array
  21688. * @param offset is taken in account only if the `pathArray` is containing a single path
  21689. * @param scene defines the hosting scene
  21690. * @param updatable defines if the mesh must be flagged as updatable
  21691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21692. * @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)
  21693. * @returns a new Mesh
  21694. */
  21695. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21696. /**
  21697. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21698. * @param name defines the name of the mesh to create
  21699. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21700. * @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
  21701. * @param scene defines the hosting scene
  21702. * @param updatable defines if the mesh must be flagged as updatable
  21703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21704. * @returns a new Mesh
  21705. */
  21706. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21707. /**
  21708. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21709. * @param name defines the name of the mesh to create
  21710. * @param size sets the size (float) of each box side (default 1)
  21711. * @param scene defines the hosting scene
  21712. * @param updatable defines if the mesh must be flagged as updatable
  21713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21714. * @returns a new Mesh
  21715. */
  21716. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21717. /**
  21718. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21719. * @param name defines the name of the mesh to create
  21720. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21721. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21722. * @param scene defines the hosting scene
  21723. * @param updatable defines if the mesh must be flagged as updatable
  21724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21725. * @returns a new Mesh
  21726. */
  21727. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21728. /**
  21729. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21730. * @param name defines the name of the mesh to create
  21731. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21732. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21733. * @param scene defines the hosting scene
  21734. * @returns a new Mesh
  21735. */
  21736. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21737. /**
  21738. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21739. * @param name defines the name of the mesh to create
  21740. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21741. * @param diameterTop set the top cap diameter (floats, default 1)
  21742. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21743. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21744. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21745. * @param scene defines the hosting scene
  21746. * @param updatable defines if the mesh must be flagged as updatable
  21747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21748. * @returns a new Mesh
  21749. */
  21750. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21751. /**
  21752. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21753. * @param name defines the name of the mesh to create
  21754. * @param diameter sets the diameter size (float) of the torus (default 1)
  21755. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21756. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21757. * @param scene defines the hosting scene
  21758. * @param updatable defines if the mesh must be flagged as updatable
  21759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21760. * @returns a new Mesh
  21761. */
  21762. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21763. /**
  21764. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21765. * @param name defines the name of the mesh to create
  21766. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21767. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21768. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21769. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21770. * @param p the number of windings on X axis (positive integers, default 2)
  21771. * @param q the number of windings on Y axis (positive integers, default 3)
  21772. * @param scene defines the hosting scene
  21773. * @param updatable defines if the mesh must be flagged as updatable
  21774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21775. * @returns a new Mesh
  21776. */
  21777. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21778. /**
  21779. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21780. * @param name defines the name of the mesh to create
  21781. * @param points is an array successive Vector3
  21782. * @param scene defines the hosting scene
  21783. * @param updatable defines if the mesh must be flagged as updatable
  21784. * @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).
  21785. * @returns a new Mesh
  21786. */
  21787. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21788. /**
  21789. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21790. * @param name defines the name of the mesh to create
  21791. * @param points is an array successive Vector3
  21792. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21793. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21794. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21795. * @param scene defines the hosting scene
  21796. * @param updatable defines if the mesh must be flagged as updatable
  21797. * @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)
  21798. * @returns a new Mesh
  21799. */
  21800. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21801. /**
  21802. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21803. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21804. * 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.
  21805. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21806. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21807. * Remember you can only change the shape positions, not their number when updating a polygon.
  21808. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21809. * @param name defines the name of the mesh to create
  21810. * @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
  21811. * @param scene defines the hosting scene
  21812. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21813. * @param updatable defines if the mesh must be flagged as updatable
  21814. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21815. * @param earcutInjection can be used to inject your own earcut reference
  21816. * @returns a new Mesh
  21817. */
  21818. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21819. /**
  21820. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21821. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21822. * @param name defines the name of the mesh to create
  21823. * @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
  21824. * @param depth defines the height of extrusion
  21825. * @param scene defines the hosting scene
  21826. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21827. * @param updatable defines if the mesh must be flagged as updatable
  21828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21829. * @param earcutInjection can be used to inject your own earcut reference
  21830. * @returns a new Mesh
  21831. */
  21832. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21833. /**
  21834. * Creates an extruded shape mesh.
  21835. * 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
  21836. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21838. * @param name defines the name of the mesh to create
  21839. * @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
  21840. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21841. * @param scale is the value to scale the shape
  21842. * @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
  21843. * @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
  21844. * @param scene defines the hosting scene
  21845. * @param updatable defines if the mesh must be flagged as updatable
  21846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21847. * @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)
  21848. * @returns a new Mesh
  21849. */
  21850. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21851. /**
  21852. * Creates an custom extruded shape mesh.
  21853. * The custom extrusion is a parametric shape.
  21854. * It has no predefined shape. Its final shape will depend on the input parameters.
  21855. * Please consider using the same method from the MeshBuilder class instead
  21856. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21857. * @param name defines the name of the mesh to create
  21858. * @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
  21859. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21860. * @param scaleFunction is a custom Javascript function called on each path point
  21861. * @param rotationFunction is a custom Javascript function called on each path point
  21862. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21863. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21864. * @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
  21865. * @param scene defines the hosting scene
  21866. * @param updatable defines if the mesh must be flagged as updatable
  21867. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21868. * @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)
  21869. * @returns a new Mesh
  21870. */
  21871. 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;
  21872. /**
  21873. * Creates lathe mesh.
  21874. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21875. * Please consider using the same method from the MeshBuilder class instead
  21876. * @param name defines the name of the mesh to create
  21877. * @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
  21878. * @param radius is the radius value of the lathe
  21879. * @param tessellation is the side number of the lathe.
  21880. * @param scene defines the hosting scene
  21881. * @param updatable defines if the mesh must be flagged as updatable
  21882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21883. * @returns a new Mesh
  21884. */
  21885. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21886. /**
  21887. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21888. * @param name defines the name of the mesh to create
  21889. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21890. * @param scene defines the hosting scene
  21891. * @param updatable defines if the mesh must be flagged as updatable
  21892. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21893. * @returns a new Mesh
  21894. */
  21895. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21896. /**
  21897. * Creates a ground mesh.
  21898. * Please consider using the same method from the MeshBuilder class instead
  21899. * @param name defines the name of the mesh to create
  21900. * @param width set the width of the ground
  21901. * @param height set the height of the ground
  21902. * @param subdivisions sets the number of subdivisions per side
  21903. * @param scene defines the hosting scene
  21904. * @param updatable defines if the mesh must be flagged as updatable
  21905. * @returns a new Mesh
  21906. */
  21907. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21908. /**
  21909. * Creates a tiled ground mesh.
  21910. * Please consider using the same method from the MeshBuilder class instead
  21911. * @param name defines the name of the mesh to create
  21912. * @param xmin set the ground minimum X coordinate
  21913. * @param zmin set the ground minimum Y coordinate
  21914. * @param xmax set the ground maximum X coordinate
  21915. * @param zmax set the ground maximum Z coordinate
  21916. * @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
  21917. * @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
  21918. * @param scene defines the hosting scene
  21919. * @param updatable defines if the mesh must be flagged as updatable
  21920. * @returns a new Mesh
  21921. */
  21922. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21923. w: number;
  21924. h: number;
  21925. }, precision: {
  21926. w: number;
  21927. h: number;
  21928. }, scene: Scene, updatable?: boolean): Mesh;
  21929. /**
  21930. * Creates a ground mesh from a height map.
  21931. * Please consider using the same method from the MeshBuilder class instead
  21932. * @see http://doc.babylonjs.com/babylon101/height_map
  21933. * @param name defines the name of the mesh to create
  21934. * @param url sets the URL of the height map image resource
  21935. * @param width set the ground width size
  21936. * @param height set the ground height size
  21937. * @param subdivisions sets the number of subdivision per side
  21938. * @param minHeight is the minimum altitude on the ground
  21939. * @param maxHeight is the maximum altitude on the ground
  21940. * @param scene defines the hosting scene
  21941. * @param updatable defines if the mesh must be flagged as updatable
  21942. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21943. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21944. * @returns a new Mesh
  21945. */
  21946. 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;
  21947. /**
  21948. * Creates a tube mesh.
  21949. * The tube is a parametric shape.
  21950. * It has no predefined shape. Its final shape will depend on the input parameters.
  21951. * Please consider using the same method from the MeshBuilder class instead
  21952. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21953. * @param name defines the name of the mesh to create
  21954. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21955. * @param radius sets the tube radius size
  21956. * @param tessellation is the number of sides on the tubular surface
  21957. * @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
  21958. * @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
  21959. * @param scene defines the hosting scene
  21960. * @param updatable defines if the mesh must be flagged as updatable
  21961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21962. * @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)
  21963. * @returns a new Mesh
  21964. */
  21965. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21966. (i: number, distance: number): number;
  21967. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21968. /**
  21969. * Creates a polyhedron mesh.
  21970. * Please consider using the same method from the MeshBuilder class instead.
  21971. * * 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
  21972. * * The parameter `size` (positive float, default 1) sets the polygon size
  21973. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21974. * * 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`
  21975. * * 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
  21976. * * 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)`)
  21977. * * 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
  21978. * * 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
  21979. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21980. * * If you create a double-sided mesh, you can choose what parts of 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
  21981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21982. * @param name defines the name of the mesh to create
  21983. * @param options defines the options used to create the mesh
  21984. * @param scene defines the hosting scene
  21985. * @returns a new Mesh
  21986. */
  21987. static CreatePolyhedron(name: string, options: {
  21988. type?: number;
  21989. size?: number;
  21990. sizeX?: number;
  21991. sizeY?: number;
  21992. sizeZ?: number;
  21993. custom?: any;
  21994. faceUV?: Vector4[];
  21995. faceColors?: Color4[];
  21996. updatable?: boolean;
  21997. sideOrientation?: number;
  21998. }, scene: Scene): Mesh;
  21999. /**
  22000. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22001. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22002. * * 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`)
  22003. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22004. * * 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
  22005. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22006. * * If you create a double-sided mesh, you can choose what parts of 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
  22007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22008. * @param name defines the name of the mesh
  22009. * @param options defines the options used to create the mesh
  22010. * @param scene defines the hosting scene
  22011. * @returns a new Mesh
  22012. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22013. */
  22014. static CreateIcoSphere(name: string, options: {
  22015. radius?: number;
  22016. flat?: boolean;
  22017. subdivisions?: number;
  22018. sideOrientation?: number;
  22019. updatable?: boolean;
  22020. }, scene: Scene): Mesh;
  22021. /**
  22022. * Creates a decal mesh.
  22023. * Please consider using the same method from the MeshBuilder class instead.
  22024. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22025. * @param name defines the name of the mesh
  22026. * @param sourceMesh defines the mesh receiving the decal
  22027. * @param position sets the position of the decal in world coordinates
  22028. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22029. * @param size sets the decal scaling
  22030. * @param angle sets the angle to rotate the decal
  22031. * @returns a new Mesh
  22032. */
  22033. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22034. /**
  22035. * Prepare internal position array for software CPU skinning
  22036. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22037. */
  22038. setPositionsForCPUSkinning(): Float32Array;
  22039. /**
  22040. * Prepare internal normal array for software CPU skinning
  22041. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22042. */
  22043. setNormalsForCPUSkinning(): Float32Array;
  22044. /**
  22045. * Updates the vertex buffer by applying transformation from the bones
  22046. * @param skeleton defines the skeleton to apply to current mesh
  22047. * @returns the current mesh
  22048. */
  22049. applySkeleton(skeleton: Skeleton): Mesh;
  22050. /**
  22051. * 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
  22052. * @param meshes defines the list of meshes to scan
  22053. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22054. */
  22055. static MinMax(meshes: AbstractMesh[]): {
  22056. min: Vector3;
  22057. max: Vector3;
  22058. };
  22059. /**
  22060. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22061. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22062. * @returns a vector3
  22063. */
  22064. static Center(meshesOrMinMaxVector: {
  22065. min: Vector3;
  22066. max: Vector3;
  22067. } | AbstractMesh[]): Vector3;
  22068. /**
  22069. * Merge the array of meshes into a single mesh for performance reasons.
  22070. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22071. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22072. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22073. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22074. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22075. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22076. * @returns a new mesh
  22077. */
  22078. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22079. /** @hidden */
  22080. addInstance(instance: InstancedMesh): void;
  22081. /** @hidden */
  22082. removeInstance(instance: InstancedMesh): void;
  22083. }
  22084. }
  22085. declare module "babylonjs/Materials/material" {
  22086. import { IAnimatable } from "babylonjs/Misc/tools";
  22087. import { SmartArray } from "babylonjs/Misc/smartArray";
  22088. import { Observable } from "babylonjs/Misc/observable";
  22089. import { Nullable } from "babylonjs/types";
  22090. import { Scene } from "babylonjs/scene";
  22091. import { Matrix } from "babylonjs/Maths/math";
  22092. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22094. import { Mesh } from "babylonjs/Meshes/mesh";
  22095. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22096. import { Effect } from "babylonjs/Materials/effect";
  22097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22099. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22100. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22101. import { Animation } from "babylonjs/Animations/animation";
  22102. /**
  22103. * Base class for the main features of a material in Babylon.js
  22104. */
  22105. export class Material implements IAnimatable {
  22106. /**
  22107. * Returns the triangle fill mode
  22108. */
  22109. static readonly TriangleFillMode: number;
  22110. /**
  22111. * Returns the wireframe mode
  22112. */
  22113. static readonly WireFrameFillMode: number;
  22114. /**
  22115. * Returns the point fill mode
  22116. */
  22117. static readonly PointFillMode: number;
  22118. /**
  22119. * Returns the point list draw mode
  22120. */
  22121. static readonly PointListDrawMode: number;
  22122. /**
  22123. * Returns the line list draw mode
  22124. */
  22125. static readonly LineListDrawMode: number;
  22126. /**
  22127. * Returns the line loop draw mode
  22128. */
  22129. static readonly LineLoopDrawMode: number;
  22130. /**
  22131. * Returns the line strip draw mode
  22132. */
  22133. static readonly LineStripDrawMode: number;
  22134. /**
  22135. * Returns the triangle strip draw mode
  22136. */
  22137. static readonly TriangleStripDrawMode: number;
  22138. /**
  22139. * Returns the triangle fan draw mode
  22140. */
  22141. static readonly TriangleFanDrawMode: number;
  22142. /**
  22143. * Stores the clock-wise side orientation
  22144. */
  22145. static readonly ClockWiseSideOrientation: number;
  22146. /**
  22147. * Stores the counter clock-wise side orientation
  22148. */
  22149. static readonly CounterClockWiseSideOrientation: number;
  22150. /**
  22151. * The dirty texture flag value
  22152. */
  22153. static readonly TextureDirtyFlag: number;
  22154. /**
  22155. * The dirty light flag value
  22156. */
  22157. static readonly LightDirtyFlag: number;
  22158. /**
  22159. * The dirty fresnel flag value
  22160. */
  22161. static readonly FresnelDirtyFlag: number;
  22162. /**
  22163. * The dirty attribute flag value
  22164. */
  22165. static readonly AttributesDirtyFlag: number;
  22166. /**
  22167. * The dirty misc flag value
  22168. */
  22169. static readonly MiscDirtyFlag: number;
  22170. /**
  22171. * The all dirty flag value
  22172. */
  22173. static readonly AllDirtyFlag: number;
  22174. /**
  22175. * The ID of the material
  22176. */
  22177. id: string;
  22178. /**
  22179. * Gets or sets the unique id of the material
  22180. */
  22181. uniqueId: number;
  22182. /**
  22183. * The name of the material
  22184. */
  22185. name: string;
  22186. /**
  22187. * Gets or sets user defined metadata
  22188. */
  22189. metadata: any;
  22190. /**
  22191. * For internal use only. Please do not use.
  22192. */
  22193. reservedDataStore: any;
  22194. /**
  22195. * Specifies if the ready state should be checked on each call
  22196. */
  22197. checkReadyOnEveryCall: boolean;
  22198. /**
  22199. * Specifies if the ready state should be checked once
  22200. */
  22201. checkReadyOnlyOnce: boolean;
  22202. /**
  22203. * The state of the material
  22204. */
  22205. state: string;
  22206. /**
  22207. * The alpha value of the material
  22208. */
  22209. protected _alpha: number;
  22210. /**
  22211. * List of inspectable custom properties (used by the Inspector)
  22212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22213. */
  22214. inspectableCustomProperties: IInspectable[];
  22215. /**
  22216. * Sets the alpha value of the material
  22217. */
  22218. /**
  22219. * Gets the alpha value of the material
  22220. */
  22221. alpha: number;
  22222. /**
  22223. * Specifies if back face culling is enabled
  22224. */
  22225. protected _backFaceCulling: boolean;
  22226. /**
  22227. * Sets the back-face culling state
  22228. */
  22229. /**
  22230. * Gets the back-face culling state
  22231. */
  22232. backFaceCulling: boolean;
  22233. /**
  22234. * Stores the value for side orientation
  22235. */
  22236. sideOrientation: number;
  22237. /**
  22238. * Callback triggered when the material is compiled
  22239. */
  22240. onCompiled: (effect: Effect) => void;
  22241. /**
  22242. * Callback triggered when an error occurs
  22243. */
  22244. onError: (effect: Effect, errors: string) => void;
  22245. /**
  22246. * Callback triggered to get the render target textures
  22247. */
  22248. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22249. /**
  22250. * Gets a boolean indicating that current material needs to register RTT
  22251. */
  22252. readonly hasRenderTargetTextures: boolean;
  22253. /**
  22254. * Specifies if the material should be serialized
  22255. */
  22256. doNotSerialize: boolean;
  22257. /**
  22258. * @hidden
  22259. */
  22260. _storeEffectOnSubMeshes: boolean;
  22261. /**
  22262. * Stores the animations for the material
  22263. */
  22264. animations: Array<Animation>;
  22265. /**
  22266. * An event triggered when the material is disposed
  22267. */
  22268. onDisposeObservable: Observable<Material>;
  22269. /**
  22270. * An observer which watches for dispose events
  22271. */
  22272. private _onDisposeObserver;
  22273. private _onUnBindObservable;
  22274. /**
  22275. * Called during a dispose event
  22276. */
  22277. onDispose: () => void;
  22278. private _onBindObservable;
  22279. /**
  22280. * An event triggered when the material is bound
  22281. */
  22282. readonly onBindObservable: Observable<AbstractMesh>;
  22283. /**
  22284. * An observer which watches for bind events
  22285. */
  22286. private _onBindObserver;
  22287. /**
  22288. * Called during a bind event
  22289. */
  22290. onBind: (Mesh: AbstractMesh) => void;
  22291. /**
  22292. * An event triggered when the material is unbound
  22293. */
  22294. readonly onUnBindObservable: Observable<Material>;
  22295. /**
  22296. * Stores the value of the alpha mode
  22297. */
  22298. private _alphaMode;
  22299. /**
  22300. * Sets the value of the alpha mode.
  22301. *
  22302. * | Value | Type | Description |
  22303. * | --- | --- | --- |
  22304. * | 0 | ALPHA_DISABLE | |
  22305. * | 1 | ALPHA_ADD | |
  22306. * | 2 | ALPHA_COMBINE | |
  22307. * | 3 | ALPHA_SUBTRACT | |
  22308. * | 4 | ALPHA_MULTIPLY | |
  22309. * | 5 | ALPHA_MAXIMIZED | |
  22310. * | 6 | ALPHA_ONEONE | |
  22311. * | 7 | ALPHA_PREMULTIPLIED | |
  22312. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22313. * | 9 | ALPHA_INTERPOLATE | |
  22314. * | 10 | ALPHA_SCREENMODE | |
  22315. *
  22316. */
  22317. /**
  22318. * Gets the value of the alpha mode
  22319. */
  22320. alphaMode: number;
  22321. /**
  22322. * Stores the state of the need depth pre-pass value
  22323. */
  22324. private _needDepthPrePass;
  22325. /**
  22326. * Sets the need depth pre-pass value
  22327. */
  22328. /**
  22329. * Gets the depth pre-pass value
  22330. */
  22331. needDepthPrePass: boolean;
  22332. /**
  22333. * Specifies if depth writing should be disabled
  22334. */
  22335. disableDepthWrite: boolean;
  22336. /**
  22337. * Specifies if depth writing should be forced
  22338. */
  22339. forceDepthWrite: boolean;
  22340. /**
  22341. * Specifies if there should be a separate pass for culling
  22342. */
  22343. separateCullingPass: boolean;
  22344. /**
  22345. * Stores the state specifing if fog should be enabled
  22346. */
  22347. private _fogEnabled;
  22348. /**
  22349. * Sets the state for enabling fog
  22350. */
  22351. /**
  22352. * Gets the value of the fog enabled state
  22353. */
  22354. fogEnabled: boolean;
  22355. /**
  22356. * Stores the size of points
  22357. */
  22358. pointSize: number;
  22359. /**
  22360. * Stores the z offset value
  22361. */
  22362. zOffset: number;
  22363. /**
  22364. * Gets a value specifying if wireframe mode is enabled
  22365. */
  22366. /**
  22367. * Sets the state of wireframe mode
  22368. */
  22369. wireframe: boolean;
  22370. /**
  22371. * Gets the value specifying if point clouds are enabled
  22372. */
  22373. /**
  22374. * Sets the state of point cloud mode
  22375. */
  22376. pointsCloud: boolean;
  22377. /**
  22378. * Gets the material fill mode
  22379. */
  22380. /**
  22381. * Sets the material fill mode
  22382. */
  22383. fillMode: number;
  22384. /**
  22385. * @hidden
  22386. * Stores the effects for the material
  22387. */
  22388. _effect: Nullable<Effect>;
  22389. /**
  22390. * @hidden
  22391. * Specifies if the material was previously ready
  22392. */
  22393. _wasPreviouslyReady: boolean;
  22394. /**
  22395. * Specifies if uniform buffers should be used
  22396. */
  22397. private _useUBO;
  22398. /**
  22399. * Stores a reference to the scene
  22400. */
  22401. private _scene;
  22402. /**
  22403. * Stores the fill mode state
  22404. */
  22405. private _fillMode;
  22406. /**
  22407. * Specifies if the depth write state should be cached
  22408. */
  22409. private _cachedDepthWriteState;
  22410. /**
  22411. * Stores the uniform buffer
  22412. */
  22413. protected _uniformBuffer: UniformBuffer;
  22414. /** @hidden */
  22415. _indexInSceneMaterialArray: number;
  22416. /** @hidden */
  22417. meshMap: Nullable<{
  22418. [id: string]: AbstractMesh | undefined;
  22419. }>;
  22420. /**
  22421. * Creates a material instance
  22422. * @param name defines the name of the material
  22423. * @param scene defines the scene to reference
  22424. * @param doNotAdd specifies if the material should be added to the scene
  22425. */
  22426. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22427. /**
  22428. * Returns a string representation of the current material
  22429. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22430. * @returns a string with material information
  22431. */
  22432. toString(fullDetails?: boolean): string;
  22433. /**
  22434. * Gets the class name of the material
  22435. * @returns a string with the class name of the material
  22436. */
  22437. getClassName(): string;
  22438. /**
  22439. * Specifies if updates for the material been locked
  22440. */
  22441. readonly isFrozen: boolean;
  22442. /**
  22443. * Locks updates for the material
  22444. */
  22445. freeze(): void;
  22446. /**
  22447. * Unlocks updates for the material
  22448. */
  22449. unfreeze(): void;
  22450. /**
  22451. * Specifies if the material is ready to be used
  22452. * @param mesh defines the mesh to check
  22453. * @param useInstances specifies if instances should be used
  22454. * @returns a boolean indicating if the material is ready to be used
  22455. */
  22456. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22457. /**
  22458. * Specifies that the submesh is ready to be used
  22459. * @param mesh defines the mesh to check
  22460. * @param subMesh defines which submesh to check
  22461. * @param useInstances specifies that instances should be used
  22462. * @returns a boolean indicating that the submesh is ready or not
  22463. */
  22464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22465. /**
  22466. * Returns the material effect
  22467. * @returns the effect associated with the material
  22468. */
  22469. getEffect(): Nullable<Effect>;
  22470. /**
  22471. * Returns the current scene
  22472. * @returns a Scene
  22473. */
  22474. getScene(): Scene;
  22475. /**
  22476. * Specifies if the material will require alpha blending
  22477. * @returns a boolean specifying if alpha blending is needed
  22478. */
  22479. needAlphaBlending(): boolean;
  22480. /**
  22481. * Specifies if the mesh will require alpha blending
  22482. * @param mesh defines the mesh to check
  22483. * @returns a boolean specifying if alpha blending is needed for the mesh
  22484. */
  22485. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22486. /**
  22487. * Specifies if this material should be rendered in alpha test mode
  22488. * @returns a boolean specifying if an alpha test is needed.
  22489. */
  22490. needAlphaTesting(): boolean;
  22491. /**
  22492. * Gets the texture used for the alpha test
  22493. * @returns the texture to use for alpha testing
  22494. */
  22495. getAlphaTestTexture(): Nullable<BaseTexture>;
  22496. /**
  22497. * Marks the material to indicate that it needs to be re-calculated
  22498. */
  22499. markDirty(): void;
  22500. /** @hidden */
  22501. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22502. /**
  22503. * Binds the material to the mesh
  22504. * @param world defines the world transformation matrix
  22505. * @param mesh defines the mesh to bind the material to
  22506. */
  22507. bind(world: Matrix, mesh?: Mesh): void;
  22508. /**
  22509. * Binds the submesh to the material
  22510. * @param world defines the world transformation matrix
  22511. * @param mesh defines the mesh containing the submesh
  22512. * @param subMesh defines the submesh to bind the material to
  22513. */
  22514. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22515. /**
  22516. * Binds the world matrix to the material
  22517. * @param world defines the world transformation matrix
  22518. */
  22519. bindOnlyWorldMatrix(world: Matrix): void;
  22520. /**
  22521. * Binds the scene's uniform buffer to the effect.
  22522. * @param effect defines the effect to bind to the scene uniform buffer
  22523. * @param sceneUbo defines the uniform buffer storing scene data
  22524. */
  22525. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22526. /**
  22527. * Binds the view matrix to the effect
  22528. * @param effect defines the effect to bind the view matrix to
  22529. */
  22530. bindView(effect: Effect): void;
  22531. /**
  22532. * Binds the view projection matrix to the effect
  22533. * @param effect defines the effect to bind the view projection matrix to
  22534. */
  22535. bindViewProjection(effect: Effect): void;
  22536. /**
  22537. * Specifies if material alpha testing should be turned on for the mesh
  22538. * @param mesh defines the mesh to check
  22539. */
  22540. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22541. /**
  22542. * Processes to execute after binding the material to a mesh
  22543. * @param mesh defines the rendered mesh
  22544. */
  22545. protected _afterBind(mesh?: Mesh): void;
  22546. /**
  22547. * Unbinds the material from the mesh
  22548. */
  22549. unbind(): void;
  22550. /**
  22551. * Gets the active textures from the material
  22552. * @returns an array of textures
  22553. */
  22554. getActiveTextures(): BaseTexture[];
  22555. /**
  22556. * Specifies if the material uses a texture
  22557. * @param texture defines the texture to check against the material
  22558. * @returns a boolean specifying if the material uses the texture
  22559. */
  22560. hasTexture(texture: BaseTexture): boolean;
  22561. /**
  22562. * Makes a duplicate of the material, and gives it a new name
  22563. * @param name defines the new name for the duplicated material
  22564. * @returns the cloned material
  22565. */
  22566. clone(name: string): Nullable<Material>;
  22567. /**
  22568. * Gets the meshes bound to the material
  22569. * @returns an array of meshes bound to the material
  22570. */
  22571. getBindedMeshes(): AbstractMesh[];
  22572. /**
  22573. * Force shader compilation
  22574. * @param mesh defines the mesh associated with this material
  22575. * @param onCompiled defines a function to execute once the material is compiled
  22576. * @param options defines the options to configure the compilation
  22577. */
  22578. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22579. clipPlane: boolean;
  22580. }>): void;
  22581. /**
  22582. * Force shader compilation
  22583. * @param mesh defines the mesh that will use this material
  22584. * @param options defines additional options for compiling the shaders
  22585. * @returns a promise that resolves when the compilation completes
  22586. */
  22587. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22588. clipPlane: boolean;
  22589. }>): Promise<void>;
  22590. private static readonly _ImageProcessingDirtyCallBack;
  22591. private static readonly _TextureDirtyCallBack;
  22592. private static readonly _FresnelDirtyCallBack;
  22593. private static readonly _MiscDirtyCallBack;
  22594. private static readonly _LightsDirtyCallBack;
  22595. private static readonly _AttributeDirtyCallBack;
  22596. private static _FresnelAndMiscDirtyCallBack;
  22597. private static _TextureAndMiscDirtyCallBack;
  22598. private static readonly _DirtyCallbackArray;
  22599. private static readonly _RunDirtyCallBacks;
  22600. /**
  22601. * Marks a define in the material to indicate that it needs to be re-computed
  22602. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22603. */
  22604. markAsDirty(flag: number): void;
  22605. /**
  22606. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22607. * @param func defines a function which checks material defines against the submeshes
  22608. */
  22609. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22610. /**
  22611. * Indicates that image processing needs to be re-calculated for all submeshes
  22612. */
  22613. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22614. /**
  22615. * Indicates that textures need to be re-calculated for all submeshes
  22616. */
  22617. protected _markAllSubMeshesAsTexturesDirty(): void;
  22618. /**
  22619. * Indicates that fresnel needs to be re-calculated for all submeshes
  22620. */
  22621. protected _markAllSubMeshesAsFresnelDirty(): void;
  22622. /**
  22623. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22624. */
  22625. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22626. /**
  22627. * Indicates that lights need to be re-calculated for all submeshes
  22628. */
  22629. protected _markAllSubMeshesAsLightsDirty(): void;
  22630. /**
  22631. * Indicates that attributes need to be re-calculated for all submeshes
  22632. */
  22633. protected _markAllSubMeshesAsAttributesDirty(): void;
  22634. /**
  22635. * Indicates that misc needs to be re-calculated for all submeshes
  22636. */
  22637. protected _markAllSubMeshesAsMiscDirty(): void;
  22638. /**
  22639. * Indicates that textures and misc need to be re-calculated for all submeshes
  22640. */
  22641. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22642. /**
  22643. * Disposes the material
  22644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22647. */
  22648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22649. /** @hidden */
  22650. private releaseVertexArrayObject;
  22651. /**
  22652. * Serializes this material
  22653. * @returns the serialized material object
  22654. */
  22655. serialize(): any;
  22656. /**
  22657. * Creates a material from parsed material data
  22658. * @param parsedMaterial defines parsed material data
  22659. * @param scene defines the hosting scene
  22660. * @param rootUrl defines the root URL to use to load textures
  22661. * @returns a new material
  22662. */
  22663. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22664. }
  22665. }
  22666. declare module "babylonjs/Meshes/subMesh" {
  22667. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22668. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22669. import { Engine } from "babylonjs/Engines/engine";
  22670. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22671. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22672. import { Effect } from "babylonjs/Materials/effect";
  22673. import { Collider } from "babylonjs/Collisions/collider";
  22674. import { Material } from "babylonjs/Materials/material";
  22675. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22677. import { Mesh } from "babylonjs/Meshes/mesh";
  22678. import { Ray } from "babylonjs/Culling/ray";
  22679. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22680. /**
  22681. * Base class for submeshes
  22682. */
  22683. export class BaseSubMesh {
  22684. /** @hidden */
  22685. _materialDefines: Nullable<MaterialDefines>;
  22686. /** @hidden */
  22687. _materialEffect: Nullable<Effect>;
  22688. /**
  22689. * Gets associated effect
  22690. */
  22691. readonly effect: Nullable<Effect>;
  22692. /**
  22693. * Sets associated effect (effect used to render this submesh)
  22694. * @param effect defines the effect to associate with
  22695. * @param defines defines the set of defines used to compile this effect
  22696. */
  22697. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22698. }
  22699. /**
  22700. * Defines a subdivision inside a mesh
  22701. */
  22702. export class SubMesh extends BaseSubMesh implements ICullable {
  22703. /** the material index to use */
  22704. materialIndex: number;
  22705. /** vertex index start */
  22706. verticesStart: number;
  22707. /** vertices count */
  22708. verticesCount: number;
  22709. /** index start */
  22710. indexStart: number;
  22711. /** indices count */
  22712. indexCount: number;
  22713. /** @hidden */
  22714. _linesIndexCount: number;
  22715. private _mesh;
  22716. private _renderingMesh;
  22717. private _boundingInfo;
  22718. private _linesIndexBuffer;
  22719. /** @hidden */
  22720. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22721. /** @hidden */
  22722. _trianglePlanes: Plane[];
  22723. /** @hidden */
  22724. _lastColliderTransformMatrix: Matrix;
  22725. /** @hidden */
  22726. _renderId: number;
  22727. /** @hidden */
  22728. _alphaIndex: number;
  22729. /** @hidden */
  22730. _distanceToCamera: number;
  22731. /** @hidden */
  22732. _id: number;
  22733. private _currentMaterial;
  22734. /**
  22735. * Add a new submesh to a mesh
  22736. * @param materialIndex defines the material index to use
  22737. * @param verticesStart defines vertex index start
  22738. * @param verticesCount defines vertices count
  22739. * @param indexStart defines index start
  22740. * @param indexCount defines indices count
  22741. * @param mesh defines the parent mesh
  22742. * @param renderingMesh defines an optional rendering mesh
  22743. * @param createBoundingBox defines if bounding box should be created for this submesh
  22744. * @returns the new submesh
  22745. */
  22746. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22747. /**
  22748. * Creates a new submesh
  22749. * @param materialIndex defines the material index to use
  22750. * @param verticesStart defines vertex index start
  22751. * @param verticesCount defines vertices count
  22752. * @param indexStart defines index start
  22753. * @param indexCount defines indices count
  22754. * @param mesh defines the parent mesh
  22755. * @param renderingMesh defines an optional rendering mesh
  22756. * @param createBoundingBox defines if bounding box should be created for this submesh
  22757. */
  22758. constructor(
  22759. /** the material index to use */
  22760. materialIndex: number,
  22761. /** vertex index start */
  22762. verticesStart: number,
  22763. /** vertices count */
  22764. verticesCount: number,
  22765. /** index start */
  22766. indexStart: number,
  22767. /** indices count */
  22768. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22769. /**
  22770. * Returns true if this submesh covers the entire parent mesh
  22771. * @ignorenaming
  22772. */
  22773. readonly IsGlobal: boolean;
  22774. /**
  22775. * Returns the submesh BoudingInfo object
  22776. * @returns current bounding info (or mesh's one if the submesh is global)
  22777. */
  22778. getBoundingInfo(): BoundingInfo;
  22779. /**
  22780. * Sets the submesh BoundingInfo
  22781. * @param boundingInfo defines the new bounding info to use
  22782. * @returns the SubMesh
  22783. */
  22784. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22785. /**
  22786. * Returns the mesh of the current submesh
  22787. * @return the parent mesh
  22788. */
  22789. getMesh(): AbstractMesh;
  22790. /**
  22791. * Returns the rendering mesh of the submesh
  22792. * @returns the rendering mesh (could be different from parent mesh)
  22793. */
  22794. getRenderingMesh(): Mesh;
  22795. /**
  22796. * Returns the submesh material
  22797. * @returns null or the current material
  22798. */
  22799. getMaterial(): Nullable<Material>;
  22800. /**
  22801. * Sets a new updated BoundingInfo object to the submesh
  22802. * @returns the SubMesh
  22803. */
  22804. refreshBoundingInfo(): SubMesh;
  22805. /** @hidden */
  22806. _checkCollision(collider: Collider): boolean;
  22807. /**
  22808. * Updates the submesh BoundingInfo
  22809. * @param world defines the world matrix to use to update the bounding info
  22810. * @returns the submesh
  22811. */
  22812. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22813. /**
  22814. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22815. * @param frustumPlanes defines the frustum planes
  22816. * @returns true if the submesh is intersecting with the frustum
  22817. */
  22818. isInFrustum(frustumPlanes: Plane[]): boolean;
  22819. /**
  22820. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22821. * @param frustumPlanes defines the frustum planes
  22822. * @returns true if the submesh is inside the frustum
  22823. */
  22824. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22825. /**
  22826. * Renders the submesh
  22827. * @param enableAlphaMode defines if alpha needs to be used
  22828. * @returns the submesh
  22829. */
  22830. render(enableAlphaMode: boolean): SubMesh;
  22831. /**
  22832. * @hidden
  22833. */
  22834. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22835. /**
  22836. * Checks if the submesh intersects with a ray
  22837. * @param ray defines the ray to test
  22838. * @returns true is the passed ray intersects the submesh bounding box
  22839. */
  22840. canIntersects(ray: Ray): boolean;
  22841. /**
  22842. * Intersects current submesh with a ray
  22843. * @param ray defines the ray to test
  22844. * @param positions defines mesh's positions array
  22845. * @param indices defines mesh's indices array
  22846. * @param fastCheck defines if only bounding info should be used
  22847. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22848. * @returns intersection info or null if no intersection
  22849. */
  22850. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22851. /** @hidden */
  22852. private _intersectLines;
  22853. /** @hidden */
  22854. private _intersectTriangles;
  22855. /** @hidden */
  22856. _rebuild(): void;
  22857. /**
  22858. * Creates a new submesh from the passed mesh
  22859. * @param newMesh defines the new hosting mesh
  22860. * @param newRenderingMesh defines an optional rendering mesh
  22861. * @returns the new submesh
  22862. */
  22863. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22864. /**
  22865. * Release associated resources
  22866. */
  22867. dispose(): void;
  22868. /**
  22869. * Gets the class name
  22870. * @returns the string "SubMesh".
  22871. */
  22872. getClassName(): string;
  22873. /**
  22874. * Creates a new submesh from indices data
  22875. * @param materialIndex the index of the main mesh material
  22876. * @param startIndex the index where to start the copy in the mesh indices array
  22877. * @param indexCount the number of indices to copy then from the startIndex
  22878. * @param mesh the main mesh to create the submesh from
  22879. * @param renderingMesh the optional rendering mesh
  22880. * @returns a new submesh
  22881. */
  22882. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Meshes/geometry" {
  22886. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22887. import { Scene } from "babylonjs/scene";
  22888. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22889. import { Engine } from "babylonjs/Engines/engine";
  22890. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22891. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22892. import { Effect } from "babylonjs/Materials/effect";
  22893. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22894. import { Mesh } from "babylonjs/Meshes/mesh";
  22895. /**
  22896. * Class used to store geometry data (vertex buffers + index buffer)
  22897. */
  22898. export class Geometry implements IGetSetVerticesData {
  22899. /**
  22900. * Gets or sets the ID of the geometry
  22901. */
  22902. id: string;
  22903. /**
  22904. * Gets or sets the unique ID of the geometry
  22905. */
  22906. uniqueId: number;
  22907. /**
  22908. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22909. */
  22910. delayLoadState: number;
  22911. /**
  22912. * Gets the file containing the data to load when running in delay load state
  22913. */
  22914. delayLoadingFile: Nullable<string>;
  22915. /**
  22916. * Callback called when the geometry is updated
  22917. */
  22918. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22919. private _scene;
  22920. private _engine;
  22921. private _meshes;
  22922. private _totalVertices;
  22923. /** @hidden */
  22924. _indices: IndicesArray;
  22925. /** @hidden */
  22926. _vertexBuffers: {
  22927. [key: string]: VertexBuffer;
  22928. };
  22929. private _isDisposed;
  22930. private _extend;
  22931. private _boundingBias;
  22932. /** @hidden */
  22933. _delayInfo: Array<string>;
  22934. private _indexBuffer;
  22935. private _indexBufferIsUpdatable;
  22936. /** @hidden */
  22937. _boundingInfo: Nullable<BoundingInfo>;
  22938. /** @hidden */
  22939. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22940. /** @hidden */
  22941. _softwareSkinningFrameId: number;
  22942. private _vertexArrayObjects;
  22943. private _updatable;
  22944. /** @hidden */
  22945. _positions: Nullable<Vector3[]>;
  22946. /**
  22947. * 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
  22948. */
  22949. /**
  22950. * 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
  22951. */
  22952. boundingBias: Vector2;
  22953. /**
  22954. * Static function used to attach a new empty geometry to a mesh
  22955. * @param mesh defines the mesh to attach the geometry to
  22956. * @returns the new Geometry
  22957. */
  22958. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22959. /**
  22960. * Creates a new geometry
  22961. * @param id defines the unique ID
  22962. * @param scene defines the hosting scene
  22963. * @param vertexData defines the VertexData used to get geometry data
  22964. * @param updatable defines if geometry must be updatable (false by default)
  22965. * @param mesh defines the mesh that will be associated with the geometry
  22966. */
  22967. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22968. /**
  22969. * Gets the current extend of the geometry
  22970. */
  22971. readonly extend: {
  22972. minimum: Vector3;
  22973. maximum: Vector3;
  22974. };
  22975. /**
  22976. * Gets the hosting scene
  22977. * @returns the hosting Scene
  22978. */
  22979. getScene(): Scene;
  22980. /**
  22981. * Gets the hosting engine
  22982. * @returns the hosting Engine
  22983. */
  22984. getEngine(): Engine;
  22985. /**
  22986. * Defines if the geometry is ready to use
  22987. * @returns true if the geometry is ready to be used
  22988. */
  22989. isReady(): boolean;
  22990. /**
  22991. * Gets a value indicating that the geometry should not be serialized
  22992. */
  22993. readonly doNotSerialize: boolean;
  22994. /** @hidden */
  22995. _rebuild(): void;
  22996. /**
  22997. * Affects all geometry data in one call
  22998. * @param vertexData defines the geometry data
  22999. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23000. */
  23001. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23002. /**
  23003. * Set specific vertex data
  23004. * @param kind defines the data kind (Position, normal, etc...)
  23005. * @param data defines the vertex data to use
  23006. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23007. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23008. */
  23009. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23010. /**
  23011. * Removes a specific vertex data
  23012. * @param kind defines the data kind (Position, normal, etc...)
  23013. */
  23014. removeVerticesData(kind: string): void;
  23015. /**
  23016. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23017. * @param buffer defines the vertex buffer to use
  23018. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23019. */
  23020. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23021. /**
  23022. * Update a specific vertex buffer
  23023. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23024. * It will do nothing if the buffer is not updatable
  23025. * @param kind defines the data kind (Position, normal, etc...)
  23026. * @param data defines the data to use
  23027. * @param offset defines the offset in the target buffer where to store the data
  23028. * @param useBytes set to true if the offset is in bytes
  23029. */
  23030. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23031. /**
  23032. * Update a specific vertex buffer
  23033. * This function will create a new buffer if the current one is not updatable
  23034. * @param kind defines the data kind (Position, normal, etc...)
  23035. * @param data defines the data to use
  23036. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23037. */
  23038. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23039. private _updateBoundingInfo;
  23040. /** @hidden */
  23041. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23042. /**
  23043. * Gets total number of vertices
  23044. * @returns the total number of vertices
  23045. */
  23046. getTotalVertices(): number;
  23047. /**
  23048. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23049. * @param kind defines the data kind (Position, normal, etc...)
  23050. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23051. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23052. * @returns a float array containing vertex data
  23053. */
  23054. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23055. /**
  23056. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23057. * @param kind defines the data kind (Position, normal, etc...)
  23058. * @returns true if the vertex buffer with the specified kind is updatable
  23059. */
  23060. isVertexBufferUpdatable(kind: string): boolean;
  23061. /**
  23062. * Gets a specific vertex buffer
  23063. * @param kind defines the data kind (Position, normal, etc...)
  23064. * @returns a VertexBuffer
  23065. */
  23066. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23067. /**
  23068. * Returns all vertex buffers
  23069. * @return an object holding all vertex buffers indexed by kind
  23070. */
  23071. getVertexBuffers(): Nullable<{
  23072. [key: string]: VertexBuffer;
  23073. }>;
  23074. /**
  23075. * Gets a boolean indicating if specific vertex buffer is present
  23076. * @param kind defines the data kind (Position, normal, etc...)
  23077. * @returns true if data is present
  23078. */
  23079. isVerticesDataPresent(kind: string): boolean;
  23080. /**
  23081. * Gets a list of all attached data kinds (Position, normal, etc...)
  23082. * @returns a list of string containing all kinds
  23083. */
  23084. getVerticesDataKinds(): string[];
  23085. /**
  23086. * Update index buffer
  23087. * @param indices defines the indices to store in the index buffer
  23088. * @param offset defines the offset in the target buffer where to store the data
  23089. * @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)
  23090. */
  23091. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23092. /**
  23093. * Creates a new index buffer
  23094. * @param indices defines the indices to store in the index buffer
  23095. * @param totalVertices defines the total number of vertices (could be null)
  23096. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23097. */
  23098. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23099. /**
  23100. * Return the total number of indices
  23101. * @returns the total number of indices
  23102. */
  23103. getTotalIndices(): number;
  23104. /**
  23105. * Gets the index buffer array
  23106. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23107. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23108. * @returns the index buffer array
  23109. */
  23110. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23111. /**
  23112. * Gets the index buffer
  23113. * @return the index buffer
  23114. */
  23115. getIndexBuffer(): Nullable<WebGLBuffer>;
  23116. /** @hidden */
  23117. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23118. /**
  23119. * Release the associated resources for a specific mesh
  23120. * @param mesh defines the source mesh
  23121. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23122. */
  23123. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23124. /**
  23125. * Apply current geometry to a given mesh
  23126. * @param mesh defines the mesh to apply geometry to
  23127. */
  23128. applyToMesh(mesh: Mesh): void;
  23129. private _updateExtend;
  23130. private _applyToMesh;
  23131. private notifyUpdate;
  23132. /**
  23133. * Load the geometry if it was flagged as delay loaded
  23134. * @param scene defines the hosting scene
  23135. * @param onLoaded defines a callback called when the geometry is loaded
  23136. */
  23137. load(scene: Scene, onLoaded?: () => void): void;
  23138. private _queueLoad;
  23139. /**
  23140. * Invert the geometry to move from a right handed system to a left handed one.
  23141. */
  23142. toLeftHanded(): void;
  23143. /** @hidden */
  23144. _resetPointsArrayCache(): void;
  23145. /** @hidden */
  23146. _generatePointsArray(): boolean;
  23147. /**
  23148. * Gets a value indicating if the geometry is disposed
  23149. * @returns true if the geometry was disposed
  23150. */
  23151. isDisposed(): boolean;
  23152. private _disposeVertexArrayObjects;
  23153. /**
  23154. * Free all associated resources
  23155. */
  23156. dispose(): void;
  23157. /**
  23158. * Clone the current geometry into a new geometry
  23159. * @param id defines the unique ID of the new geometry
  23160. * @returns a new geometry object
  23161. */
  23162. copy(id: string): Geometry;
  23163. /**
  23164. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23165. * @return a JSON representation of the current geometry data (without the vertices data)
  23166. */
  23167. serialize(): any;
  23168. private toNumberArray;
  23169. /**
  23170. * Serialize all vertices data into a JSON oject
  23171. * @returns a JSON representation of the current geometry data
  23172. */
  23173. serializeVerticeData(): any;
  23174. /**
  23175. * Extracts a clone of a mesh geometry
  23176. * @param mesh defines the source mesh
  23177. * @param id defines the unique ID of the new geometry object
  23178. * @returns the new geometry object
  23179. */
  23180. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23181. /**
  23182. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23183. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23184. * Be aware Math.random() could cause collisions, but:
  23185. * "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"
  23186. * @returns a string containing a new GUID
  23187. */
  23188. static RandomId(): string;
  23189. /** @hidden */
  23190. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23191. private static _CleanMatricesWeights;
  23192. /**
  23193. * Create a new geometry from persisted data (Using .babylon file format)
  23194. * @param parsedVertexData defines the persisted data
  23195. * @param scene defines the hosting scene
  23196. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23197. * @returns the new geometry object
  23198. */
  23199. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23200. }
  23201. }
  23202. declare module "babylonjs/Meshes/mesh.vertexData" {
  23203. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23204. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23205. import { Geometry } from "babylonjs/Meshes/geometry";
  23206. import { Mesh } from "babylonjs/Meshes/mesh";
  23207. /**
  23208. * Define an interface for all classes that will get and set the data on vertices
  23209. */
  23210. export interface IGetSetVerticesData {
  23211. /**
  23212. * Gets a boolean indicating if specific vertex data is present
  23213. * @param kind defines the vertex data kind to use
  23214. * @returns true is data kind is present
  23215. */
  23216. isVerticesDataPresent(kind: string): boolean;
  23217. /**
  23218. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23219. * @param kind defines the data kind (Position, normal, etc...)
  23220. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23221. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23222. * @returns a float array containing vertex data
  23223. */
  23224. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23225. /**
  23226. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23227. * @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.
  23228. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23229. * @returns the indices array or an empty array if the mesh has no geometry
  23230. */
  23231. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23232. /**
  23233. * Set specific vertex data
  23234. * @param kind defines the data kind (Position, normal, etc...)
  23235. * @param data defines the vertex data to use
  23236. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23237. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23238. */
  23239. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23240. /**
  23241. * Update a specific associated vertex buffer
  23242. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23243. * - VertexBuffer.PositionKind
  23244. * - VertexBuffer.UVKind
  23245. * - VertexBuffer.UV2Kind
  23246. * - VertexBuffer.UV3Kind
  23247. * - VertexBuffer.UV4Kind
  23248. * - VertexBuffer.UV5Kind
  23249. * - VertexBuffer.UV6Kind
  23250. * - VertexBuffer.ColorKind
  23251. * - VertexBuffer.MatricesIndicesKind
  23252. * - VertexBuffer.MatricesIndicesExtraKind
  23253. * - VertexBuffer.MatricesWeightsKind
  23254. * - VertexBuffer.MatricesWeightsExtraKind
  23255. * @param data defines the data source
  23256. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23257. * @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)
  23258. */
  23259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23260. /**
  23261. * Creates a new index buffer
  23262. * @param indices defines the indices to store in the index buffer
  23263. * @param totalVertices defines the total number of vertices (could be null)
  23264. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23265. */
  23266. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23267. }
  23268. /**
  23269. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23270. */
  23271. export class VertexData {
  23272. /**
  23273. * Mesh side orientation : usually the external or front surface
  23274. */
  23275. static readonly FRONTSIDE: number;
  23276. /**
  23277. * Mesh side orientation : usually the internal or back surface
  23278. */
  23279. static readonly BACKSIDE: number;
  23280. /**
  23281. * Mesh side orientation : both internal and external or front and back surfaces
  23282. */
  23283. static readonly DOUBLESIDE: number;
  23284. /**
  23285. * Mesh side orientation : by default, `FRONTSIDE`
  23286. */
  23287. static readonly DEFAULTSIDE: number;
  23288. /**
  23289. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23290. */
  23291. positions: Nullable<FloatArray>;
  23292. /**
  23293. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23294. */
  23295. normals: Nullable<FloatArray>;
  23296. /**
  23297. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23298. */
  23299. tangents: Nullable<FloatArray>;
  23300. /**
  23301. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23302. */
  23303. uvs: Nullable<FloatArray>;
  23304. /**
  23305. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23306. */
  23307. uvs2: Nullable<FloatArray>;
  23308. /**
  23309. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23310. */
  23311. uvs3: Nullable<FloatArray>;
  23312. /**
  23313. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23314. */
  23315. uvs4: Nullable<FloatArray>;
  23316. /**
  23317. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23318. */
  23319. uvs5: Nullable<FloatArray>;
  23320. /**
  23321. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23322. */
  23323. uvs6: Nullable<FloatArray>;
  23324. /**
  23325. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23326. */
  23327. colors: Nullable<FloatArray>;
  23328. /**
  23329. * 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).
  23330. */
  23331. matricesIndices: Nullable<FloatArray>;
  23332. /**
  23333. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23334. */
  23335. matricesWeights: Nullable<FloatArray>;
  23336. /**
  23337. * An array extending the number of possible indices
  23338. */
  23339. matricesIndicesExtra: Nullable<FloatArray>;
  23340. /**
  23341. * An array extending the number of possible weights when the number of indices is extended
  23342. */
  23343. matricesWeightsExtra: Nullable<FloatArray>;
  23344. /**
  23345. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23346. */
  23347. indices: Nullable<IndicesArray>;
  23348. /**
  23349. * Uses the passed data array to set the set the values for the specified kind of data
  23350. * @param data a linear array of floating numbers
  23351. * @param kind the type of data that is being set, eg positions, colors etc
  23352. */
  23353. set(data: FloatArray, kind: string): void;
  23354. /**
  23355. * Associates the vertexData to the passed Mesh.
  23356. * Sets it as updatable or not (default `false`)
  23357. * @param mesh the mesh the vertexData is applied to
  23358. * @param updatable when used and having the value true allows new data to update the vertexData
  23359. * @returns the VertexData
  23360. */
  23361. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23362. /**
  23363. * Associates the vertexData to the passed Geometry.
  23364. * Sets it as updatable or not (default `false`)
  23365. * @param geometry the geometry the vertexData is applied to
  23366. * @param updatable when used and having the value true allows new data to update the vertexData
  23367. * @returns VertexData
  23368. */
  23369. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23370. /**
  23371. * Updates the associated mesh
  23372. * @param mesh the mesh to be updated
  23373. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23374. * @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
  23375. * @returns VertexData
  23376. */
  23377. updateMesh(mesh: Mesh): VertexData;
  23378. /**
  23379. * Updates the associated geometry
  23380. * @param geometry the geometry to be updated
  23381. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23382. * @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
  23383. * @returns VertexData.
  23384. */
  23385. updateGeometry(geometry: Geometry): VertexData;
  23386. private _applyTo;
  23387. private _update;
  23388. /**
  23389. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23390. * @param matrix the transforming matrix
  23391. * @returns the VertexData
  23392. */
  23393. transform(matrix: Matrix): VertexData;
  23394. /**
  23395. * Merges the passed VertexData into the current one
  23396. * @param other the VertexData to be merged into the current one
  23397. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23398. * @returns the modified VertexData
  23399. */
  23400. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23401. private _mergeElement;
  23402. private _validate;
  23403. /**
  23404. * Serializes the VertexData
  23405. * @returns a serialized object
  23406. */
  23407. serialize(): any;
  23408. /**
  23409. * Extracts the vertexData from a mesh
  23410. * @param mesh the mesh from which to extract the VertexData
  23411. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23412. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23413. * @returns the object VertexData associated to the passed mesh
  23414. */
  23415. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23416. /**
  23417. * Extracts the vertexData from the geometry
  23418. * @param geometry the geometry from which to extract the VertexData
  23419. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23420. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23421. * @returns the object VertexData associated to the passed mesh
  23422. */
  23423. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23424. private static _ExtractFrom;
  23425. /**
  23426. * Creates the VertexData for a Ribbon
  23427. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23428. * * pathArray array of paths, each of which an array of successive Vector3
  23429. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23430. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23431. * * 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
  23432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23433. * * 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)
  23434. * * 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)
  23435. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23436. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23437. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23438. * @returns the VertexData of the ribbon
  23439. */
  23440. static CreateRibbon(options: {
  23441. pathArray: Vector3[][];
  23442. closeArray?: boolean;
  23443. closePath?: boolean;
  23444. offset?: number;
  23445. sideOrientation?: number;
  23446. frontUVs?: Vector4;
  23447. backUVs?: Vector4;
  23448. invertUV?: boolean;
  23449. uvs?: Vector2[];
  23450. colors?: Color4[];
  23451. }): VertexData;
  23452. /**
  23453. * Creates the VertexData for a box
  23454. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23455. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23456. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23457. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23458. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23459. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23460. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23462. * * 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)
  23463. * * 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)
  23464. * @returns the VertexData of the box
  23465. */
  23466. static CreateBox(options: {
  23467. size?: number;
  23468. width?: number;
  23469. height?: number;
  23470. depth?: number;
  23471. faceUV?: Vector4[];
  23472. faceColors?: Color4[];
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. }): VertexData;
  23477. /**
  23478. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23479. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23480. * * segments sets the number of horizontal strips optional, default 32
  23481. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23482. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23483. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23484. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23485. * * 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
  23486. * * 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
  23487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23488. * * 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)
  23489. * * 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)
  23490. * @returns the VertexData of the ellipsoid
  23491. */
  23492. static CreateSphere(options: {
  23493. segments?: number;
  23494. diameter?: number;
  23495. diameterX?: number;
  23496. diameterY?: number;
  23497. diameterZ?: number;
  23498. arc?: number;
  23499. slice?: number;
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. }): VertexData;
  23504. /**
  23505. * Creates the VertexData for a cylinder, cone or prism
  23506. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23507. * * height sets the height (y direction) of the cylinder, optional, default 2
  23508. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23509. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23510. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23511. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23512. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23513. * * 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
  23514. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23515. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23516. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23517. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23519. * * 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)
  23520. * * 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)
  23521. * @returns the VertexData of the cylinder, cone or prism
  23522. */
  23523. static CreateCylinder(options: {
  23524. height?: number;
  23525. diameterTop?: number;
  23526. diameterBottom?: number;
  23527. diameter?: number;
  23528. tessellation?: number;
  23529. subdivisions?: number;
  23530. arc?: number;
  23531. faceColors?: Color4[];
  23532. faceUV?: Vector4[];
  23533. hasRings?: boolean;
  23534. enclose?: boolean;
  23535. sideOrientation?: number;
  23536. frontUVs?: Vector4;
  23537. backUVs?: Vector4;
  23538. }): VertexData;
  23539. /**
  23540. * Creates the VertexData for a torus
  23541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23542. * * diameter the diameter of the torus, optional default 1
  23543. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23544. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23546. * * 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)
  23547. * * 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)
  23548. * @returns the VertexData of the torus
  23549. */
  23550. static CreateTorus(options: {
  23551. diameter?: number;
  23552. thickness?: number;
  23553. tessellation?: number;
  23554. sideOrientation?: number;
  23555. frontUVs?: Vector4;
  23556. backUVs?: Vector4;
  23557. }): VertexData;
  23558. /**
  23559. * Creates the VertexData of the LineSystem
  23560. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23561. * - lines an array of lines, each line being an array of successive Vector3
  23562. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23563. * @returns the VertexData of the LineSystem
  23564. */
  23565. static CreateLineSystem(options: {
  23566. lines: Vector3[][];
  23567. colors?: Nullable<Color4[][]>;
  23568. }): VertexData;
  23569. /**
  23570. * Create the VertexData for a DashedLines
  23571. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23572. * - points an array successive Vector3
  23573. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23574. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23575. * - dashNb the intended total number of dashes, optional, default 200
  23576. * @returns the VertexData for the DashedLines
  23577. */
  23578. static CreateDashedLines(options: {
  23579. points: Vector3[];
  23580. dashSize?: number;
  23581. gapSize?: number;
  23582. dashNb?: number;
  23583. }): VertexData;
  23584. /**
  23585. * Creates the VertexData for a Ground
  23586. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23587. * - width the width (x direction) of the ground, optional, default 1
  23588. * - height the height (z direction) of the ground, optional, default 1
  23589. * - subdivisions the number of subdivisions per side, optional, default 1
  23590. * @returns the VertexData of the Ground
  23591. */
  23592. static CreateGround(options: {
  23593. width?: number;
  23594. height?: number;
  23595. subdivisions?: number;
  23596. subdivisionsX?: number;
  23597. subdivisionsY?: number;
  23598. }): VertexData;
  23599. /**
  23600. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23601. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23602. * * xmin the ground minimum X coordinate, optional, default -1
  23603. * * zmin the ground minimum Z coordinate, optional, default -1
  23604. * * xmax the ground maximum X coordinate, optional, default 1
  23605. * * zmax the ground maximum Z coordinate, optional, default 1
  23606. * * 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}
  23607. * * 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}
  23608. * @returns the VertexData of the TiledGround
  23609. */
  23610. static CreateTiledGround(options: {
  23611. xmin: number;
  23612. zmin: number;
  23613. xmax: number;
  23614. zmax: number;
  23615. subdivisions?: {
  23616. w: number;
  23617. h: number;
  23618. };
  23619. precision?: {
  23620. w: number;
  23621. h: number;
  23622. };
  23623. }): VertexData;
  23624. /**
  23625. * Creates the VertexData of the Ground designed from a heightmap
  23626. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23627. * * width the width (x direction) of the ground
  23628. * * height the height (z direction) of the ground
  23629. * * subdivisions the number of subdivisions per side
  23630. * * minHeight the minimum altitude on the ground, optional, default 0
  23631. * * maxHeight the maximum altitude on the ground, optional default 1
  23632. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23633. * * buffer the array holding the image color data
  23634. * * bufferWidth the width of image
  23635. * * bufferHeight the height of image
  23636. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23637. * @returns the VertexData of the Ground designed from a heightmap
  23638. */
  23639. static CreateGroundFromHeightMap(options: {
  23640. width: number;
  23641. height: number;
  23642. subdivisions: number;
  23643. minHeight: number;
  23644. maxHeight: number;
  23645. colorFilter: Color3;
  23646. buffer: Uint8Array;
  23647. bufferWidth: number;
  23648. bufferHeight: number;
  23649. alphaFilter: number;
  23650. }): VertexData;
  23651. /**
  23652. * Creates the VertexData for a Plane
  23653. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23654. * * size sets the width and height of the plane to the value of size, optional default 1
  23655. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23656. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23658. * * 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)
  23659. * * 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)
  23660. * @returns the VertexData of the box
  23661. */
  23662. static CreatePlane(options: {
  23663. size?: number;
  23664. width?: number;
  23665. height?: number;
  23666. sideOrientation?: number;
  23667. frontUVs?: Vector4;
  23668. backUVs?: Vector4;
  23669. }): VertexData;
  23670. /**
  23671. * Creates the VertexData of the Disc or regular Polygon
  23672. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23673. * * radius the radius of the disc, optional default 0.5
  23674. * * tessellation the number of polygon sides, optional, default 64
  23675. * * 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
  23676. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23677. * * 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)
  23678. * * 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)
  23679. * @returns the VertexData of the box
  23680. */
  23681. static CreateDisc(options: {
  23682. radius?: number;
  23683. tessellation?: number;
  23684. arc?: number;
  23685. sideOrientation?: number;
  23686. frontUVs?: Vector4;
  23687. backUVs?: Vector4;
  23688. }): VertexData;
  23689. /**
  23690. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23691. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23692. * @param polygon a mesh built from polygonTriangulation.build()
  23693. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23694. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23695. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23696. * @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)
  23697. * @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)
  23698. * @returns the VertexData of the Polygon
  23699. */
  23700. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23701. /**
  23702. * Creates the VertexData of the IcoSphere
  23703. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23704. * * radius the radius of the IcoSphere, optional default 1
  23705. * * radiusX allows stretching in the x direction, optional, default radius
  23706. * * radiusY allows stretching in the y direction, optional, default radius
  23707. * * radiusZ allows stretching in the z direction, optional, default radius
  23708. * * flat when true creates a flat shaded mesh, optional, default true
  23709. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23710. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23711. * * 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)
  23712. * * 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)
  23713. * @returns the VertexData of the IcoSphere
  23714. */
  23715. static CreateIcoSphere(options: {
  23716. radius?: number;
  23717. radiusX?: number;
  23718. radiusY?: number;
  23719. radiusZ?: number;
  23720. flat?: boolean;
  23721. subdivisions?: number;
  23722. sideOrientation?: number;
  23723. frontUVs?: Vector4;
  23724. backUVs?: Vector4;
  23725. }): VertexData;
  23726. /**
  23727. * Creates the VertexData for a Polyhedron
  23728. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23729. * * type provided types are:
  23730. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23731. * * 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)
  23732. * * size the size of the IcoSphere, optional default 1
  23733. * * sizeX allows stretching in the x direction, optional, default size
  23734. * * sizeY allows stretching in the y direction, optional, default size
  23735. * * sizeZ allows stretching in the z direction, optional, default size
  23736. * * 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
  23737. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23738. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23739. * * flat when true creates a flat shaded mesh, optional, default true
  23740. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23742. * * 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)
  23743. * * 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)
  23744. * @returns the VertexData of the Polyhedron
  23745. */
  23746. static CreatePolyhedron(options: {
  23747. type?: number;
  23748. size?: number;
  23749. sizeX?: number;
  23750. sizeY?: number;
  23751. sizeZ?: number;
  23752. custom?: any;
  23753. faceUV?: Vector4[];
  23754. faceColors?: Color4[];
  23755. flat?: boolean;
  23756. sideOrientation?: number;
  23757. frontUVs?: Vector4;
  23758. backUVs?: Vector4;
  23759. }): VertexData;
  23760. /**
  23761. * Creates the VertexData for a TorusKnot
  23762. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23763. * * radius the radius of the torus knot, optional, default 2
  23764. * * tube the thickness of the tube, optional, default 0.5
  23765. * * radialSegments the number of sides on each tube segments, optional, default 32
  23766. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23767. * * p the number of windings around the z axis, optional, default 2
  23768. * * q the number of windings around the x axis, optional, default 3
  23769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23770. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23771. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23772. * @returns the VertexData of the Torus Knot
  23773. */
  23774. static CreateTorusKnot(options: {
  23775. radius?: number;
  23776. tube?: number;
  23777. radialSegments?: number;
  23778. tubularSegments?: number;
  23779. p?: number;
  23780. q?: number;
  23781. sideOrientation?: number;
  23782. frontUVs?: Vector4;
  23783. backUVs?: Vector4;
  23784. }): VertexData;
  23785. /**
  23786. * Compute normals for given positions and indices
  23787. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23788. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23789. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23790. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23791. * * facetNormals : optional array of facet normals (vector3)
  23792. * * facetPositions : optional array of facet positions (vector3)
  23793. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23794. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23795. * * bInfo : optional bounding info, required for facetPartitioning computation
  23796. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23797. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23798. * * useRightHandedSystem: optional boolean to for right handed system computation
  23799. * * depthSort : optional boolean to enable the facet depth sort computation
  23800. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23801. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23802. */
  23803. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23804. facetNormals?: any;
  23805. facetPositions?: any;
  23806. facetPartitioning?: any;
  23807. ratio?: number;
  23808. bInfo?: any;
  23809. bbSize?: Vector3;
  23810. subDiv?: any;
  23811. useRightHandedSystem?: boolean;
  23812. depthSort?: boolean;
  23813. distanceTo?: Vector3;
  23814. depthSortedFacets?: any;
  23815. }): void;
  23816. /** @hidden */
  23817. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23818. /**
  23819. * Applies VertexData created from the imported parameters to the geometry
  23820. * @param parsedVertexData the parsed data from an imported file
  23821. * @param geometry the geometry to apply the VertexData to
  23822. */
  23823. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23824. }
  23825. }
  23826. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23827. import { Nullable } from "babylonjs/types";
  23828. import { Scene } from "babylonjs/scene";
  23829. import { Vector4 } from "babylonjs/Maths/math";
  23830. import { Mesh } from "babylonjs/Meshes/mesh";
  23831. /**
  23832. * Class containing static functions to help procedurally build meshes
  23833. */
  23834. export class DiscBuilder {
  23835. /**
  23836. * Creates a plane polygonal mesh. By default, this is a disc
  23837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23838. * * 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
  23839. * * 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
  23840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23843. * @param name defines the name of the mesh
  23844. * @param options defines the options used to create the mesh
  23845. * @param scene defines the hosting scene
  23846. * @returns the plane polygonal mesh
  23847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23848. */
  23849. static CreateDisc(name: string, options: {
  23850. radius?: number;
  23851. tessellation?: number;
  23852. arc?: number;
  23853. updatable?: boolean;
  23854. sideOrientation?: number;
  23855. frontUVs?: Vector4;
  23856. backUVs?: Vector4;
  23857. }, scene?: Nullable<Scene>): Mesh;
  23858. }
  23859. }
  23860. declare module "babylonjs/Particles/solidParticleSystem" {
  23861. import { Vector3 } from "babylonjs/Maths/math";
  23862. import { Mesh } from "babylonjs/Meshes/mesh";
  23863. import { Scene, IDisposable } from "babylonjs/scene";
  23864. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23865. /**
  23866. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23867. *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.
  23868. * The SPS is also a particle system. It provides some methods to manage the particles.
  23869. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23870. *
  23871. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23872. */
  23873. export class SolidParticleSystem implements IDisposable {
  23874. /**
  23875. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23876. * Example : var p = SPS.particles[i];
  23877. */
  23878. particles: SolidParticle[];
  23879. /**
  23880. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23881. */
  23882. nbParticles: number;
  23883. /**
  23884. * If the particles must ever face the camera (default false). Useful for planar particles.
  23885. */
  23886. billboard: boolean;
  23887. /**
  23888. * Recompute normals when adding a shape
  23889. */
  23890. recomputeNormals: boolean;
  23891. /**
  23892. * This a counter ofr your own usage. It's not set by any SPS functions.
  23893. */
  23894. counter: number;
  23895. /**
  23896. * The SPS name. This name is also given to the underlying mesh.
  23897. */
  23898. name: string;
  23899. /**
  23900. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23901. */
  23902. mesh: Mesh;
  23903. /**
  23904. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23905. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23906. */
  23907. vars: any;
  23908. /**
  23909. * This array is populated when the SPS is set as 'pickable'.
  23910. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23911. * Each element of this array is an object `{idx: int, faceId: int}`.
  23912. * `idx` is the picked particle index in the `SPS.particles` array
  23913. * `faceId` is the picked face index counted within this particle.
  23914. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23915. */
  23916. pickedParticles: {
  23917. idx: number;
  23918. faceId: number;
  23919. }[];
  23920. /**
  23921. * This array is populated when `enableDepthSort` is set to true.
  23922. * Each element of this array is an instance of the class DepthSortedParticle.
  23923. */
  23924. depthSortedParticles: DepthSortedParticle[];
  23925. /**
  23926. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23927. * @hidden
  23928. */
  23929. _bSphereOnly: boolean;
  23930. /**
  23931. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23932. * @hidden
  23933. */
  23934. _bSphereRadiusFactor: number;
  23935. private _scene;
  23936. private _positions;
  23937. private _indices;
  23938. private _normals;
  23939. private _colors;
  23940. private _uvs;
  23941. private _indices32;
  23942. private _positions32;
  23943. private _normals32;
  23944. private _fixedNormal32;
  23945. private _colors32;
  23946. private _uvs32;
  23947. private _index;
  23948. private _updatable;
  23949. private _pickable;
  23950. private _isVisibilityBoxLocked;
  23951. private _alwaysVisible;
  23952. private _depthSort;
  23953. private _shapeCounter;
  23954. private _copy;
  23955. private _color;
  23956. private _computeParticleColor;
  23957. private _computeParticleTexture;
  23958. private _computeParticleRotation;
  23959. private _computeParticleVertex;
  23960. private _computeBoundingBox;
  23961. private _depthSortParticles;
  23962. private _camera;
  23963. private _mustUnrotateFixedNormals;
  23964. private _particlesIntersect;
  23965. private _needs32Bits;
  23966. /**
  23967. * Creates a SPS (Solid Particle System) object.
  23968. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23969. * @param scene (Scene) is the scene in which the SPS is added.
  23970. * @param options defines the options of the sps e.g.
  23971. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23972. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23973. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23974. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23975. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23976. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23977. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23978. */
  23979. constructor(name: string, scene: Scene, options?: {
  23980. updatable?: boolean;
  23981. isPickable?: boolean;
  23982. enableDepthSort?: boolean;
  23983. particleIntersection?: boolean;
  23984. boundingSphereOnly?: boolean;
  23985. bSphereRadiusFactor?: number;
  23986. });
  23987. /**
  23988. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23989. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23990. * @returns the created mesh
  23991. */
  23992. buildMesh(): Mesh;
  23993. /**
  23994. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23995. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23996. * Thus the particles generated from `digest()` have their property `position` set yet.
  23997. * @param mesh ( Mesh ) is the mesh to be digested
  23998. * @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
  23999. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24000. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24001. * @returns the current SPS
  24002. */
  24003. digest(mesh: Mesh, options?: {
  24004. facetNb?: number;
  24005. number?: number;
  24006. delta?: number;
  24007. }): SolidParticleSystem;
  24008. private _unrotateFixedNormals;
  24009. private _resetCopy;
  24010. private _meshBuilder;
  24011. private _posToShape;
  24012. private _uvsToShapeUV;
  24013. private _addParticle;
  24014. /**
  24015. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24016. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24017. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24018. * @param nb (positive integer) the number of particles to be created from this model
  24019. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24020. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24021. * @returns the number of shapes in the system
  24022. */
  24023. addShape(mesh: Mesh, nb: number, options?: {
  24024. positionFunction?: any;
  24025. vertexFunction?: any;
  24026. }): number;
  24027. private _rebuildParticle;
  24028. /**
  24029. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24030. * @returns the SPS.
  24031. */
  24032. rebuildMesh(): SolidParticleSystem;
  24033. /**
  24034. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24035. * This method calls `updateParticle()` for each particle of the SPS.
  24036. * For an animated SPS, it is usually called within the render loop.
  24037. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24038. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24039. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24040. * @returns the SPS.
  24041. */
  24042. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24043. /**
  24044. * Disposes the SPS.
  24045. */
  24046. dispose(): void;
  24047. /**
  24048. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24049. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24050. * @returns the SPS.
  24051. */
  24052. refreshVisibleSize(): SolidParticleSystem;
  24053. /**
  24054. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24055. * @param size the size (float) of the visibility box
  24056. * note : this doesn't lock the SPS mesh bounding box.
  24057. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24058. */
  24059. setVisibilityBox(size: number): void;
  24060. /**
  24061. * Gets whether the SPS as always visible or not
  24062. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24063. */
  24064. /**
  24065. * Sets the SPS as always visible or not
  24066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24067. */
  24068. isAlwaysVisible: boolean;
  24069. /**
  24070. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24071. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24072. */
  24073. /**
  24074. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24076. */
  24077. isVisibilityBoxLocked: boolean;
  24078. /**
  24079. * Tells to `setParticles()` to compute the particle rotations or not.
  24080. * Default value : true. The SPS is faster when it's set to false.
  24081. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24082. */
  24083. /**
  24084. * Gets if `setParticles()` computes the particle rotations or not.
  24085. * Default value : true. The SPS is faster when it's set to false.
  24086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24087. */
  24088. computeParticleRotation: boolean;
  24089. /**
  24090. * Tells to `setParticles()` to compute the particle colors or not.
  24091. * Default value : true. The SPS is faster when it's set to false.
  24092. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24093. */
  24094. /**
  24095. * Gets if `setParticles()` computes the particle colors or not.
  24096. * Default value : true. The SPS is faster when it's set to false.
  24097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24098. */
  24099. computeParticleColor: boolean;
  24100. /**
  24101. * Gets if `setParticles()` computes the particle textures or not.
  24102. * Default value : true. The SPS is faster when it's set to false.
  24103. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24104. */
  24105. computeParticleTexture: boolean;
  24106. /**
  24107. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24108. * Default value : false. The SPS is faster when it's set to false.
  24109. * Note : the particle custom vertex positions aren't stored values.
  24110. */
  24111. /**
  24112. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24113. * Default value : false. The SPS is faster when it's set to false.
  24114. * Note : the particle custom vertex positions aren't stored values.
  24115. */
  24116. computeParticleVertex: boolean;
  24117. /**
  24118. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24119. */
  24120. /**
  24121. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24122. */
  24123. computeBoundingBox: boolean;
  24124. /**
  24125. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24126. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24127. * Default : `true`
  24128. */
  24129. /**
  24130. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24131. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24132. * Default : `true`
  24133. */
  24134. depthSortParticles: boolean;
  24135. /**
  24136. * This function does nothing. It may be overwritten to set all the particle first values.
  24137. * The SPS doesn't call this function, you may have to call it by your own.
  24138. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24139. */
  24140. initParticles(): void;
  24141. /**
  24142. * This function does nothing. It may be overwritten to recycle a particle.
  24143. * The SPS doesn't call this function, you may have to call it by your own.
  24144. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24145. * @param particle The particle to recycle
  24146. * @returns the recycled particle
  24147. */
  24148. recycleParticle(particle: SolidParticle): SolidParticle;
  24149. /**
  24150. * Updates a particle : this function should be overwritten by the user.
  24151. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24152. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24153. * @example : just set a particle position or velocity and recycle conditions
  24154. * @param particle The particle to update
  24155. * @returns the updated particle
  24156. */
  24157. updateParticle(particle: SolidParticle): SolidParticle;
  24158. /**
  24159. * Updates a vertex of a particle : it can be overwritten by the user.
  24160. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24161. * @param particle the current particle
  24162. * @param vertex the current index of the current particle
  24163. * @param pt the index of the current vertex in the particle shape
  24164. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24165. * @example : just set a vertex particle position
  24166. * @returns the updated vertex
  24167. */
  24168. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24169. /**
  24170. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24171. * This does nothing and may be overwritten by the user.
  24172. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24173. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24174. * @param update the boolean update value actually passed to setParticles()
  24175. */
  24176. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24177. /**
  24178. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24179. * This will be passed three parameters.
  24180. * This does nothing and may be overwritten by the user.
  24181. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24183. * @param update the boolean update value actually passed to setParticles()
  24184. */
  24185. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24186. }
  24187. }
  24188. declare module "babylonjs/Particles/solidParticle" {
  24189. import { Nullable } from "babylonjs/types";
  24190. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24191. import { Mesh } from "babylonjs/Meshes/mesh";
  24192. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24193. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24194. /**
  24195. * Represents one particle of a solid particle system.
  24196. */
  24197. export class SolidParticle {
  24198. /**
  24199. * particle global index
  24200. */
  24201. idx: number;
  24202. /**
  24203. * The color of the particle
  24204. */
  24205. color: Nullable<Color4>;
  24206. /**
  24207. * The world space position of the particle.
  24208. */
  24209. position: Vector3;
  24210. /**
  24211. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24212. */
  24213. rotation: Vector3;
  24214. /**
  24215. * The world space rotation quaternion of the particle.
  24216. */
  24217. rotationQuaternion: Nullable<Quaternion>;
  24218. /**
  24219. * The scaling of the particle.
  24220. */
  24221. scaling: Vector3;
  24222. /**
  24223. * The uvs of the particle.
  24224. */
  24225. uvs: Vector4;
  24226. /**
  24227. * The current speed of the particle.
  24228. */
  24229. velocity: Vector3;
  24230. /**
  24231. * The pivot point in the particle local space.
  24232. */
  24233. pivot: Vector3;
  24234. /**
  24235. * Must the particle be translated from its pivot point in its local space ?
  24236. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24237. * Default : false
  24238. */
  24239. translateFromPivot: boolean;
  24240. /**
  24241. * Is the particle active or not ?
  24242. */
  24243. alive: boolean;
  24244. /**
  24245. * Is the particle visible or not ?
  24246. */
  24247. isVisible: boolean;
  24248. /**
  24249. * Index of this particle in the global "positions" array (Internal use)
  24250. * @hidden
  24251. */
  24252. _pos: number;
  24253. /**
  24254. * @hidden Index of this particle in the global "indices" array (Internal use)
  24255. */
  24256. _ind: number;
  24257. /**
  24258. * @hidden ModelShape of this particle (Internal use)
  24259. */
  24260. _model: ModelShape;
  24261. /**
  24262. * ModelShape id of this particle
  24263. */
  24264. shapeId: number;
  24265. /**
  24266. * Index of the particle in its shape id (Internal use)
  24267. */
  24268. idxInShape: number;
  24269. /**
  24270. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24271. */
  24272. _modelBoundingInfo: BoundingInfo;
  24273. /**
  24274. * @hidden Particle BoundingInfo object (Internal use)
  24275. */
  24276. _boundingInfo: BoundingInfo;
  24277. /**
  24278. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24279. */
  24280. _sps: SolidParticleSystem;
  24281. /**
  24282. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24283. */
  24284. _stillInvisible: boolean;
  24285. /**
  24286. * @hidden Last computed particle rotation matrix
  24287. */
  24288. _rotationMatrix: number[];
  24289. /**
  24290. * Parent particle Id, if any.
  24291. * Default null.
  24292. */
  24293. parentId: Nullable<number>;
  24294. /**
  24295. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24296. * The possible values are :
  24297. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24298. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24299. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24300. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24301. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24302. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24303. * */
  24304. cullingStrategy: number;
  24305. /**
  24306. * @hidden Internal global position in the SPS.
  24307. */
  24308. _globalPosition: Vector3;
  24309. /**
  24310. * Creates a Solid Particle object.
  24311. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24312. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24313. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24314. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24315. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24316. * @param shapeId (integer) is the model shape identifier in the SPS.
  24317. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24318. * @param sps defines the sps it is associated to
  24319. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24320. */
  24321. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24322. /**
  24323. * Legacy support, changed scale to scaling
  24324. */
  24325. /**
  24326. * Legacy support, changed scale to scaling
  24327. */
  24328. scale: Vector3;
  24329. /**
  24330. * Legacy support, changed quaternion to rotationQuaternion
  24331. */
  24332. /**
  24333. * Legacy support, changed quaternion to rotationQuaternion
  24334. */
  24335. quaternion: Nullable<Quaternion>;
  24336. /**
  24337. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24338. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24339. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24340. * @returns true if it intersects
  24341. */
  24342. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24343. /**
  24344. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24345. * A particle is in the frustum if its bounding box intersects the frustum
  24346. * @param frustumPlanes defines the frustum to test
  24347. * @returns true if the particle is in the frustum planes
  24348. */
  24349. isInFrustum(frustumPlanes: Plane[]): boolean;
  24350. /**
  24351. * get the rotation matrix of the particle
  24352. * @hidden
  24353. */
  24354. getRotationMatrix(m: Matrix): void;
  24355. }
  24356. /**
  24357. * Represents the shape of the model used by one particle of a solid particle system.
  24358. * SPS internal tool, don't use it manually.
  24359. */
  24360. export class ModelShape {
  24361. /**
  24362. * The shape id
  24363. * @hidden
  24364. */
  24365. shapeID: number;
  24366. /**
  24367. * flat array of model positions (internal use)
  24368. * @hidden
  24369. */
  24370. _shape: Vector3[];
  24371. /**
  24372. * flat array of model UVs (internal use)
  24373. * @hidden
  24374. */
  24375. _shapeUV: number[];
  24376. /**
  24377. * length of the shape in the model indices array (internal use)
  24378. * @hidden
  24379. */
  24380. _indicesLength: number;
  24381. /**
  24382. * Custom position function (internal use)
  24383. * @hidden
  24384. */
  24385. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24386. /**
  24387. * Custom vertex function (internal use)
  24388. * @hidden
  24389. */
  24390. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24391. /**
  24392. * 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.
  24393. * SPS internal tool, don't use it manually.
  24394. * @hidden
  24395. */
  24396. 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>);
  24397. }
  24398. /**
  24399. * Represents a Depth Sorted Particle in the solid particle system.
  24400. */
  24401. export class DepthSortedParticle {
  24402. /**
  24403. * Index of the particle in the "indices" array
  24404. */
  24405. ind: number;
  24406. /**
  24407. * Length of the particle shape in the "indices" array
  24408. */
  24409. indicesLength: number;
  24410. /**
  24411. * Squared distance from the particle to the camera
  24412. */
  24413. sqDistance: number;
  24414. }
  24415. }
  24416. declare module "babylonjs/Meshes/abstractMesh" {
  24417. import { Observable } from "babylonjs/Misc/observable";
  24418. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24419. import { Camera } from "babylonjs/Cameras/camera";
  24420. import { Scene, IDisposable } from "babylonjs/scene";
  24421. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24422. import { Node } from "babylonjs/node";
  24423. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24424. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24426. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24427. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24428. import { Material } from "babylonjs/Materials/material";
  24429. import { Light } from "babylonjs/Lights/light";
  24430. import { Skeleton } from "babylonjs/Bones/skeleton";
  24431. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24432. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24433. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24434. import { Ray } from "babylonjs/Culling/ray";
  24435. import { Collider } from "babylonjs/Collisions/collider";
  24436. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24437. /**
  24438. * Class used to store all common mesh properties
  24439. */
  24440. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24441. /** No occlusion */
  24442. static OCCLUSION_TYPE_NONE: number;
  24443. /** Occlusion set to optimisitic */
  24444. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24445. /** Occlusion set to strict */
  24446. static OCCLUSION_TYPE_STRICT: number;
  24447. /** Use an accurante occlusion algorithm */
  24448. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24449. /** Use a conservative occlusion algorithm */
  24450. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24451. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24452. * Test order :
  24453. * Is the bounding sphere outside the frustum ?
  24454. * If not, are the bounding box vertices outside the frustum ?
  24455. * It not, then the cullable object is in the frustum.
  24456. */
  24457. static readonly CULLINGSTRATEGY_STANDARD: number;
  24458. /** Culling strategy : Bounding Sphere Only.
  24459. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24460. * It's also less accurate than the standard because some not visible objects can still be selected.
  24461. * Test : is the bounding sphere outside the frustum ?
  24462. * If not, then the cullable object is in the frustum.
  24463. */
  24464. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24465. /** Culling strategy : Optimistic Inclusion.
  24466. * This in an inclusion test first, then the standard exclusion test.
  24467. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24468. * 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.
  24469. * Anyway, it's as accurate as the standard strategy.
  24470. * Test :
  24471. * Is the cullable object bounding sphere center in the frustum ?
  24472. * If not, apply the default culling strategy.
  24473. */
  24474. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24475. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24476. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24477. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24478. * 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.
  24479. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24480. * Test :
  24481. * Is the cullable object bounding sphere center in the frustum ?
  24482. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24483. */
  24484. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24485. /**
  24486. * No billboard
  24487. */
  24488. static readonly BILLBOARDMODE_NONE: number;
  24489. /** Billboard on X axis */
  24490. static readonly BILLBOARDMODE_X: number;
  24491. /** Billboard on Y axis */
  24492. static readonly BILLBOARDMODE_Y: number;
  24493. /** Billboard on Z axis */
  24494. static readonly BILLBOARDMODE_Z: number;
  24495. /** Billboard on all axes */
  24496. static readonly BILLBOARDMODE_ALL: number;
  24497. private _facetData;
  24498. /**
  24499. * The culling strategy to use to check whether the mesh must be rendered or not.
  24500. * This value can be changed at any time and will be used on the next render mesh selection.
  24501. * The possible values are :
  24502. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24503. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24504. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24505. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24506. * Please read each static variable documentation to get details about the culling process.
  24507. * */
  24508. cullingStrategy: number;
  24509. /**
  24510. * Gets the number of facets in the mesh
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24512. */
  24513. readonly facetNb: number;
  24514. /**
  24515. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24517. */
  24518. partitioningSubdivisions: number;
  24519. /**
  24520. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24521. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24523. */
  24524. partitioningBBoxRatio: number;
  24525. /**
  24526. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24527. * Works only for updatable meshes.
  24528. * Doesn't work with multi-materials
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24530. */
  24531. mustDepthSortFacets: boolean;
  24532. /**
  24533. * The location (Vector3) where the facet depth sort must be computed from.
  24534. * By default, the active camera position.
  24535. * Used only when facet depth sort is enabled
  24536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24537. */
  24538. facetDepthSortFrom: Vector3;
  24539. /**
  24540. * gets a boolean indicating if facetData is enabled
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24542. */
  24543. readonly isFacetDataEnabled: boolean;
  24544. /** @hidden */
  24545. _updateNonUniformScalingState(value: boolean): boolean;
  24546. /**
  24547. * An event triggered when this mesh collides with another one
  24548. */
  24549. onCollideObservable: Observable<AbstractMesh>;
  24550. private _onCollideObserver;
  24551. /** Set a function to call when this mesh collides with another one */
  24552. onCollide: () => void;
  24553. /**
  24554. * An event triggered when the collision's position changes
  24555. */
  24556. onCollisionPositionChangeObservable: Observable<Vector3>;
  24557. private _onCollisionPositionChangeObserver;
  24558. /** Set a function to call when the collision's position changes */
  24559. onCollisionPositionChange: () => void;
  24560. /**
  24561. * An event triggered when material is changed
  24562. */
  24563. onMaterialChangedObservable: Observable<AbstractMesh>;
  24564. /**
  24565. * Gets or sets the orientation for POV movement & rotation
  24566. */
  24567. definedFacingForward: boolean;
  24568. /** @hidden */
  24569. _occlusionQuery: Nullable<WebGLQuery>;
  24570. private _visibility;
  24571. /**
  24572. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24573. */
  24574. /**
  24575. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24576. */
  24577. visibility: number;
  24578. /** Gets or sets the alpha index used to sort transparent meshes
  24579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24580. */
  24581. alphaIndex: number;
  24582. /**
  24583. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24584. */
  24585. isVisible: boolean;
  24586. /**
  24587. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24588. */
  24589. isPickable: boolean;
  24590. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24591. showSubMeshesBoundingBox: boolean;
  24592. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24594. */
  24595. isBlocker: boolean;
  24596. /**
  24597. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24598. */
  24599. enablePointerMoveEvents: boolean;
  24600. /**
  24601. * Specifies the rendering group id for this mesh (0 by default)
  24602. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24603. */
  24604. renderingGroupId: number;
  24605. private _material;
  24606. /** Gets or sets current material */
  24607. material: Nullable<Material>;
  24608. private _receiveShadows;
  24609. /**
  24610. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24611. * @see http://doc.babylonjs.com/babylon101/shadows
  24612. */
  24613. receiveShadows: boolean;
  24614. /** Defines color to use when rendering outline */
  24615. outlineColor: Color3;
  24616. /** Define width to use when rendering outline */
  24617. outlineWidth: number;
  24618. /** Defines color to use when rendering overlay */
  24619. overlayColor: Color3;
  24620. /** Defines alpha to use when rendering overlay */
  24621. overlayAlpha: number;
  24622. private _hasVertexAlpha;
  24623. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24624. hasVertexAlpha: boolean;
  24625. private _useVertexColors;
  24626. /** 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) */
  24627. useVertexColors: boolean;
  24628. private _computeBonesUsingShaders;
  24629. /**
  24630. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24631. */
  24632. computeBonesUsingShaders: boolean;
  24633. private _numBoneInfluencers;
  24634. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24635. numBoneInfluencers: number;
  24636. private _applyFog;
  24637. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24638. applyFog: boolean;
  24639. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24640. useOctreeForRenderingSelection: boolean;
  24641. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24642. useOctreeForPicking: boolean;
  24643. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24644. useOctreeForCollisions: boolean;
  24645. private _layerMask;
  24646. /**
  24647. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24648. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24649. */
  24650. layerMask: number;
  24651. /**
  24652. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24653. */
  24654. alwaysSelectAsActiveMesh: boolean;
  24655. /**
  24656. * Gets or sets the current action manager
  24657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24658. */
  24659. actionManager: Nullable<AbstractActionManager>;
  24660. private _checkCollisions;
  24661. private _collisionMask;
  24662. private _collisionGroup;
  24663. /**
  24664. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24666. */
  24667. ellipsoid: Vector3;
  24668. /**
  24669. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24671. */
  24672. ellipsoidOffset: Vector3;
  24673. private _collider;
  24674. private _oldPositionForCollisions;
  24675. private _diffPositionForCollisions;
  24676. /**
  24677. * Gets or sets a collision mask used to mask collisions (default is -1).
  24678. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24679. */
  24680. collisionMask: number;
  24681. /**
  24682. * Gets or sets the current collision group mask (-1 by default).
  24683. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24684. */
  24685. collisionGroup: number;
  24686. /**
  24687. * Defines edge width used when edgesRenderer is enabled
  24688. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24689. */
  24690. edgesWidth: number;
  24691. /**
  24692. * Defines edge color used when edgesRenderer is enabled
  24693. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24694. */
  24695. edgesColor: Color4;
  24696. /** @hidden */
  24697. _edgesRenderer: Nullable<IEdgesRenderer>;
  24698. /** @hidden */
  24699. _masterMesh: Nullable<AbstractMesh>;
  24700. /** @hidden */
  24701. _boundingInfo: Nullable<BoundingInfo>;
  24702. /** @hidden */
  24703. _renderId: number;
  24704. /**
  24705. * Gets or sets the list of subMeshes
  24706. * @see http://doc.babylonjs.com/how_to/multi_materials
  24707. */
  24708. subMeshes: SubMesh[];
  24709. /** @hidden */
  24710. _intersectionsInProgress: AbstractMesh[];
  24711. /** @hidden */
  24712. _unIndexed: boolean;
  24713. /** @hidden */
  24714. _lightSources: Light[];
  24715. /** @hidden */
  24716. readonly _positions: Nullable<Vector3[]>;
  24717. /** @hidden */
  24718. _waitingActions: any;
  24719. /** @hidden */
  24720. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24721. private _skeleton;
  24722. /** @hidden */
  24723. _bonesTransformMatrices: Nullable<Float32Array>;
  24724. /**
  24725. * Gets or sets a skeleton to apply skining transformations
  24726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24727. */
  24728. skeleton: Nullable<Skeleton>;
  24729. /**
  24730. * An event triggered when the mesh is rebuilt.
  24731. */
  24732. onRebuildObservable: Observable<AbstractMesh>;
  24733. /**
  24734. * Creates a new AbstractMesh
  24735. * @param name defines the name of the mesh
  24736. * @param scene defines the hosting scene
  24737. */
  24738. constructor(name: string, scene?: Nullable<Scene>);
  24739. /**
  24740. * Returns the string "AbstractMesh"
  24741. * @returns "AbstractMesh"
  24742. */
  24743. getClassName(): string;
  24744. /**
  24745. * Gets a string representation of the current mesh
  24746. * @param fullDetails defines a boolean indicating if full details must be included
  24747. * @returns a string representation of the current mesh
  24748. */
  24749. toString(fullDetails?: boolean): string;
  24750. /** @hidden */
  24751. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24752. /** @hidden */
  24753. _rebuild(): void;
  24754. /** @hidden */
  24755. _resyncLightSources(): void;
  24756. /** @hidden */
  24757. _resyncLighSource(light: Light): void;
  24758. /** @hidden */
  24759. _unBindEffect(): void;
  24760. /** @hidden */
  24761. _removeLightSource(light: Light): void;
  24762. private _markSubMeshesAsDirty;
  24763. /** @hidden */
  24764. _markSubMeshesAsLightDirty(): void;
  24765. /** @hidden */
  24766. _markSubMeshesAsAttributesDirty(): void;
  24767. /** @hidden */
  24768. _markSubMeshesAsMiscDirty(): void;
  24769. /**
  24770. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24771. */
  24772. scaling: Vector3;
  24773. /**
  24774. * Returns true if the mesh is blocked. Implemented by child classes
  24775. */
  24776. readonly isBlocked: boolean;
  24777. /**
  24778. * Returns the mesh itself by default. Implemented by child classes
  24779. * @param camera defines the camera to use to pick the right LOD level
  24780. * @returns the currentAbstractMesh
  24781. */
  24782. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24783. /**
  24784. * Returns 0 by default. Implemented by child classes
  24785. * @returns an integer
  24786. */
  24787. getTotalVertices(): number;
  24788. /**
  24789. * Returns a positive integer : the total number of indices in this mesh geometry.
  24790. * @returns the numner of indices or zero if the mesh has no geometry.
  24791. */
  24792. getTotalIndices(): number;
  24793. /**
  24794. * Returns null by default. Implemented by child classes
  24795. * @returns null
  24796. */
  24797. getIndices(): Nullable<IndicesArray>;
  24798. /**
  24799. * Returns the array of the requested vertex data kind. Implemented by child classes
  24800. * @param kind defines the vertex data kind to use
  24801. * @returns null
  24802. */
  24803. getVerticesData(kind: string): Nullable<FloatArray>;
  24804. /**
  24805. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24806. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24807. * Note that a new underlying VertexBuffer object is created each call.
  24808. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24809. * @param kind defines vertex data kind:
  24810. * * VertexBuffer.PositionKind
  24811. * * VertexBuffer.UVKind
  24812. * * VertexBuffer.UV2Kind
  24813. * * VertexBuffer.UV3Kind
  24814. * * VertexBuffer.UV4Kind
  24815. * * VertexBuffer.UV5Kind
  24816. * * VertexBuffer.UV6Kind
  24817. * * VertexBuffer.ColorKind
  24818. * * VertexBuffer.MatricesIndicesKind
  24819. * * VertexBuffer.MatricesIndicesExtraKind
  24820. * * VertexBuffer.MatricesWeightsKind
  24821. * * VertexBuffer.MatricesWeightsExtraKind
  24822. * @param data defines the data source
  24823. * @param updatable defines if the data must be flagged as updatable (or static)
  24824. * @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
  24825. * @returns the current mesh
  24826. */
  24827. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24828. /**
  24829. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24830. * If the mesh has no geometry, it is simply returned as it is.
  24831. * @param kind defines vertex data kind:
  24832. * * VertexBuffer.PositionKind
  24833. * * VertexBuffer.UVKind
  24834. * * VertexBuffer.UV2Kind
  24835. * * VertexBuffer.UV3Kind
  24836. * * VertexBuffer.UV4Kind
  24837. * * VertexBuffer.UV5Kind
  24838. * * VertexBuffer.UV6Kind
  24839. * * VertexBuffer.ColorKind
  24840. * * VertexBuffer.MatricesIndicesKind
  24841. * * VertexBuffer.MatricesIndicesExtraKind
  24842. * * VertexBuffer.MatricesWeightsKind
  24843. * * VertexBuffer.MatricesWeightsExtraKind
  24844. * @param data defines the data source
  24845. * @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
  24846. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24847. * @returns the current mesh
  24848. */
  24849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24850. /**
  24851. * Sets the mesh indices,
  24852. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24853. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24854. * @param totalVertices Defines the total number of vertices
  24855. * @returns the current mesh
  24856. */
  24857. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24858. /**
  24859. * Gets a boolean indicating if specific vertex data is present
  24860. * @param kind defines the vertex data kind to use
  24861. * @returns true is data kind is present
  24862. */
  24863. isVerticesDataPresent(kind: string): boolean;
  24864. /**
  24865. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24866. * @returns a BoundingInfo
  24867. */
  24868. getBoundingInfo(): BoundingInfo;
  24869. /**
  24870. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24871. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24872. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24873. * @returns the current mesh
  24874. */
  24875. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24876. /**
  24877. * Overwrite the current bounding info
  24878. * @param boundingInfo defines the new bounding info
  24879. * @returns the current mesh
  24880. */
  24881. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24882. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24883. readonly useBones: boolean;
  24884. /** @hidden */
  24885. _preActivate(): void;
  24886. /** @hidden */
  24887. _preActivateForIntermediateRendering(renderId: number): void;
  24888. /** @hidden */
  24889. _activate(renderId: number): void;
  24890. /**
  24891. * Gets the current world matrix
  24892. * @returns a Matrix
  24893. */
  24894. getWorldMatrix(): Matrix;
  24895. /** @hidden */
  24896. _getWorldMatrixDeterminant(): number;
  24897. /**
  24898. * Perform relative position change from the point of view of behind the front of the mesh.
  24899. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24900. * Supports definition of mesh facing forward or backward
  24901. * @param amountRight defines the distance on the right axis
  24902. * @param amountUp defines the distance on the up axis
  24903. * @param amountForward defines the distance on the forward axis
  24904. * @returns the current mesh
  24905. */
  24906. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24907. /**
  24908. * Calculate relative position change from the point of view of behind the front of the mesh.
  24909. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24910. * Supports definition of mesh facing forward or backward
  24911. * @param amountRight defines the distance on the right axis
  24912. * @param amountUp defines the distance on the up axis
  24913. * @param amountForward defines the distance on the forward axis
  24914. * @returns the new displacement vector
  24915. */
  24916. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24917. /**
  24918. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24919. * Supports definition of mesh facing forward or backward
  24920. * @param flipBack defines the flip
  24921. * @param twirlClockwise defines the twirl
  24922. * @param tiltRight defines the tilt
  24923. * @returns the current mesh
  24924. */
  24925. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24926. /**
  24927. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24928. * Supports definition of mesh facing forward or backward.
  24929. * @param flipBack defines the flip
  24930. * @param twirlClockwise defines the twirl
  24931. * @param tiltRight defines the tilt
  24932. * @returns the new rotation vector
  24933. */
  24934. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24935. /**
  24936. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24937. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24938. * @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
  24939. * @returns the new bounding vectors
  24940. */
  24941. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24942. min: Vector3;
  24943. max: Vector3;
  24944. };
  24945. /**
  24946. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24947. * This means the mesh underlying bounding box and sphere are recomputed.
  24948. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24949. * @returns the current mesh
  24950. */
  24951. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24952. /** @hidden */
  24953. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24954. /** @hidden */
  24955. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24956. /** @hidden */
  24957. _updateBoundingInfo(): AbstractMesh;
  24958. /** @hidden */
  24959. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24960. /** @hidden */
  24961. protected _afterComputeWorldMatrix(): void;
  24962. /** @hidden */
  24963. readonly _effectiveMesh: AbstractMesh;
  24964. /**
  24965. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24966. * A mesh is in the frustum if its bounding box intersects the frustum
  24967. * @param frustumPlanes defines the frustum to test
  24968. * @returns true if the mesh is in the frustum planes
  24969. */
  24970. isInFrustum(frustumPlanes: Plane[]): boolean;
  24971. /**
  24972. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24973. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24974. * @param frustumPlanes defines the frustum to test
  24975. * @returns true if the mesh is completely in the frustum planes
  24976. */
  24977. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24978. /**
  24979. * True if the mesh intersects another mesh or a SolidParticle object
  24980. * @param mesh defines a target mesh or SolidParticle to test
  24981. * @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)
  24982. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24983. * @returns true if there is an intersection
  24984. */
  24985. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24986. /**
  24987. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24988. * @param point defines the point to test
  24989. * @returns true if there is an intersection
  24990. */
  24991. intersectsPoint(point: Vector3): boolean;
  24992. /**
  24993. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24995. */
  24996. checkCollisions: boolean;
  24997. /**
  24998. * Gets Collider object used to compute collisions (not physics)
  24999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25000. */
  25001. readonly collider: Collider;
  25002. /**
  25003. * Move the mesh using collision engine
  25004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25005. * @param displacement defines the requested displacement vector
  25006. * @returns the current mesh
  25007. */
  25008. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25009. private _onCollisionPositionChange;
  25010. /** @hidden */
  25011. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25012. /** @hidden */
  25013. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25014. /** @hidden */
  25015. _checkCollision(collider: Collider): AbstractMesh;
  25016. /** @hidden */
  25017. _generatePointsArray(): boolean;
  25018. /**
  25019. * Checks if the passed Ray intersects with the mesh
  25020. * @param ray defines the ray to use
  25021. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25022. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25023. * @returns the picking info
  25024. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25025. */
  25026. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25027. /**
  25028. * Clones the current mesh
  25029. * @param name defines the mesh name
  25030. * @param newParent defines the new mesh parent
  25031. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25032. * @returns the new mesh
  25033. */
  25034. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25035. /**
  25036. * Disposes all the submeshes of the current meshnp
  25037. * @returns the current mesh
  25038. */
  25039. releaseSubMeshes(): AbstractMesh;
  25040. /**
  25041. * Releases resources associated with this abstract mesh.
  25042. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25043. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25044. */
  25045. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25046. /**
  25047. * Adds the passed mesh as a child to the current mesh
  25048. * @param mesh defines the child mesh
  25049. * @returns the current mesh
  25050. */
  25051. addChild(mesh: AbstractMesh): AbstractMesh;
  25052. /**
  25053. * Removes the passed mesh from the current mesh children list
  25054. * @param mesh defines the child mesh
  25055. * @returns the current mesh
  25056. */
  25057. removeChild(mesh: AbstractMesh): AbstractMesh;
  25058. /** @hidden */
  25059. private _initFacetData;
  25060. /**
  25061. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25062. * This method can be called within the render loop.
  25063. * 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
  25064. * @returns the current mesh
  25065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25066. */
  25067. updateFacetData(): AbstractMesh;
  25068. /**
  25069. * Returns the facetLocalNormals array.
  25070. * The normals are expressed in the mesh local spac
  25071. * @returns an array of Vector3
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25073. */
  25074. getFacetLocalNormals(): Vector3[];
  25075. /**
  25076. * Returns the facetLocalPositions array.
  25077. * The facet positions are expressed in the mesh local space
  25078. * @returns an array of Vector3
  25079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25080. */
  25081. getFacetLocalPositions(): Vector3[];
  25082. /**
  25083. * Returns the facetLocalPartioning array
  25084. * @returns an array of array of numbers
  25085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25086. */
  25087. getFacetLocalPartitioning(): number[][];
  25088. /**
  25089. * Returns the i-th facet position in the world system.
  25090. * This method allocates a new Vector3 per call
  25091. * @param i defines the facet index
  25092. * @returns a new Vector3
  25093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25094. */
  25095. getFacetPosition(i: number): Vector3;
  25096. /**
  25097. * Sets the reference Vector3 with the i-th facet position in the world system
  25098. * @param i defines the facet index
  25099. * @param ref defines the target vector
  25100. * @returns the current mesh
  25101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25102. */
  25103. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25104. /**
  25105. * Returns the i-th facet normal in the world system.
  25106. * This method allocates a new Vector3 per call
  25107. * @param i defines the facet index
  25108. * @returns a new Vector3
  25109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25110. */
  25111. getFacetNormal(i: number): Vector3;
  25112. /**
  25113. * Sets the reference Vector3 with the i-th facet normal in the world system
  25114. * @param i defines the facet index
  25115. * @param ref defines the target vector
  25116. * @returns the current mesh
  25117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25118. */
  25119. getFacetNormalToRef(i: number, ref: Vector3): this;
  25120. /**
  25121. * 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)
  25122. * @param x defines x coordinate
  25123. * @param y defines y coordinate
  25124. * @param z defines z coordinate
  25125. * @returns the array of facet indexes
  25126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25127. */
  25128. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25129. /**
  25130. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25131. * @param projected sets as the (x,y,z) world projection on the facet
  25132. * @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
  25133. * @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
  25134. * @param x defines x coordinate
  25135. * @param y defines y coordinate
  25136. * @param z defines z coordinate
  25137. * @returns the face index if found (or null instead)
  25138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25139. */
  25140. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25141. /**
  25142. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25143. * @param projected sets as the (x,y,z) local projection on the facet
  25144. * @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
  25145. * @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
  25146. * @param x defines x coordinate
  25147. * @param y defines y coordinate
  25148. * @param z defines z coordinate
  25149. * @returns the face index if found (or null instead)
  25150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25151. */
  25152. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25153. /**
  25154. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25155. * @returns the parameters
  25156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25157. */
  25158. getFacetDataParameters(): any;
  25159. /**
  25160. * Disables the feature FacetData and frees the related memory
  25161. * @returns the current mesh
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25163. */
  25164. disableFacetData(): AbstractMesh;
  25165. /**
  25166. * Updates the AbstractMesh indices array
  25167. * @param indices defines the data source
  25168. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25169. * @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)
  25170. * @returns the current mesh
  25171. */
  25172. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25173. /**
  25174. * Creates new normals data for the mesh
  25175. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25176. * @returns the current mesh
  25177. */
  25178. createNormals(updatable: boolean): AbstractMesh;
  25179. /**
  25180. * Align the mesh with a normal
  25181. * @param normal defines the normal to use
  25182. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25183. * @returns the current mesh
  25184. */
  25185. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25186. /** @hidden */
  25187. _checkOcclusionQuery(): boolean;
  25188. }
  25189. }
  25190. declare module "babylonjs/Actions/actionEvent" {
  25191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25192. import { Nullable } from "babylonjs/types";
  25193. import { Sprite } from "babylonjs/Sprites/sprite";
  25194. import { Scene } from "babylonjs/scene";
  25195. import { Vector2 } from "babylonjs/Maths/math";
  25196. /**
  25197. * Interface used to define ActionEvent
  25198. */
  25199. export interface IActionEvent {
  25200. /** The mesh or sprite that triggered the action */
  25201. source: any;
  25202. /** The X mouse cursor position at the time of the event */
  25203. pointerX: number;
  25204. /** The Y mouse cursor position at the time of the event */
  25205. pointerY: number;
  25206. /** The mesh that is currently pointed at (can be null) */
  25207. meshUnderPointer: Nullable<AbstractMesh>;
  25208. /** the original (browser) event that triggered the ActionEvent */
  25209. sourceEvent?: any;
  25210. /** additional data for the event */
  25211. additionalData?: any;
  25212. }
  25213. /**
  25214. * ActionEvent is the event being sent when an action is triggered.
  25215. */
  25216. export class ActionEvent implements IActionEvent {
  25217. /** The mesh or sprite that triggered the action */
  25218. source: any;
  25219. /** The X mouse cursor position at the time of the event */
  25220. pointerX: number;
  25221. /** The Y mouse cursor position at the time of the event */
  25222. pointerY: number;
  25223. /** The mesh that is currently pointed at (can be null) */
  25224. meshUnderPointer: Nullable<AbstractMesh>;
  25225. /** the original (browser) event that triggered the ActionEvent */
  25226. sourceEvent?: any;
  25227. /** additional data for the event */
  25228. additionalData?: any;
  25229. /**
  25230. * Creates a new ActionEvent
  25231. * @param source The mesh or sprite that triggered the action
  25232. * @param pointerX The X mouse cursor position at the time of the event
  25233. * @param pointerY The Y mouse cursor position at the time of the event
  25234. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25235. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25236. * @param additionalData additional data for the event
  25237. */
  25238. constructor(
  25239. /** The mesh or sprite that triggered the action */
  25240. source: any,
  25241. /** The X mouse cursor position at the time of the event */
  25242. pointerX: number,
  25243. /** The Y mouse cursor position at the time of the event */
  25244. pointerY: number,
  25245. /** The mesh that is currently pointed at (can be null) */
  25246. meshUnderPointer: Nullable<AbstractMesh>,
  25247. /** the original (browser) event that triggered the ActionEvent */
  25248. sourceEvent?: any,
  25249. /** additional data for the event */
  25250. additionalData?: any);
  25251. /**
  25252. * Helper function to auto-create an ActionEvent from a source mesh.
  25253. * @param source The source mesh that triggered the event
  25254. * @param evt The original (browser) event
  25255. * @param additionalData additional data for the event
  25256. * @returns the new ActionEvent
  25257. */
  25258. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25259. /**
  25260. * Helper function to auto-create an ActionEvent from a source sprite
  25261. * @param source The source sprite that triggered the event
  25262. * @param scene Scene associated with the sprite
  25263. * @param evt The original (browser) event
  25264. * @param additionalData additional data for the event
  25265. * @returns the new ActionEvent
  25266. */
  25267. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25268. /**
  25269. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25270. * @param scene the scene where the event occurred
  25271. * @param evt The original (browser) event
  25272. * @returns the new ActionEvent
  25273. */
  25274. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25275. /**
  25276. * Helper function to auto-create an ActionEvent from a primitive
  25277. * @param prim defines the target primitive
  25278. * @param pointerPos defines the pointer position
  25279. * @param evt The original (browser) event
  25280. * @param additionalData additional data for the event
  25281. * @returns the new ActionEvent
  25282. */
  25283. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25284. }
  25285. }
  25286. declare module "babylonjs/Actions/abstractActionManager" {
  25287. import { IDisposable } from "babylonjs/scene";
  25288. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25289. import { IAction } from "babylonjs/Actions/action";
  25290. import { Nullable } from "babylonjs/types";
  25291. /**
  25292. * Abstract class used to decouple action Manager from scene and meshes.
  25293. * Do not instantiate.
  25294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25295. */
  25296. export abstract class AbstractActionManager implements IDisposable {
  25297. /** Gets the list of active triggers */
  25298. static Triggers: {
  25299. [key: string]: number;
  25300. };
  25301. /** Gets the cursor to use when hovering items */
  25302. hoverCursor: string;
  25303. /** Gets the list of actions */
  25304. actions: IAction[];
  25305. /**
  25306. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25307. */
  25308. isRecursive: boolean;
  25309. /**
  25310. * Releases all associated resources
  25311. */
  25312. abstract dispose(): void;
  25313. /**
  25314. * Does this action manager has pointer triggers
  25315. */
  25316. abstract readonly hasPointerTriggers: boolean;
  25317. /**
  25318. * Does this action manager has pick triggers
  25319. */
  25320. abstract readonly hasPickTriggers: boolean;
  25321. /**
  25322. * Process a specific trigger
  25323. * @param trigger defines the trigger to process
  25324. * @param evt defines the event details to be processed
  25325. */
  25326. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25327. /**
  25328. * Does this action manager handles actions of any of the given triggers
  25329. * @param triggers defines the triggers to be tested
  25330. * @return a boolean indicating whether one (or more) of the triggers is handled
  25331. */
  25332. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25333. /**
  25334. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25335. * speed.
  25336. * @param triggerA defines the trigger to be tested
  25337. * @param triggerB defines the trigger to be tested
  25338. * @return a boolean indicating whether one (or more) of the triggers is handled
  25339. */
  25340. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25341. /**
  25342. * Does this action manager handles actions of a given trigger
  25343. * @param trigger defines the trigger to be tested
  25344. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25345. * @return whether the trigger is handled
  25346. */
  25347. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25348. /**
  25349. * Serialize this manager to a JSON object
  25350. * @param name defines the property name to store this manager
  25351. * @returns a JSON representation of this manager
  25352. */
  25353. abstract serialize(name: string): any;
  25354. /**
  25355. * Registers an action to this action manager
  25356. * @param action defines the action to be registered
  25357. * @return the action amended (prepared) after registration
  25358. */
  25359. abstract registerAction(action: IAction): Nullable<IAction>;
  25360. /**
  25361. * Unregisters an action to this action manager
  25362. * @param action defines the action to be unregistered
  25363. * @return a boolean indicating whether the action has been unregistered
  25364. */
  25365. abstract unregisterAction(action: IAction): Boolean;
  25366. /**
  25367. * Does exist one action manager with at least one trigger
  25368. **/
  25369. static readonly HasTriggers: boolean;
  25370. /**
  25371. * Does exist one action manager with at least one pick trigger
  25372. **/
  25373. static readonly HasPickTriggers: boolean;
  25374. /**
  25375. * Does exist one action manager that handles actions of a given trigger
  25376. * @param trigger defines the trigger to be tested
  25377. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25378. **/
  25379. static HasSpecificTrigger(trigger: number): boolean;
  25380. }
  25381. }
  25382. declare module "babylonjs/node" {
  25383. import { Scene } from "babylonjs/scene";
  25384. import { Nullable } from "babylonjs/types";
  25385. import { Matrix } from "babylonjs/Maths/math";
  25386. import { Engine } from "babylonjs/Engines/engine";
  25387. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25388. import { Observable } from "babylonjs/Misc/observable";
  25389. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25391. import { Animatable } from "babylonjs/Animations/animatable";
  25392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25393. import { Animation } from "babylonjs/Animations/animation";
  25394. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25396. /**
  25397. * Defines how a node can be built from a string name.
  25398. */
  25399. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25400. /**
  25401. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25402. */
  25403. export class Node implements IBehaviorAware<Node> {
  25404. /** @hidden */
  25405. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25406. private static _NodeConstructors;
  25407. /**
  25408. * Add a new node constructor
  25409. * @param type defines the type name of the node to construct
  25410. * @param constructorFunc defines the constructor function
  25411. */
  25412. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25413. /**
  25414. * Returns a node constructor based on type name
  25415. * @param type defines the type name
  25416. * @param name defines the new node name
  25417. * @param scene defines the hosting scene
  25418. * @param options defines optional options to transmit to constructors
  25419. * @returns the new constructor or null
  25420. */
  25421. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25422. /**
  25423. * Gets or sets the name of the node
  25424. */
  25425. name: string;
  25426. /**
  25427. * Gets or sets the id of the node
  25428. */
  25429. id: string;
  25430. /**
  25431. * Gets or sets the unique id of the node
  25432. */
  25433. uniqueId: number;
  25434. /**
  25435. * Gets or sets a string used to store user defined state for the node
  25436. */
  25437. state: string;
  25438. /**
  25439. * Gets or sets an object used to store user defined information for the node
  25440. */
  25441. metadata: any;
  25442. /**
  25443. * For internal use only. Please do not use.
  25444. */
  25445. reservedDataStore: any;
  25446. /**
  25447. * List of inspectable custom properties (used by the Inspector)
  25448. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25449. */
  25450. inspectableCustomProperties: IInspectable[];
  25451. /**
  25452. * Gets or sets a boolean used to define if the node must be serialized
  25453. */
  25454. doNotSerialize: boolean;
  25455. /** @hidden */
  25456. _isDisposed: boolean;
  25457. /**
  25458. * Gets a list of Animations associated with the node
  25459. */
  25460. animations: import("babylonjs/Animations/animation").Animation[];
  25461. protected _ranges: {
  25462. [name: string]: Nullable<AnimationRange>;
  25463. };
  25464. /**
  25465. * Callback raised when the node is ready to be used
  25466. */
  25467. onReady: (node: Node) => void;
  25468. private _isEnabled;
  25469. private _isParentEnabled;
  25470. private _isReady;
  25471. /** @hidden */
  25472. _currentRenderId: number;
  25473. private _parentUpdateId;
  25474. protected _childUpdateId: number;
  25475. /** @hidden */
  25476. _waitingParentId: Nullable<string>;
  25477. /** @hidden */
  25478. _scene: Scene;
  25479. /** @hidden */
  25480. _cache: any;
  25481. private _parentNode;
  25482. private _children;
  25483. /** @hidden */
  25484. _worldMatrix: Matrix;
  25485. /** @hidden */
  25486. _worldMatrixDeterminant: number;
  25487. /** @hidden */
  25488. private _sceneRootNodesIndex;
  25489. /**
  25490. * Gets a boolean indicating if the node has been disposed
  25491. * @returns true if the node was disposed
  25492. */
  25493. isDisposed(): boolean;
  25494. /**
  25495. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25496. * @see https://doc.babylonjs.com/how_to/parenting
  25497. */
  25498. parent: Nullable<Node>;
  25499. private addToSceneRootNodes;
  25500. private removeFromSceneRootNodes;
  25501. private _animationPropertiesOverride;
  25502. /**
  25503. * Gets or sets the animation properties override
  25504. */
  25505. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25506. /**
  25507. * Gets a string idenfifying the name of the class
  25508. * @returns "Node" string
  25509. */
  25510. getClassName(): string;
  25511. /** @hidden */
  25512. readonly _isNode: boolean;
  25513. /**
  25514. * An event triggered when the mesh is disposed
  25515. */
  25516. onDisposeObservable: Observable<Node>;
  25517. private _onDisposeObserver;
  25518. /**
  25519. * Sets a callback that will be raised when the node will be disposed
  25520. */
  25521. onDispose: () => void;
  25522. /**
  25523. * Creates a new Node
  25524. * @param name the name and id to be given to this node
  25525. * @param scene the scene this node will be added to
  25526. * @param addToRootNodes the node will be added to scene.rootNodes
  25527. */
  25528. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25529. /**
  25530. * Gets the scene of the node
  25531. * @returns a scene
  25532. */
  25533. getScene(): Scene;
  25534. /**
  25535. * Gets the engine of the node
  25536. * @returns a Engine
  25537. */
  25538. getEngine(): Engine;
  25539. private _behaviors;
  25540. /**
  25541. * Attach a behavior to the node
  25542. * @see http://doc.babylonjs.com/features/behaviour
  25543. * @param behavior defines the behavior to attach
  25544. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25545. * @returns the current Node
  25546. */
  25547. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25548. /**
  25549. * Remove an attached behavior
  25550. * @see http://doc.babylonjs.com/features/behaviour
  25551. * @param behavior defines the behavior to attach
  25552. * @returns the current Node
  25553. */
  25554. removeBehavior(behavior: Behavior<Node>): Node;
  25555. /**
  25556. * Gets the list of attached behaviors
  25557. * @see http://doc.babylonjs.com/features/behaviour
  25558. */
  25559. readonly behaviors: Behavior<Node>[];
  25560. /**
  25561. * Gets an attached behavior by name
  25562. * @param name defines the name of the behavior to look for
  25563. * @see http://doc.babylonjs.com/features/behaviour
  25564. * @returns null if behavior was not found else the requested behavior
  25565. */
  25566. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25567. /**
  25568. * Returns the latest update of the World matrix
  25569. * @returns a Matrix
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getWorldMatrixDeterminant(): number;
  25574. /**
  25575. * Returns directly the latest state of the mesh World matrix.
  25576. * A Matrix is returned.
  25577. */
  25578. readonly worldMatrixFromCache: Matrix;
  25579. /** @hidden */
  25580. _initCache(): void;
  25581. /** @hidden */
  25582. updateCache(force?: boolean): void;
  25583. /** @hidden */
  25584. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25585. /** @hidden */
  25586. _updateCache(ignoreParentClass?: boolean): void;
  25587. /** @hidden */
  25588. _isSynchronized(): boolean;
  25589. /** @hidden */
  25590. _markSyncedWithParent(): void;
  25591. /** @hidden */
  25592. isSynchronizedWithParent(): boolean;
  25593. /** @hidden */
  25594. isSynchronized(): boolean;
  25595. /**
  25596. * Is this node ready to be used/rendered
  25597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25598. * @return true if the node is ready
  25599. */
  25600. isReady(completeCheck?: boolean): boolean;
  25601. /**
  25602. * Is this node enabled?
  25603. * 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
  25604. * @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
  25605. * @return whether this node (and its parent) is enabled
  25606. */
  25607. isEnabled(checkAncestors?: boolean): boolean;
  25608. /** @hidden */
  25609. protected _syncParentEnabledState(): void;
  25610. /**
  25611. * Set the enabled state of this node
  25612. * @param value defines the new enabled state
  25613. */
  25614. setEnabled(value: boolean): void;
  25615. /**
  25616. * Is this node a descendant of the given node?
  25617. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25618. * @param ancestor defines the parent node to inspect
  25619. * @returns a boolean indicating if this node is a descendant of the given node
  25620. */
  25621. isDescendantOf(ancestor: Node): boolean;
  25622. /** @hidden */
  25623. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25624. /**
  25625. * Will return all nodes that have this node as ascendant
  25626. * @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
  25627. * @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
  25628. * @return all children nodes of all types
  25629. */
  25630. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25631. /**
  25632. * Get all child-meshes of this node
  25633. * @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)
  25634. * @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
  25635. * @returns an array of AbstractMesh
  25636. */
  25637. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25638. /**
  25639. * Get all direct children of this node
  25640. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  25641. * @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)
  25642. * @returns an array of Node
  25643. */
  25644. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25645. /** @hidden */
  25646. _setReady(state: boolean): void;
  25647. /**
  25648. * Get an animation by name
  25649. * @param name defines the name of the animation to look for
  25650. * @returns null if not found else the requested animation
  25651. */
  25652. getAnimationByName(name: string): Nullable<Animation>;
  25653. /**
  25654. * Creates an animation range for this node
  25655. * @param name defines the name of the range
  25656. * @param from defines the starting key
  25657. * @param to defines the end key
  25658. */
  25659. createAnimationRange(name: string, from: number, to: number): void;
  25660. /**
  25661. * Delete a specific animation range
  25662. * @param name defines the name of the range to delete
  25663. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25664. */
  25665. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25666. /**
  25667. * Get an animation range by name
  25668. * @param name defines the name of the animation range to look for
  25669. * @returns null if not found else the requested animation range
  25670. */
  25671. getAnimationRange(name: string): Nullable<AnimationRange>;
  25672. /**
  25673. * Gets the list of all animation ranges defined on this node
  25674. * @returns an array
  25675. */
  25676. getAnimationRanges(): Nullable<AnimationRange>[];
  25677. /**
  25678. * Will start the animation sequence
  25679. * @param name defines the range frames for animation sequence
  25680. * @param loop defines if the animation should loop (false by default)
  25681. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25682. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25683. * @returns the object created for this animation. If range does not exist, it will return null
  25684. */
  25685. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25686. /**
  25687. * Serialize animation ranges into a JSON compatible object
  25688. * @returns serialization object
  25689. */
  25690. serializeAnimationRanges(): any;
  25691. /**
  25692. * Computes the world matrix of the node
  25693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25694. * @returns the world matrix
  25695. */
  25696. computeWorldMatrix(force?: boolean): Matrix;
  25697. /**
  25698. * Releases resources associated with this node.
  25699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25701. */
  25702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25703. /**
  25704. * Parse animation range data from a serialization object and store them into a given node
  25705. * @param node defines where to store the animation ranges
  25706. * @param parsedNode defines the serialization object to read data from
  25707. * @param scene defines the hosting scene
  25708. */
  25709. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25710. }
  25711. }
  25712. declare module "babylonjs/Animations/animation" {
  25713. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25714. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25715. import { Nullable } from "babylonjs/types";
  25716. import { Scene } from "babylonjs/scene";
  25717. import { IAnimatable } from "babylonjs/Misc/tools";
  25718. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25719. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25720. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25721. import { Node } from "babylonjs/node";
  25722. import { Animatable } from "babylonjs/Animations/animatable";
  25723. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25724. /**
  25725. * Class used to store any kind of animation
  25726. */
  25727. export class Animation {
  25728. /**Name of the animation */
  25729. name: string;
  25730. /**Property to animate */
  25731. targetProperty: string;
  25732. /**The frames per second of the animation */
  25733. framePerSecond: number;
  25734. /**The data type of the animation */
  25735. dataType: number;
  25736. /**The loop mode of the animation */
  25737. loopMode?: number | undefined;
  25738. /**Specifies if blending should be enabled */
  25739. enableBlending?: boolean | undefined;
  25740. /**
  25741. * Use matrix interpolation instead of using direct key value when animating matrices
  25742. */
  25743. static AllowMatricesInterpolation: boolean;
  25744. /**
  25745. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25746. */
  25747. static AllowMatrixDecomposeForInterpolation: boolean;
  25748. /**
  25749. * Stores the key frames of the animation
  25750. */
  25751. private _keys;
  25752. /**
  25753. * Stores the easing function of the animation
  25754. */
  25755. private _easingFunction;
  25756. /**
  25757. * @hidden Internal use only
  25758. */
  25759. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25760. /**
  25761. * The set of event that will be linked to this animation
  25762. */
  25763. private _events;
  25764. /**
  25765. * Stores an array of target property paths
  25766. */
  25767. targetPropertyPath: string[];
  25768. /**
  25769. * Stores the blending speed of the animation
  25770. */
  25771. blendingSpeed: number;
  25772. /**
  25773. * Stores the animation ranges for the animation
  25774. */
  25775. private _ranges;
  25776. /**
  25777. * @hidden Internal use
  25778. */
  25779. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25780. /**
  25781. * Sets up an animation
  25782. * @param property The property to animate
  25783. * @param animationType The animation type to apply
  25784. * @param framePerSecond The frames per second of the animation
  25785. * @param easingFunction The easing function used in the animation
  25786. * @returns The created animation
  25787. */
  25788. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25789. /**
  25790. * Create and start an animation on a node
  25791. * @param name defines the name of the global animation that will be run on all nodes
  25792. * @param node defines the root node where the animation will take place
  25793. * @param targetProperty defines property to animate
  25794. * @param framePerSecond defines the number of frame per second yo use
  25795. * @param totalFrame defines the number of frames in total
  25796. * @param from defines the initial value
  25797. * @param to defines the final value
  25798. * @param loopMode defines which loop mode you want to use (off by default)
  25799. * @param easingFunction defines the easing function to use (linear by default)
  25800. * @param onAnimationEnd defines the callback to call when animation end
  25801. * @returns the animatable created for this animation
  25802. */
  25803. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25804. /**
  25805. * Create and start an animation on a node and its descendants
  25806. * @param name defines the name of the global animation that will be run on all nodes
  25807. * @param node defines the root node where the animation will take place
  25808. * @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
  25809. * @param targetProperty defines property to animate
  25810. * @param framePerSecond defines the number of frame per second to use
  25811. * @param totalFrame defines the number of frames in total
  25812. * @param from defines the initial value
  25813. * @param to defines the final value
  25814. * @param loopMode defines which loop mode you want to use (off by default)
  25815. * @param easingFunction defines the easing function to use (linear by default)
  25816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25817. * @returns the list of animatables created for all nodes
  25818. * @example https://www.babylonjs-playground.com/#MH0VLI
  25819. */
  25820. 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[]>;
  25821. /**
  25822. * Creates a new animation, merges it with the existing animations and starts it
  25823. * @param name Name of the animation
  25824. * @param node Node which contains the scene that begins the animations
  25825. * @param targetProperty Specifies which property to animate
  25826. * @param framePerSecond The frames per second of the animation
  25827. * @param totalFrame The total number of frames
  25828. * @param from The frame at the beginning of the animation
  25829. * @param to The frame at the end of the animation
  25830. * @param loopMode Specifies the loop mode of the animation
  25831. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25832. * @param onAnimationEnd Callback to run once the animation is complete
  25833. * @returns Nullable animation
  25834. */
  25835. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25836. /**
  25837. * Transition property of an host to the target Value
  25838. * @param property The property to transition
  25839. * @param targetValue The target Value of the property
  25840. * @param host The object where the property to animate belongs
  25841. * @param scene Scene used to run the animation
  25842. * @param frameRate Framerate (in frame/s) to use
  25843. * @param transition The transition type we want to use
  25844. * @param duration The duration of the animation, in milliseconds
  25845. * @param onAnimationEnd Callback trigger at the end of the animation
  25846. * @returns Nullable animation
  25847. */
  25848. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25849. /**
  25850. * Return the array of runtime animations currently using this animation
  25851. */
  25852. readonly runtimeAnimations: RuntimeAnimation[];
  25853. /**
  25854. * Specifies if any of the runtime animations are currently running
  25855. */
  25856. readonly hasRunningRuntimeAnimations: boolean;
  25857. /**
  25858. * Initializes the animation
  25859. * @param name Name of the animation
  25860. * @param targetProperty Property to animate
  25861. * @param framePerSecond The frames per second of the animation
  25862. * @param dataType The data type of the animation
  25863. * @param loopMode The loop mode of the animation
  25864. * @param enableBlending Specifies if blending should be enabled
  25865. */
  25866. constructor(
  25867. /**Name of the animation */
  25868. name: string,
  25869. /**Property to animate */
  25870. targetProperty: string,
  25871. /**The frames per second of the animation */
  25872. framePerSecond: number,
  25873. /**The data type of the animation */
  25874. dataType: number,
  25875. /**The loop mode of the animation */
  25876. loopMode?: number | undefined,
  25877. /**Specifies if blending should be enabled */
  25878. enableBlending?: boolean | undefined);
  25879. /**
  25880. * Converts the animation to a string
  25881. * @param fullDetails support for multiple levels of logging within scene loading
  25882. * @returns String form of the animation
  25883. */
  25884. toString(fullDetails?: boolean): string;
  25885. /**
  25886. * Add an event to this animation
  25887. * @param event Event to add
  25888. */
  25889. addEvent(event: AnimationEvent): void;
  25890. /**
  25891. * Remove all events found at the given frame
  25892. * @param frame The frame to remove events from
  25893. */
  25894. removeEvents(frame: number): void;
  25895. /**
  25896. * Retrieves all the events from the animation
  25897. * @returns Events from the animation
  25898. */
  25899. getEvents(): AnimationEvent[];
  25900. /**
  25901. * Creates an animation range
  25902. * @param name Name of the animation range
  25903. * @param from Starting frame of the animation range
  25904. * @param to Ending frame of the animation
  25905. */
  25906. createRange(name: string, from: number, to: number): void;
  25907. /**
  25908. * Deletes an animation range by name
  25909. * @param name Name of the animation range to delete
  25910. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25911. */
  25912. deleteRange(name: string, deleteFrames?: boolean): void;
  25913. /**
  25914. * Gets the animation range by name, or null if not defined
  25915. * @param name Name of the animation range
  25916. * @returns Nullable animation range
  25917. */
  25918. getRange(name: string): Nullable<AnimationRange>;
  25919. /**
  25920. * Gets the key frames from the animation
  25921. * @returns The key frames of the animation
  25922. */
  25923. getKeys(): Array<IAnimationKey>;
  25924. /**
  25925. * Gets the highest frame rate of the animation
  25926. * @returns Highest frame rate of the animation
  25927. */
  25928. getHighestFrame(): number;
  25929. /**
  25930. * Gets the easing function of the animation
  25931. * @returns Easing function of the animation
  25932. */
  25933. getEasingFunction(): IEasingFunction;
  25934. /**
  25935. * Sets the easing function of the animation
  25936. * @param easingFunction A custom mathematical formula for animation
  25937. */
  25938. setEasingFunction(easingFunction: EasingFunction): void;
  25939. /**
  25940. * Interpolates a scalar linearly
  25941. * @param startValue Start value of the animation curve
  25942. * @param endValue End value of the animation curve
  25943. * @param gradient Scalar amount to interpolate
  25944. * @returns Interpolated scalar value
  25945. */
  25946. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25947. /**
  25948. * Interpolates a scalar cubically
  25949. * @param startValue Start value of the animation curve
  25950. * @param outTangent End tangent of the animation
  25951. * @param endValue End value of the animation curve
  25952. * @param inTangent Start tangent of the animation curve
  25953. * @param gradient Scalar amount to interpolate
  25954. * @returns Interpolated scalar value
  25955. */
  25956. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25957. /**
  25958. * Interpolates a quaternion using a spherical linear interpolation
  25959. * @param startValue Start value of the animation curve
  25960. * @param endValue End value of the animation curve
  25961. * @param gradient Scalar amount to interpolate
  25962. * @returns Interpolated quaternion value
  25963. */
  25964. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25965. /**
  25966. * Interpolates a quaternion cubically
  25967. * @param startValue Start value of the animation curve
  25968. * @param outTangent End tangent of the animation curve
  25969. * @param endValue End value of the animation curve
  25970. * @param inTangent Start tangent of the animation curve
  25971. * @param gradient Scalar amount to interpolate
  25972. * @returns Interpolated quaternion value
  25973. */
  25974. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25975. /**
  25976. * Interpolates a Vector3 linearl
  25977. * @param startValue Start value of the animation curve
  25978. * @param endValue End value of the animation curve
  25979. * @param gradient Scalar amount to interpolate
  25980. * @returns Interpolated scalar value
  25981. */
  25982. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25983. /**
  25984. * Interpolates a Vector3 cubically
  25985. * @param startValue Start value of the animation curve
  25986. * @param outTangent End tangent of the animation
  25987. * @param endValue End value of the animation curve
  25988. * @param inTangent Start tangent of the animation curve
  25989. * @param gradient Scalar amount to interpolate
  25990. * @returns InterpolatedVector3 value
  25991. */
  25992. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25993. /**
  25994. * Interpolates a Vector2 linearly
  25995. * @param startValue Start value of the animation curve
  25996. * @param endValue End value of the animation curve
  25997. * @param gradient Scalar amount to interpolate
  25998. * @returns Interpolated Vector2 value
  25999. */
  26000. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26001. /**
  26002. * Interpolates a Vector2 cubically
  26003. * @param startValue Start value of the animation curve
  26004. * @param outTangent End tangent of the animation
  26005. * @param endValue End value of the animation curve
  26006. * @param inTangent Start tangent of the animation curve
  26007. * @param gradient Scalar amount to interpolate
  26008. * @returns Interpolated Vector2 value
  26009. */
  26010. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26011. /**
  26012. * Interpolates a size linearly
  26013. * @param startValue Start value of the animation curve
  26014. * @param endValue End value of the animation curve
  26015. * @param gradient Scalar amount to interpolate
  26016. * @returns Interpolated Size value
  26017. */
  26018. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26019. /**
  26020. * Interpolates a Color3 linearly
  26021. * @param startValue Start value of the animation curve
  26022. * @param endValue End value of the animation curve
  26023. * @param gradient Scalar amount to interpolate
  26024. * @returns Interpolated Color3 value
  26025. */
  26026. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26027. /**
  26028. * @hidden Internal use only
  26029. */
  26030. _getKeyValue(value: any): any;
  26031. /**
  26032. * @hidden Internal use only
  26033. */
  26034. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26035. /**
  26036. * Defines the function to use to interpolate matrices
  26037. * @param startValue defines the start matrix
  26038. * @param endValue defines the end matrix
  26039. * @param gradient defines the gradient between both matrices
  26040. * @param result defines an optional target matrix where to store the interpolation
  26041. * @returns the interpolated matrix
  26042. */
  26043. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26044. /**
  26045. * Makes a copy of the animation
  26046. * @returns Cloned animation
  26047. */
  26048. clone(): Animation;
  26049. /**
  26050. * Sets the key frames of the animation
  26051. * @param values The animation key frames to set
  26052. */
  26053. setKeys(values: Array<IAnimationKey>): void;
  26054. /**
  26055. * Serializes the animation to an object
  26056. * @returns Serialized object
  26057. */
  26058. serialize(): any;
  26059. /**
  26060. * Float animation type
  26061. */
  26062. private static _ANIMATIONTYPE_FLOAT;
  26063. /**
  26064. * Vector3 animation type
  26065. */
  26066. private static _ANIMATIONTYPE_VECTOR3;
  26067. /**
  26068. * Quaternion animation type
  26069. */
  26070. private static _ANIMATIONTYPE_QUATERNION;
  26071. /**
  26072. * Matrix animation type
  26073. */
  26074. private static _ANIMATIONTYPE_MATRIX;
  26075. /**
  26076. * Color3 animation type
  26077. */
  26078. private static _ANIMATIONTYPE_COLOR3;
  26079. /**
  26080. * Vector2 animation type
  26081. */
  26082. private static _ANIMATIONTYPE_VECTOR2;
  26083. /**
  26084. * Size animation type
  26085. */
  26086. private static _ANIMATIONTYPE_SIZE;
  26087. /**
  26088. * Relative Loop Mode
  26089. */
  26090. private static _ANIMATIONLOOPMODE_RELATIVE;
  26091. /**
  26092. * Cycle Loop Mode
  26093. */
  26094. private static _ANIMATIONLOOPMODE_CYCLE;
  26095. /**
  26096. * Constant Loop Mode
  26097. */
  26098. private static _ANIMATIONLOOPMODE_CONSTANT;
  26099. /**
  26100. * Get the float animation type
  26101. */
  26102. static readonly ANIMATIONTYPE_FLOAT: number;
  26103. /**
  26104. * Get the Vector3 animation type
  26105. */
  26106. static readonly ANIMATIONTYPE_VECTOR3: number;
  26107. /**
  26108. * Get the Vector2 animation type
  26109. */
  26110. static readonly ANIMATIONTYPE_VECTOR2: number;
  26111. /**
  26112. * Get the Size animation type
  26113. */
  26114. static readonly ANIMATIONTYPE_SIZE: number;
  26115. /**
  26116. * Get the Quaternion animation type
  26117. */
  26118. static readonly ANIMATIONTYPE_QUATERNION: number;
  26119. /**
  26120. * Get the Matrix animation type
  26121. */
  26122. static readonly ANIMATIONTYPE_MATRIX: number;
  26123. /**
  26124. * Get the Color3 animation type
  26125. */
  26126. static readonly ANIMATIONTYPE_COLOR3: number;
  26127. /**
  26128. * Get the Relative Loop Mode
  26129. */
  26130. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26131. /**
  26132. * Get the Cycle Loop Mode
  26133. */
  26134. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26135. /**
  26136. * Get the Constant Loop Mode
  26137. */
  26138. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26139. /** @hidden */
  26140. static _UniversalLerp(left: any, right: any, amount: number): any;
  26141. /**
  26142. * Parses an animation object and creates an animation
  26143. * @param parsedAnimation Parsed animation object
  26144. * @returns Animation object
  26145. */
  26146. static Parse(parsedAnimation: any): Animation;
  26147. /**
  26148. * Appends the serialized animations from the source animations
  26149. * @param source Source containing the animations
  26150. * @param destination Target to store the animations
  26151. */
  26152. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26153. }
  26154. }
  26155. declare module "babylonjs/Materials/Textures/baseTexture" {
  26156. import { Observable } from "babylonjs/Misc/observable";
  26157. import { IAnimatable } from "babylonjs/Misc/tools";
  26158. import { Nullable } from "babylonjs/types";
  26159. import { Scene } from "babylonjs/scene";
  26160. import { Matrix, ISize } from "babylonjs/Maths/math";
  26161. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26163. /**
  26164. * Base class of all the textures in babylon.
  26165. * It groups all the common properties the materials, post process, lights... might need
  26166. * in order to make a correct use of the texture.
  26167. */
  26168. export class BaseTexture implements IAnimatable {
  26169. /**
  26170. * Default anisotropic filtering level for the application.
  26171. * It is set to 4 as a good tradeoff between perf and quality.
  26172. */
  26173. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26174. /**
  26175. * Gets or sets the unique id of the texture
  26176. */
  26177. uniqueId: number;
  26178. /**
  26179. * Define the name of the texture.
  26180. */
  26181. name: string;
  26182. /**
  26183. * Gets or sets an object used to store user defined information.
  26184. */
  26185. metadata: any;
  26186. /**
  26187. * For internal use only. Please do not use.
  26188. */
  26189. reservedDataStore: any;
  26190. private _hasAlpha;
  26191. /**
  26192. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26193. */
  26194. hasAlpha: boolean;
  26195. /**
  26196. * Defines if the alpha value should be determined via the rgb values.
  26197. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26198. */
  26199. getAlphaFromRGB: boolean;
  26200. /**
  26201. * Intensity or strength of the texture.
  26202. * It is commonly used by materials to fine tune the intensity of the texture
  26203. */
  26204. level: number;
  26205. /**
  26206. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26207. * This is part of the texture as textures usually maps to one uv set.
  26208. */
  26209. coordinatesIndex: number;
  26210. private _coordinatesMode;
  26211. /**
  26212. * How a texture is mapped.
  26213. *
  26214. * | Value | Type | Description |
  26215. * | ----- | ----------------------------------- | ----------- |
  26216. * | 0 | EXPLICIT_MODE | |
  26217. * | 1 | SPHERICAL_MODE | |
  26218. * | 2 | PLANAR_MODE | |
  26219. * | 3 | CUBIC_MODE | |
  26220. * | 4 | PROJECTION_MODE | |
  26221. * | 5 | SKYBOX_MODE | |
  26222. * | 6 | INVCUBIC_MODE | |
  26223. * | 7 | EQUIRECTANGULAR_MODE | |
  26224. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26225. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26226. */
  26227. coordinatesMode: number;
  26228. /**
  26229. * | Value | Type | Description |
  26230. * | ----- | ------------------ | ----------- |
  26231. * | 0 | CLAMP_ADDRESSMODE | |
  26232. * | 1 | WRAP_ADDRESSMODE | |
  26233. * | 2 | MIRROR_ADDRESSMODE | |
  26234. */
  26235. wrapU: number;
  26236. /**
  26237. * | Value | Type | Description |
  26238. * | ----- | ------------------ | ----------- |
  26239. * | 0 | CLAMP_ADDRESSMODE | |
  26240. * | 1 | WRAP_ADDRESSMODE | |
  26241. * | 2 | MIRROR_ADDRESSMODE | |
  26242. */
  26243. wrapV: number;
  26244. /**
  26245. * | Value | Type | Description |
  26246. * | ----- | ------------------ | ----------- |
  26247. * | 0 | CLAMP_ADDRESSMODE | |
  26248. * | 1 | WRAP_ADDRESSMODE | |
  26249. * | 2 | MIRROR_ADDRESSMODE | |
  26250. */
  26251. wrapR: number;
  26252. /**
  26253. * With compliant hardware and browser (supporting anisotropic filtering)
  26254. * this defines the level of anisotropic filtering in the texture.
  26255. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26256. */
  26257. anisotropicFilteringLevel: number;
  26258. /**
  26259. * Define if the texture is a cube texture or if false a 2d texture.
  26260. */
  26261. isCube: boolean;
  26262. /**
  26263. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26264. */
  26265. is3D: boolean;
  26266. /**
  26267. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26268. * HDR texture are usually stored in linear space.
  26269. * This only impacts the PBR and Background materials
  26270. */
  26271. gammaSpace: boolean;
  26272. /**
  26273. * Gets whether or not the texture contains RGBD data.
  26274. */
  26275. readonly isRGBD: boolean;
  26276. /**
  26277. * Is Z inverted in the texture (useful in a cube texture).
  26278. */
  26279. invertZ: boolean;
  26280. /**
  26281. * Are mip maps generated for this texture or not.
  26282. */
  26283. readonly noMipmap: boolean;
  26284. /**
  26285. * @hidden
  26286. */
  26287. lodLevelInAlpha: boolean;
  26288. /**
  26289. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26290. */
  26291. lodGenerationOffset: number;
  26292. /**
  26293. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26294. */
  26295. lodGenerationScale: number;
  26296. /**
  26297. * Define if the texture is a render target.
  26298. */
  26299. isRenderTarget: boolean;
  26300. /**
  26301. * Define the unique id of the texture in the scene.
  26302. */
  26303. readonly uid: string;
  26304. /**
  26305. * Return a string representation of the texture.
  26306. * @returns the texture as a string
  26307. */
  26308. toString(): string;
  26309. /**
  26310. * Get the class name of the texture.
  26311. * @returns "BaseTexture"
  26312. */
  26313. getClassName(): string;
  26314. /**
  26315. * Define the list of animation attached to the texture.
  26316. */
  26317. animations: import("babylonjs/Animations/animation").Animation[];
  26318. /**
  26319. * An event triggered when the texture is disposed.
  26320. */
  26321. onDisposeObservable: Observable<BaseTexture>;
  26322. private _onDisposeObserver;
  26323. /**
  26324. * Callback triggered when the texture has been disposed.
  26325. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26326. */
  26327. onDispose: () => void;
  26328. /**
  26329. * Define the current state of the loading sequence when in delayed load mode.
  26330. */
  26331. delayLoadState: number;
  26332. private _scene;
  26333. /** @hidden */
  26334. _texture: Nullable<InternalTexture>;
  26335. private _uid;
  26336. /**
  26337. * Define if the texture is preventinga material to render or not.
  26338. * If not and the texture is not ready, the engine will use a default black texture instead.
  26339. */
  26340. readonly isBlocking: boolean;
  26341. /**
  26342. * Instantiates a new BaseTexture.
  26343. * Base class of all the textures in babylon.
  26344. * It groups all the common properties the materials, post process, lights... might need
  26345. * in order to make a correct use of the texture.
  26346. * @param scene Define the scene the texture blongs to
  26347. */
  26348. constructor(scene: Nullable<Scene>);
  26349. /**
  26350. * Get the scene the texture belongs to.
  26351. * @returns the scene or null if undefined
  26352. */
  26353. getScene(): Nullable<Scene>;
  26354. /**
  26355. * Get the texture transform matrix used to offset tile the texture for istance.
  26356. * @returns the transformation matrix
  26357. */
  26358. getTextureMatrix(): Matrix;
  26359. /**
  26360. * Get the texture reflection matrix used to rotate/transform the reflection.
  26361. * @returns the reflection matrix
  26362. */
  26363. getReflectionTextureMatrix(): Matrix;
  26364. /**
  26365. * Get the underlying lower level texture from Babylon.
  26366. * @returns the insternal texture
  26367. */
  26368. getInternalTexture(): Nullable<InternalTexture>;
  26369. /**
  26370. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26371. * @returns true if ready or not blocking
  26372. */
  26373. isReadyOrNotBlocking(): boolean;
  26374. /**
  26375. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26376. * @returns true if fully ready
  26377. */
  26378. isReady(): boolean;
  26379. private _cachedSize;
  26380. /**
  26381. * Get the size of the texture.
  26382. * @returns the texture size.
  26383. */
  26384. getSize(): ISize;
  26385. /**
  26386. * Get the base size of the texture.
  26387. * It can be different from the size if the texture has been resized for POT for instance
  26388. * @returns the base size
  26389. */
  26390. getBaseSize(): ISize;
  26391. /**
  26392. * Update the sampling mode of the texture.
  26393. * Default is Trilinear mode.
  26394. *
  26395. * | Value | Type | Description |
  26396. * | ----- | ------------------ | ----------- |
  26397. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26398. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26399. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26400. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26401. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26402. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26403. * | 7 | NEAREST_LINEAR | |
  26404. * | 8 | NEAREST_NEAREST | |
  26405. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26406. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26407. * | 11 | LINEAR_LINEAR | |
  26408. * | 12 | LINEAR_NEAREST | |
  26409. *
  26410. * > _mag_: magnification filter (close to the viewer)
  26411. * > _min_: minification filter (far from the viewer)
  26412. * > _mip_: filter used between mip map levels
  26413. *@param samplingMode Define the new sampling mode of the texture
  26414. */
  26415. updateSamplingMode(samplingMode: number): void;
  26416. /**
  26417. * Scales the texture if is `canRescale()`
  26418. * @param ratio the resize factor we want to use to rescale
  26419. */
  26420. scale(ratio: number): void;
  26421. /**
  26422. * Get if the texture can rescale.
  26423. */
  26424. readonly canRescale: boolean;
  26425. /** @hidden */
  26426. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26427. /** @hidden */
  26428. _rebuild(): void;
  26429. /**
  26430. * Triggers the load sequence in delayed load mode.
  26431. */
  26432. delayLoad(): void;
  26433. /**
  26434. * Clones the texture.
  26435. * @returns the cloned texture
  26436. */
  26437. clone(): Nullable<BaseTexture>;
  26438. /**
  26439. * Get the texture underlying type (INT, FLOAT...)
  26440. */
  26441. readonly textureType: number;
  26442. /**
  26443. * Get the texture underlying format (RGB, RGBA...)
  26444. */
  26445. readonly textureFormat: number;
  26446. /**
  26447. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26448. * This will returns an RGBA array buffer containing either in values (0-255) or
  26449. * float values (0-1) depending of the underlying buffer type.
  26450. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26451. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26452. * @param buffer defines a user defined buffer to fill with data (can be null)
  26453. * @returns The Array buffer containing the pixels data.
  26454. */
  26455. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26456. /**
  26457. * Release and destroy the underlying lower level texture aka internalTexture.
  26458. */
  26459. releaseInternalTexture(): void;
  26460. /**
  26461. * Get the polynomial representation of the texture data.
  26462. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26463. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26464. */
  26465. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26466. /** @hidden */
  26467. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26468. /** @hidden */
  26469. readonly _lodTextureMid: Nullable<BaseTexture>;
  26470. /** @hidden */
  26471. readonly _lodTextureLow: Nullable<BaseTexture>;
  26472. /**
  26473. * Dispose the texture and release its associated resources.
  26474. */
  26475. dispose(): void;
  26476. /**
  26477. * Serialize the texture into a JSON representation that can be parsed later on.
  26478. * @returns the JSON representation of the texture
  26479. */
  26480. serialize(): any;
  26481. /**
  26482. * Helper function to be called back once a list of texture contains only ready textures.
  26483. * @param textures Define the list of textures to wait for
  26484. * @param callback Define the callback triggered once the entire list will be ready
  26485. */
  26486. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26487. }
  26488. }
  26489. declare module "babylonjs/Materials/uniformBuffer" {
  26490. import { Nullable, FloatArray } from "babylonjs/types";
  26491. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26492. import { Engine } from "babylonjs/Engines/engine";
  26493. import { Effect } from "babylonjs/Materials/effect";
  26494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26495. /**
  26496. * Uniform buffer objects.
  26497. *
  26498. * Handles blocks of uniform on the GPU.
  26499. *
  26500. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26501. *
  26502. * For more information, please refer to :
  26503. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26504. */
  26505. export class UniformBuffer {
  26506. private _engine;
  26507. private _buffer;
  26508. private _data;
  26509. private _bufferData;
  26510. private _dynamic?;
  26511. private _uniformLocations;
  26512. private _uniformSizes;
  26513. private _uniformLocationPointer;
  26514. private _needSync;
  26515. private _noUBO;
  26516. private _currentEffect;
  26517. private static _MAX_UNIFORM_SIZE;
  26518. private static _tempBuffer;
  26519. /**
  26520. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26521. * This is dynamic to allow compat with webgl 1 and 2.
  26522. * You will need to pass the name of the uniform as well as the value.
  26523. */
  26524. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26525. /**
  26526. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26527. * This is dynamic to allow compat with webgl 1 and 2.
  26528. * You will need to pass the name of the uniform as well as the value.
  26529. */
  26530. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26531. /**
  26532. * Lambda to Update a single float in a uniform buffer.
  26533. * This is dynamic to allow compat with webgl 1 and 2.
  26534. * You will need to pass the name of the uniform as well as the value.
  26535. */
  26536. updateFloat: (name: string, x: number) => void;
  26537. /**
  26538. * Lambda to Update a vec2 of float in a uniform buffer.
  26539. * This is dynamic to allow compat with webgl 1 and 2.
  26540. * You will need to pass the name of the uniform as well as the value.
  26541. */
  26542. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26543. /**
  26544. * Lambda to Update a vec3 of float in a uniform buffer.
  26545. * This is dynamic to allow compat with webgl 1 and 2.
  26546. * You will need to pass the name of the uniform as well as the value.
  26547. */
  26548. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26549. /**
  26550. * Lambda to Update a vec4 of float in a uniform buffer.
  26551. * This is dynamic to allow compat with webgl 1 and 2.
  26552. * You will need to pass the name of the uniform as well as the value.
  26553. */
  26554. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26555. /**
  26556. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26557. * This is dynamic to allow compat with webgl 1 and 2.
  26558. * You will need to pass the name of the uniform as well as the value.
  26559. */
  26560. updateMatrix: (name: string, mat: Matrix) => void;
  26561. /**
  26562. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26563. * This is dynamic to allow compat with webgl 1 and 2.
  26564. * You will need to pass the name of the uniform as well as the value.
  26565. */
  26566. updateVector3: (name: string, vector: Vector3) => void;
  26567. /**
  26568. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26569. * This is dynamic to allow compat with webgl 1 and 2.
  26570. * You will need to pass the name of the uniform as well as the value.
  26571. */
  26572. updateVector4: (name: string, vector: Vector4) => void;
  26573. /**
  26574. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26575. * This is dynamic to allow compat with webgl 1 and 2.
  26576. * You will need to pass the name of the uniform as well as the value.
  26577. */
  26578. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26579. /**
  26580. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26581. * This is dynamic to allow compat with webgl 1 and 2.
  26582. * You will need to pass the name of the uniform as well as the value.
  26583. */
  26584. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26585. /**
  26586. * Instantiates a new Uniform buffer objects.
  26587. *
  26588. * Handles blocks of uniform on the GPU.
  26589. *
  26590. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26591. *
  26592. * For more information, please refer to :
  26593. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26594. * @param engine Define the engine the buffer is associated with
  26595. * @param data Define the data contained in the buffer
  26596. * @param dynamic Define if the buffer is updatable
  26597. */
  26598. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26599. /**
  26600. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26601. * or just falling back on setUniformXXX calls.
  26602. */
  26603. readonly useUbo: boolean;
  26604. /**
  26605. * Indicates if the WebGL underlying uniform buffer is in sync
  26606. * with the javascript cache data.
  26607. */
  26608. readonly isSync: boolean;
  26609. /**
  26610. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26611. * Also, a dynamic UniformBuffer will disable cache verification and always
  26612. * update the underlying WebGL uniform buffer to the GPU.
  26613. * @returns if Dynamic, otherwise false
  26614. */
  26615. isDynamic(): boolean;
  26616. /**
  26617. * The data cache on JS side.
  26618. * @returns the underlying data as a float array
  26619. */
  26620. getData(): Float32Array;
  26621. /**
  26622. * The underlying WebGL Uniform buffer.
  26623. * @returns the webgl buffer
  26624. */
  26625. getBuffer(): Nullable<WebGLBuffer>;
  26626. /**
  26627. * std140 layout specifies how to align data within an UBO structure.
  26628. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26629. * for specs.
  26630. */
  26631. private _fillAlignment;
  26632. /**
  26633. * Adds an uniform in the buffer.
  26634. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26635. * for the layout to be correct !
  26636. * @param name Name of the uniform, as used in the uniform block in the shader.
  26637. * @param size Data size, or data directly.
  26638. */
  26639. addUniform(name: string, size: number | number[]): void;
  26640. /**
  26641. * Adds a Matrix 4x4 to the uniform buffer.
  26642. * @param name Name of the uniform, as used in the uniform block in the shader.
  26643. * @param mat A 4x4 matrix.
  26644. */
  26645. addMatrix(name: string, mat: Matrix): void;
  26646. /**
  26647. * Adds a vec2 to the uniform buffer.
  26648. * @param name Name of the uniform, as used in the uniform block in the shader.
  26649. * @param x Define the x component value of the vec2
  26650. * @param y Define the y component value of the vec2
  26651. */
  26652. addFloat2(name: string, x: number, y: number): void;
  26653. /**
  26654. * Adds a vec3 to the uniform buffer.
  26655. * @param name Name of the uniform, as used in the uniform block in the shader.
  26656. * @param x Define the x component value of the vec3
  26657. * @param y Define the y component value of the vec3
  26658. * @param z Define the z component value of the vec3
  26659. */
  26660. addFloat3(name: string, x: number, y: number, z: number): void;
  26661. /**
  26662. * Adds a vec3 to the uniform buffer.
  26663. * @param name Name of the uniform, as used in the uniform block in the shader.
  26664. * @param color Define the vec3 from a Color
  26665. */
  26666. addColor3(name: string, color: Color3): void;
  26667. /**
  26668. * Adds a vec4 to the uniform buffer.
  26669. * @param name Name of the uniform, as used in the uniform block in the shader.
  26670. * @param color Define the rgb components from a Color
  26671. * @param alpha Define the a component of the vec4
  26672. */
  26673. addColor4(name: string, color: Color3, alpha: number): void;
  26674. /**
  26675. * Adds a vec3 to the uniform buffer.
  26676. * @param name Name of the uniform, as used in the uniform block in the shader.
  26677. * @param vector Define the vec3 components from a Vector
  26678. */
  26679. addVector3(name: string, vector: Vector3): void;
  26680. /**
  26681. * Adds a Matrix 3x3 to the uniform buffer.
  26682. * @param name Name of the uniform, as used in the uniform block in the shader.
  26683. */
  26684. addMatrix3x3(name: string): void;
  26685. /**
  26686. * Adds a Matrix 2x2 to the uniform buffer.
  26687. * @param name Name of the uniform, as used in the uniform block in the shader.
  26688. */
  26689. addMatrix2x2(name: string): void;
  26690. /**
  26691. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26692. */
  26693. create(): void;
  26694. /** @hidden */
  26695. _rebuild(): void;
  26696. /**
  26697. * Updates the WebGL Uniform Buffer on the GPU.
  26698. * If the `dynamic` flag is set to true, no cache comparison is done.
  26699. * Otherwise, the buffer will be updated only if the cache differs.
  26700. */
  26701. update(): void;
  26702. /**
  26703. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26704. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26705. * @param data Define the flattened data
  26706. * @param size Define the size of the data.
  26707. */
  26708. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26709. private _updateMatrix3x3ForUniform;
  26710. private _updateMatrix3x3ForEffect;
  26711. private _updateMatrix2x2ForEffect;
  26712. private _updateMatrix2x2ForUniform;
  26713. private _updateFloatForEffect;
  26714. private _updateFloatForUniform;
  26715. private _updateFloat2ForEffect;
  26716. private _updateFloat2ForUniform;
  26717. private _updateFloat3ForEffect;
  26718. private _updateFloat3ForUniform;
  26719. private _updateFloat4ForEffect;
  26720. private _updateFloat4ForUniform;
  26721. private _updateMatrixForEffect;
  26722. private _updateMatrixForUniform;
  26723. private _updateVector3ForEffect;
  26724. private _updateVector3ForUniform;
  26725. private _updateVector4ForEffect;
  26726. private _updateVector4ForUniform;
  26727. private _updateColor3ForEffect;
  26728. private _updateColor3ForUniform;
  26729. private _updateColor4ForEffect;
  26730. private _updateColor4ForUniform;
  26731. /**
  26732. * Sets a sampler uniform on the effect.
  26733. * @param name Define the name of the sampler.
  26734. * @param texture Define the texture to set in the sampler
  26735. */
  26736. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26737. /**
  26738. * Directly updates the value of the uniform in the cache AND on the GPU.
  26739. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26740. * @param data Define the flattened data
  26741. */
  26742. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26743. /**
  26744. * Binds this uniform buffer to an effect.
  26745. * @param effect Define the effect to bind the buffer to
  26746. * @param name Name of the uniform block in the shader.
  26747. */
  26748. bindToEffect(effect: Effect, name: string): void;
  26749. /**
  26750. * Disposes the uniform buffer.
  26751. */
  26752. dispose(): void;
  26753. }
  26754. }
  26755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26756. import { Nullable } from "babylonjs/types";
  26757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26758. /**
  26759. * This represents the required contract to create a new type of texture loader.
  26760. */
  26761. export interface IInternalTextureLoader {
  26762. /**
  26763. * Defines wether the loader supports cascade loading the different faces.
  26764. */
  26765. supportCascades: boolean;
  26766. /**
  26767. * This returns if the loader support the current file information.
  26768. * @param extension defines the file extension of the file being loaded
  26769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26770. * @param fallback defines the fallback internal texture if any
  26771. * @param isBase64 defines whether the texture is encoded as a base64
  26772. * @param isBuffer defines whether the texture data are stored as a buffer
  26773. * @returns true if the loader can load the specified file
  26774. */
  26775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26776. /**
  26777. * Transform the url before loading if required.
  26778. * @param rootUrl the url of the texture
  26779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26780. * @returns the transformed texture
  26781. */
  26782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26783. /**
  26784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26785. * @param rootUrl the url of the texture
  26786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26787. * @returns the fallback texture
  26788. */
  26789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26790. /**
  26791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26792. * @param data contains the texture data
  26793. * @param texture defines the BabylonJS internal texture
  26794. * @param createPolynomials will be true if polynomials have been requested
  26795. * @param onLoad defines the callback to trigger once the texture is ready
  26796. * @param onError defines the callback to trigger in case of error
  26797. */
  26798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26799. /**
  26800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26801. * @param data contains the texture data
  26802. * @param texture defines the BabylonJS internal texture
  26803. * @param callback defines the method to call once ready to upload
  26804. */
  26805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26806. }
  26807. }
  26808. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26809. import { Scene } from "babylonjs/scene";
  26810. import { Engine } from "babylonjs/Engines/engine";
  26811. import { Texture } from "babylonjs/Materials/Textures/texture";
  26812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26813. /**
  26814. * Creation options of the multi render target texture.
  26815. */
  26816. export interface IMultiRenderTargetOptions {
  26817. /**
  26818. * Define if the texture needs to create mip maps after render.
  26819. */
  26820. generateMipMaps?: boolean;
  26821. /**
  26822. * Define the types of all the draw buffers we want to create
  26823. */
  26824. types?: number[];
  26825. /**
  26826. * Define the sampling modes of all the draw buffers we want to create
  26827. */
  26828. samplingModes?: number[];
  26829. /**
  26830. * Define if a depth buffer is required
  26831. */
  26832. generateDepthBuffer?: boolean;
  26833. /**
  26834. * Define if a stencil buffer is required
  26835. */
  26836. generateStencilBuffer?: boolean;
  26837. /**
  26838. * Define if a depth texture is required instead of a depth buffer
  26839. */
  26840. generateDepthTexture?: boolean;
  26841. /**
  26842. * Define the number of desired draw buffers
  26843. */
  26844. textureCount?: number;
  26845. /**
  26846. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26847. */
  26848. doNotChangeAspectRatio?: boolean;
  26849. /**
  26850. * Define the default type of the buffers we are creating
  26851. */
  26852. defaultType?: number;
  26853. }
  26854. /**
  26855. * A multi render target, like a render target provides the ability to render to a texture.
  26856. * Unlike the render target, it can render to several draw buffers in one draw.
  26857. * This is specially interesting in deferred rendering or for any effects requiring more than
  26858. * just one color from a single pass.
  26859. */
  26860. export class MultiRenderTarget extends RenderTargetTexture {
  26861. private _internalTextures;
  26862. private _textures;
  26863. private _multiRenderTargetOptions;
  26864. /**
  26865. * Get if draw buffers are currently supported by the used hardware and browser.
  26866. */
  26867. readonly isSupported: boolean;
  26868. /**
  26869. * Get the list of textures generated by the multi render target.
  26870. */
  26871. readonly textures: Texture[];
  26872. /**
  26873. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26874. */
  26875. readonly depthTexture: Texture;
  26876. /**
  26877. * Set the wrapping mode on U of all the textures we are rendering to.
  26878. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26879. */
  26880. wrapU: number;
  26881. /**
  26882. * Set the wrapping mode on V of all the textures we are rendering to.
  26883. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26884. */
  26885. wrapV: number;
  26886. /**
  26887. * Instantiate a new multi render target texture.
  26888. * A multi render target, like a render target provides the ability to render to a texture.
  26889. * Unlike the render target, it can render to several draw buffers in one draw.
  26890. * This is specially interesting in deferred rendering or for any effects requiring more than
  26891. * just one color from a single pass.
  26892. * @param name Define the name of the texture
  26893. * @param size Define the size of the buffers to render to
  26894. * @param count Define the number of target we are rendering into
  26895. * @param scene Define the scene the texture belongs to
  26896. * @param options Define the options used to create the multi render target
  26897. */
  26898. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26899. /** @hidden */
  26900. _rebuild(): void;
  26901. private _createInternalTextures;
  26902. private _createTextures;
  26903. /**
  26904. * Define the number of samples used if MSAA is enabled.
  26905. */
  26906. samples: number;
  26907. /**
  26908. * Resize all the textures in the multi render target.
  26909. * Be carrefull as it will recreate all the data in the new texture.
  26910. * @param size Define the new size
  26911. */
  26912. resize(size: any): void;
  26913. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26914. /**
  26915. * Dispose the render targets and their associated resources
  26916. */
  26917. dispose(): void;
  26918. /**
  26919. * Release all the underlying texture used as draw buffers.
  26920. */
  26921. releaseInternalTextures(): void;
  26922. }
  26923. }
  26924. declare module "babylonjs/Audio/analyser" {
  26925. import { Scene } from "babylonjs/scene";
  26926. /**
  26927. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26929. */
  26930. export class Analyser {
  26931. /**
  26932. * Gets or sets the smoothing
  26933. * @ignorenaming
  26934. */
  26935. SMOOTHING: number;
  26936. /**
  26937. * Gets or sets the FFT table size
  26938. * @ignorenaming
  26939. */
  26940. FFT_SIZE: number;
  26941. /**
  26942. * Gets or sets the bar graph amplitude
  26943. * @ignorenaming
  26944. */
  26945. BARGRAPHAMPLITUDE: number;
  26946. /**
  26947. * Gets or sets the position of the debug canvas
  26948. * @ignorenaming
  26949. */
  26950. DEBUGCANVASPOS: {
  26951. x: number;
  26952. y: number;
  26953. };
  26954. /**
  26955. * Gets or sets the debug canvas size
  26956. * @ignorenaming
  26957. */
  26958. DEBUGCANVASSIZE: {
  26959. width: number;
  26960. height: number;
  26961. };
  26962. private _byteFreqs;
  26963. private _byteTime;
  26964. private _floatFreqs;
  26965. private _webAudioAnalyser;
  26966. private _debugCanvas;
  26967. private _debugCanvasContext;
  26968. private _scene;
  26969. private _registerFunc;
  26970. private _audioEngine;
  26971. /**
  26972. * Creates a new analyser
  26973. * @param scene defines hosting scene
  26974. */
  26975. constructor(scene: Scene);
  26976. /**
  26977. * Get the number of data values you will have to play with for the visualization
  26978. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26979. * @returns a number
  26980. */
  26981. getFrequencyBinCount(): number;
  26982. /**
  26983. * Gets the current frequency data as a byte array
  26984. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26985. * @returns a Uint8Array
  26986. */
  26987. getByteFrequencyData(): Uint8Array;
  26988. /**
  26989. * Gets the current waveform as a byte array
  26990. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26991. * @returns a Uint8Array
  26992. */
  26993. getByteTimeDomainData(): Uint8Array;
  26994. /**
  26995. * Gets the current frequency data as a float array
  26996. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26997. * @returns a Float32Array
  26998. */
  26999. getFloatFrequencyData(): Float32Array;
  27000. /**
  27001. * Renders the debug canvas
  27002. */
  27003. drawDebugCanvas(): void;
  27004. /**
  27005. * Stops rendering the debug canvas and removes it
  27006. */
  27007. stopDebugCanvas(): void;
  27008. /**
  27009. * Connects two audio nodes
  27010. * @param inputAudioNode defines first node to connect
  27011. * @param outputAudioNode defines second node to connect
  27012. */
  27013. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27014. /**
  27015. * Releases all associated resources
  27016. */
  27017. dispose(): void;
  27018. }
  27019. }
  27020. declare module "babylonjs/Audio/audioEngine" {
  27021. import { IDisposable } from "babylonjs/scene";
  27022. import { Analyser } from "babylonjs/Audio/analyser";
  27023. import { Nullable } from "babylonjs/types";
  27024. import { Observable } from "babylonjs/Misc/observable";
  27025. /**
  27026. * This represents an audio engine and it is responsible
  27027. * to play, synchronize and analyse sounds throughout the application.
  27028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27029. */
  27030. export interface IAudioEngine extends IDisposable {
  27031. /**
  27032. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27033. */
  27034. readonly canUseWebAudio: boolean;
  27035. /**
  27036. * Gets the current AudioContext if available.
  27037. */
  27038. readonly audioContext: Nullable<AudioContext>;
  27039. /**
  27040. * The master gain node defines the global audio volume of your audio engine.
  27041. */
  27042. readonly masterGain: GainNode;
  27043. /**
  27044. * Gets whether or not mp3 are supported by your browser.
  27045. */
  27046. readonly isMP3supported: boolean;
  27047. /**
  27048. * Gets whether or not ogg are supported by your browser.
  27049. */
  27050. readonly isOGGsupported: boolean;
  27051. /**
  27052. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27053. * @ignoreNaming
  27054. */
  27055. WarnedWebAudioUnsupported: boolean;
  27056. /**
  27057. * Defines if the audio engine relies on a custom unlocked button.
  27058. * In this case, the embedded button will not be displayed.
  27059. */
  27060. useCustomUnlockedButton: boolean;
  27061. /**
  27062. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27063. */
  27064. readonly unlocked: boolean;
  27065. /**
  27066. * Event raised when audio has been unlocked on the browser.
  27067. */
  27068. onAudioUnlockedObservable: Observable<AudioEngine>;
  27069. /**
  27070. * Event raised when audio has been locked on the browser.
  27071. */
  27072. onAudioLockedObservable: Observable<AudioEngine>;
  27073. /**
  27074. * Flags the audio engine in Locked state.
  27075. * This happens due to new browser policies preventing audio to autoplay.
  27076. */
  27077. lock(): void;
  27078. /**
  27079. * Unlocks the audio engine once a user action has been done on the dom.
  27080. * This is helpful to resume play once browser policies have been satisfied.
  27081. */
  27082. unlock(): void;
  27083. }
  27084. /**
  27085. * This represents the default audio engine used in babylon.
  27086. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27088. */
  27089. export class AudioEngine implements IAudioEngine {
  27090. private _audioContext;
  27091. private _audioContextInitialized;
  27092. private _muteButton;
  27093. private _hostElement;
  27094. /**
  27095. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27096. */
  27097. canUseWebAudio: boolean;
  27098. /**
  27099. * The master gain node defines the global audio volume of your audio engine.
  27100. */
  27101. masterGain: GainNode;
  27102. /**
  27103. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27104. * @ignoreNaming
  27105. */
  27106. WarnedWebAudioUnsupported: boolean;
  27107. /**
  27108. * Gets whether or not mp3 are supported by your browser.
  27109. */
  27110. isMP3supported: boolean;
  27111. /**
  27112. * Gets whether or not ogg are supported by your browser.
  27113. */
  27114. isOGGsupported: boolean;
  27115. /**
  27116. * Gets whether audio has been unlocked on the device.
  27117. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27118. * a user interaction has happened.
  27119. */
  27120. unlocked: boolean;
  27121. /**
  27122. * Defines if the audio engine relies on a custom unlocked button.
  27123. * In this case, the embedded button will not be displayed.
  27124. */
  27125. useCustomUnlockedButton: boolean;
  27126. /**
  27127. * Event raised when audio has been unlocked on the browser.
  27128. */
  27129. onAudioUnlockedObservable: Observable<AudioEngine>;
  27130. /**
  27131. * Event raised when audio has been locked on the browser.
  27132. */
  27133. onAudioLockedObservable: Observable<AudioEngine>;
  27134. /**
  27135. * Gets the current AudioContext if available.
  27136. */
  27137. readonly audioContext: Nullable<AudioContext>;
  27138. private _connectedAnalyser;
  27139. /**
  27140. * Instantiates a new audio engine.
  27141. *
  27142. * There should be only one per page as some browsers restrict the number
  27143. * of audio contexts you can create.
  27144. * @param hostElement defines the host element where to display the mute icon if necessary
  27145. */
  27146. constructor(hostElement?: Nullable<HTMLElement>);
  27147. /**
  27148. * Flags the audio engine in Locked state.
  27149. * This happens due to new browser policies preventing audio to autoplay.
  27150. */
  27151. lock(): void;
  27152. /**
  27153. * Unlocks the audio engine once a user action has been done on the dom.
  27154. * This is helpful to resume play once browser policies have been satisfied.
  27155. */
  27156. unlock(): void;
  27157. private _resumeAudioContext;
  27158. private _initializeAudioContext;
  27159. private _tryToRun;
  27160. private _triggerRunningState;
  27161. private _triggerSuspendedState;
  27162. private _displayMuteButton;
  27163. private _moveButtonToTopLeft;
  27164. private _onResize;
  27165. private _hideMuteButton;
  27166. /**
  27167. * Destroy and release the resources associated with the audio ccontext.
  27168. */
  27169. dispose(): void;
  27170. /**
  27171. * Gets the global volume sets on the master gain.
  27172. * @returns the global volume if set or -1 otherwise
  27173. */
  27174. getGlobalVolume(): number;
  27175. /**
  27176. * Sets the global volume of your experience (sets on the master gain).
  27177. * @param newVolume Defines the new global volume of the application
  27178. */
  27179. setGlobalVolume(newVolume: number): void;
  27180. /**
  27181. * Connect the audio engine to an audio analyser allowing some amazing
  27182. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27184. * @param analyser The analyser to connect to the engine
  27185. */
  27186. connectToAnalyser(analyser: Analyser): void;
  27187. }
  27188. }
  27189. declare module "babylonjs/Loading/loadingScreen" {
  27190. /**
  27191. * Interface used to present a loading screen while loading a scene
  27192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27193. */
  27194. export interface ILoadingScreen {
  27195. /**
  27196. * Function called to display the loading screen
  27197. */
  27198. displayLoadingUI: () => void;
  27199. /**
  27200. * Function called to hide the loading screen
  27201. */
  27202. hideLoadingUI: () => void;
  27203. /**
  27204. * Gets or sets the color to use for the background
  27205. */
  27206. loadingUIBackgroundColor: string;
  27207. /**
  27208. * Gets or sets the text to display while loading
  27209. */
  27210. loadingUIText: string;
  27211. }
  27212. /**
  27213. * Class used for the default loading screen
  27214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27215. */
  27216. export class DefaultLoadingScreen implements ILoadingScreen {
  27217. private _renderingCanvas;
  27218. private _loadingText;
  27219. private _loadingDivBackgroundColor;
  27220. private _loadingDiv;
  27221. private _loadingTextDiv;
  27222. /**
  27223. * Creates a new default loading screen
  27224. * @param _renderingCanvas defines the canvas used to render the scene
  27225. * @param _loadingText defines the default text to display
  27226. * @param _loadingDivBackgroundColor defines the default background color
  27227. */
  27228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27229. /**
  27230. * Function called to display the loading screen
  27231. */
  27232. displayLoadingUI(): void;
  27233. /**
  27234. * Function called to hide the loading screen
  27235. */
  27236. hideLoadingUI(): void;
  27237. /**
  27238. * Gets or sets the text to display while loading
  27239. */
  27240. loadingUIText: string;
  27241. /**
  27242. * Gets or sets the color to use for the background
  27243. */
  27244. loadingUIBackgroundColor: string;
  27245. private _resizeLoadingUI;
  27246. }
  27247. }
  27248. declare module "babylonjs/Materials/Textures/videoTexture" {
  27249. import { Observable } from "babylonjs/Misc/observable";
  27250. import { Nullable } from "babylonjs/types";
  27251. import { Scene } from "babylonjs/scene";
  27252. import { Texture } from "babylonjs/Materials/Textures/texture";
  27253. /**
  27254. * Settings for finer control over video usage
  27255. */
  27256. export interface VideoTextureSettings {
  27257. /**
  27258. * Applies `autoplay` to video, if specified
  27259. */
  27260. autoPlay?: boolean;
  27261. /**
  27262. * Applies `loop` to video, if specified
  27263. */
  27264. loop?: boolean;
  27265. /**
  27266. * Automatically updates internal texture from video at every frame in the render loop
  27267. */
  27268. autoUpdateTexture: boolean;
  27269. /**
  27270. * Image src displayed during the video loading or until the user interacts with the video.
  27271. */
  27272. poster?: string;
  27273. }
  27274. /**
  27275. * If you want to display a video in your scene, this is the special texture for that.
  27276. * This special texture works similar to other textures, with the exception of a few parameters.
  27277. * @see https://doc.babylonjs.com/how_to/video_texture
  27278. */
  27279. export class VideoTexture extends Texture {
  27280. /**
  27281. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27282. */
  27283. readonly autoUpdateTexture: boolean;
  27284. /**
  27285. * The video instance used by the texture internally
  27286. */
  27287. readonly video: HTMLVideoElement;
  27288. private _onUserActionRequestedObservable;
  27289. /**
  27290. * Event triggerd when a dom action is required by the user to play the video.
  27291. * This happens due to recent changes in browser policies preventing video to auto start.
  27292. */
  27293. readonly onUserActionRequestedObservable: Observable<Texture>;
  27294. private _generateMipMaps;
  27295. private _engine;
  27296. private _stillImageCaptured;
  27297. private _displayingPosterTexture;
  27298. private _settings;
  27299. private _createInternalTextureOnEvent;
  27300. /**
  27301. * Creates a video texture.
  27302. * If you want to display a video in your scene, this is the special texture for that.
  27303. * This special texture works similar to other textures, with the exception of a few parameters.
  27304. * @see https://doc.babylonjs.com/how_to/video_texture
  27305. * @param name optional name, will detect from video source, if not defined
  27306. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27307. * @param scene is obviously the current scene.
  27308. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27309. * @param invertY is false by default but can be used to invert video on Y axis
  27310. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27311. * @param settings allows finer control over video usage
  27312. */
  27313. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27314. private _getName;
  27315. private _getVideo;
  27316. private _createInternalTexture;
  27317. private reset;
  27318. /**
  27319. * @hidden Internal method to initiate `update`.
  27320. */
  27321. _rebuild(): void;
  27322. /**
  27323. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27324. */
  27325. update(): void;
  27326. /**
  27327. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27328. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27329. */
  27330. updateTexture(isVisible: boolean): void;
  27331. protected _updateInternalTexture: () => void;
  27332. /**
  27333. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27334. * @param url New url.
  27335. */
  27336. updateURL(url: string): void;
  27337. /**
  27338. * Dispose the texture and release its associated resources.
  27339. */
  27340. dispose(): void;
  27341. /**
  27342. * Creates a video texture straight from a stream.
  27343. * @param scene Define the scene the texture should be created in
  27344. * @param stream Define the stream the texture should be created from
  27345. * @returns The created video texture as a promise
  27346. */
  27347. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27348. /**
  27349. * Creates a video texture straight from your WebCam video feed.
  27350. * @param scene Define the scene the texture should be created in
  27351. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27352. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27353. * @returns The created video texture as a promise
  27354. */
  27355. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27356. minWidth: number;
  27357. maxWidth: number;
  27358. minHeight: number;
  27359. maxHeight: number;
  27360. deviceId: string;
  27361. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27362. /**
  27363. * Creates a video texture straight from your WebCam video feed.
  27364. * @param scene Define the scene the texture should be created in
  27365. * @param onReady Define a callback to triggered once the texture will be ready
  27366. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27367. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27368. */
  27369. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27370. minWidth: number;
  27371. maxWidth: number;
  27372. minHeight: number;
  27373. maxHeight: number;
  27374. deviceId: string;
  27375. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27376. }
  27377. }
  27378. declare module "babylonjs/Engines/engine" {
  27379. import { Observable } from "babylonjs/Misc/observable";
  27380. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27381. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27382. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27383. import { Camera } from "babylonjs/Cameras/camera";
  27384. import { Scene } from "babylonjs/scene";
  27385. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27386. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27388. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27389. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27390. import { Material } from "babylonjs/Materials/material";
  27391. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27394. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27395. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27396. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27397. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27398. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27399. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27400. import { WebRequest } from "babylonjs/Misc/webRequest";
  27401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27403. /**
  27404. * Interface for attribute information associated with buffer instanciation
  27405. */
  27406. export class InstancingAttributeInfo {
  27407. /**
  27408. * Index/offset of the attribute in the vertex shader
  27409. */
  27410. index: number;
  27411. /**
  27412. * size of the attribute, 1, 2, 3 or 4
  27413. */
  27414. attributeSize: number;
  27415. /**
  27416. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27417. * default is FLOAT
  27418. */
  27419. attribyteType: number;
  27420. /**
  27421. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27422. */
  27423. normalized: boolean;
  27424. /**
  27425. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27426. */
  27427. offset: number;
  27428. /**
  27429. * Name of the GLSL attribute, for debugging purpose only
  27430. */
  27431. attributeName: string;
  27432. }
  27433. /**
  27434. * Define options used to create a depth texture
  27435. */
  27436. export class DepthTextureCreationOptions {
  27437. /** Specifies whether or not a stencil should be allocated in the texture */
  27438. generateStencil?: boolean;
  27439. /** Specifies whether or not bilinear filtering is enable on the texture */
  27440. bilinearFiltering?: boolean;
  27441. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27442. comparisonFunction?: number;
  27443. /** Specifies if the created texture is a cube texture */
  27444. isCube?: boolean;
  27445. }
  27446. /**
  27447. * Class used to describe the capabilities of the engine relatively to the current browser
  27448. */
  27449. export class EngineCapabilities {
  27450. /** Maximum textures units per fragment shader */
  27451. maxTexturesImageUnits: number;
  27452. /** Maximum texture units per vertex shader */
  27453. maxVertexTextureImageUnits: number;
  27454. /** Maximum textures units in the entire pipeline */
  27455. maxCombinedTexturesImageUnits: number;
  27456. /** Maximum texture size */
  27457. maxTextureSize: number;
  27458. /** Maximum cube texture size */
  27459. maxCubemapTextureSize: number;
  27460. /** Maximum render texture size */
  27461. maxRenderTextureSize: number;
  27462. /** Maximum number of vertex attributes */
  27463. maxVertexAttribs: number;
  27464. /** Maximum number of varyings */
  27465. maxVaryingVectors: number;
  27466. /** Maximum number of uniforms per vertex shader */
  27467. maxVertexUniformVectors: number;
  27468. /** Maximum number of uniforms per fragment shader */
  27469. maxFragmentUniformVectors: number;
  27470. /** Defines if standard derivates (dx/dy) are supported */
  27471. standardDerivatives: boolean;
  27472. /** Defines if s3tc texture compression is supported */
  27473. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27474. /** Defines if pvrtc texture compression is supported */
  27475. pvrtc: any;
  27476. /** Defines if etc1 texture compression is supported */
  27477. etc1: any;
  27478. /** Defines if etc2 texture compression is supported */
  27479. etc2: any;
  27480. /** Defines if astc texture compression is supported */
  27481. astc: any;
  27482. /** Defines if float textures are supported */
  27483. textureFloat: boolean;
  27484. /** Defines if vertex array objects are supported */
  27485. vertexArrayObject: boolean;
  27486. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27487. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27488. /** Gets the maximum level of anisotropy supported */
  27489. maxAnisotropy: number;
  27490. /** Defines if instancing is supported */
  27491. instancedArrays: boolean;
  27492. /** Defines if 32 bits indices are supported */
  27493. uintIndices: boolean;
  27494. /** Defines if high precision shaders are supported */
  27495. highPrecisionShaderSupported: boolean;
  27496. /** Defines if depth reading in the fragment shader is supported */
  27497. fragmentDepthSupported: boolean;
  27498. /** Defines if float texture linear filtering is supported*/
  27499. textureFloatLinearFiltering: boolean;
  27500. /** Defines if rendering to float textures is supported */
  27501. textureFloatRender: boolean;
  27502. /** Defines if half float textures are supported*/
  27503. textureHalfFloat: boolean;
  27504. /** Defines if half float texture linear filtering is supported*/
  27505. textureHalfFloatLinearFiltering: boolean;
  27506. /** Defines if rendering to half float textures is supported */
  27507. textureHalfFloatRender: boolean;
  27508. /** Defines if textureLOD shader command is supported */
  27509. textureLOD: boolean;
  27510. /** Defines if draw buffers extension is supported */
  27511. drawBuffersExtension: boolean;
  27512. /** Defines if depth textures are supported */
  27513. depthTextureExtension: boolean;
  27514. /** Defines if float color buffer are supported */
  27515. colorBufferFloat: boolean;
  27516. /** Gets disjoint timer query extension (null if not supported) */
  27517. timerQuery: EXT_disjoint_timer_query;
  27518. /** Defines if timestamp can be used with timer query */
  27519. canUseTimestampForTimerQuery: boolean;
  27520. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27521. multiview: any;
  27522. /** Function used to let the system compiles shaders in background */
  27523. parallelShaderCompile: {
  27524. COMPLETION_STATUS_KHR: number;
  27525. };
  27526. }
  27527. /** Interface defining initialization parameters for Engine class */
  27528. export interface EngineOptions extends WebGLContextAttributes {
  27529. /**
  27530. * Defines if the engine should no exceed a specified device ratio
  27531. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27532. */
  27533. limitDeviceRatio?: number;
  27534. /**
  27535. * Defines if webvr should be enabled automatically
  27536. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27537. */
  27538. autoEnableWebVR?: boolean;
  27539. /**
  27540. * Defines if webgl2 should be turned off even if supported
  27541. * @see http://doc.babylonjs.com/features/webgl2
  27542. */
  27543. disableWebGL2Support?: boolean;
  27544. /**
  27545. * Defines if webaudio should be initialized as well
  27546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27547. */
  27548. audioEngine?: boolean;
  27549. /**
  27550. * Defines if animations should run using a deterministic lock step
  27551. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27552. */
  27553. deterministicLockstep?: boolean;
  27554. /** Defines the maximum steps to use with deterministic lock step mode */
  27555. lockstepMaxSteps?: number;
  27556. /**
  27557. * Defines that engine should ignore context lost events
  27558. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27559. */
  27560. doNotHandleContextLost?: boolean;
  27561. /**
  27562. * Defines that engine should ignore modifying touch action attribute and style
  27563. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27564. */
  27565. doNotHandleTouchAction?: boolean;
  27566. /**
  27567. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27568. */
  27569. useHighPrecisionFloats?: boolean;
  27570. }
  27571. /**
  27572. * Defines the interface used by display changed events
  27573. */
  27574. export interface IDisplayChangedEventArgs {
  27575. /** Gets the vrDisplay object (if any) */
  27576. vrDisplay: Nullable<any>;
  27577. /** Gets a boolean indicating if webVR is supported */
  27578. vrSupported: boolean;
  27579. }
  27580. /**
  27581. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27582. */
  27583. export class Engine {
  27584. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27585. static ExceptionList: ({
  27586. key: string;
  27587. capture: string;
  27588. captureConstraint: number;
  27589. targets: string[];
  27590. } | {
  27591. key: string;
  27592. capture: null;
  27593. captureConstraint: null;
  27594. targets: string[];
  27595. })[];
  27596. /** Gets the list of created engines */
  27597. static readonly Instances: Engine[];
  27598. /**
  27599. * Gets the latest created engine
  27600. */
  27601. static readonly LastCreatedEngine: Nullable<Engine>;
  27602. /**
  27603. * Gets the latest created scene
  27604. */
  27605. static readonly LastCreatedScene: Nullable<Scene>;
  27606. /**
  27607. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27608. * @param flag defines which part of the materials must be marked as dirty
  27609. * @param predicate defines a predicate used to filter which materials should be affected
  27610. */
  27611. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27612. /**
  27613. * Hidden
  27614. */
  27615. static _TextureLoaders: IInternalTextureLoader[];
  27616. /** Defines that alpha blending is disabled */
  27617. static readonly ALPHA_DISABLE: number;
  27618. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27619. static readonly ALPHA_ADD: number;
  27620. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27621. static readonly ALPHA_COMBINE: number;
  27622. /** Defines that alpha blending to DEST - SRC * DEST */
  27623. static readonly ALPHA_SUBTRACT: number;
  27624. /** Defines that alpha blending to SRC * DEST */
  27625. static readonly ALPHA_MULTIPLY: number;
  27626. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27627. static readonly ALPHA_MAXIMIZED: number;
  27628. /** Defines that alpha blending to SRC + DEST */
  27629. static readonly ALPHA_ONEONE: number;
  27630. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27631. static readonly ALPHA_PREMULTIPLIED: number;
  27632. /**
  27633. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27634. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27635. */
  27636. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27637. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27638. static readonly ALPHA_INTERPOLATE: number;
  27639. /**
  27640. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27641. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27642. */
  27643. static readonly ALPHA_SCREENMODE: number;
  27644. /** Defines that the ressource is not delayed*/
  27645. static readonly DELAYLOADSTATE_NONE: number;
  27646. /** Defines that the ressource was successfully delay loaded */
  27647. static readonly DELAYLOADSTATE_LOADED: number;
  27648. /** Defines that the ressource is currently delay loading */
  27649. static readonly DELAYLOADSTATE_LOADING: number;
  27650. /** Defines that the ressource is delayed and has not started loading */
  27651. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27653. static readonly NEVER: number;
  27654. /** 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 */
  27655. static readonly ALWAYS: number;
  27656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27657. static readonly LESS: number;
  27658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27659. static readonly EQUAL: number;
  27660. /** 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 */
  27661. static readonly LEQUAL: number;
  27662. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27663. static readonly GREATER: number;
  27664. /** 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 */
  27665. static readonly GEQUAL: number;
  27666. /** 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 */
  27667. static readonly NOTEQUAL: number;
  27668. /** Passed to stencilOperation to specify that stencil value must be kept */
  27669. static readonly KEEP: number;
  27670. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27671. static readonly REPLACE: number;
  27672. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27673. static readonly INCR: number;
  27674. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27675. static readonly DECR: number;
  27676. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27677. static readonly INVERT: number;
  27678. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27679. static readonly INCR_WRAP: number;
  27680. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27681. static readonly DECR_WRAP: number;
  27682. /** Texture is not repeating outside of 0..1 UVs */
  27683. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27684. /** Texture is repeating outside of 0..1 UVs */
  27685. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27686. /** Texture is repeating and mirrored */
  27687. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27688. /** ALPHA */
  27689. static readonly TEXTUREFORMAT_ALPHA: number;
  27690. /** LUMINANCE */
  27691. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27692. /** LUMINANCE_ALPHA */
  27693. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27694. /** RGB */
  27695. static readonly TEXTUREFORMAT_RGB: number;
  27696. /** RGBA */
  27697. static readonly TEXTUREFORMAT_RGBA: number;
  27698. /** RED */
  27699. static readonly TEXTUREFORMAT_RED: number;
  27700. /** RED (2nd reference) */
  27701. static readonly TEXTUREFORMAT_R: number;
  27702. /** RG */
  27703. static readonly TEXTUREFORMAT_RG: number;
  27704. /** RED_INTEGER */
  27705. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27706. /** RED_INTEGER (2nd reference) */
  27707. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27708. /** RG_INTEGER */
  27709. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27710. /** RGB_INTEGER */
  27711. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27712. /** RGBA_INTEGER */
  27713. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27714. /** UNSIGNED_BYTE */
  27715. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27716. /** UNSIGNED_BYTE (2nd reference) */
  27717. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27718. /** FLOAT */
  27719. static readonly TEXTURETYPE_FLOAT: number;
  27720. /** HALF_FLOAT */
  27721. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27722. /** BYTE */
  27723. static readonly TEXTURETYPE_BYTE: number;
  27724. /** SHORT */
  27725. static readonly TEXTURETYPE_SHORT: number;
  27726. /** UNSIGNED_SHORT */
  27727. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27728. /** INT */
  27729. static readonly TEXTURETYPE_INT: number;
  27730. /** UNSIGNED_INT */
  27731. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27732. /** UNSIGNED_SHORT_4_4_4_4 */
  27733. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27734. /** UNSIGNED_SHORT_5_5_5_1 */
  27735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27736. /** UNSIGNED_SHORT_5_6_5 */
  27737. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27738. /** UNSIGNED_INT_2_10_10_10_REV */
  27739. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27740. /** UNSIGNED_INT_24_8 */
  27741. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27742. /** UNSIGNED_INT_10F_11F_11F_REV */
  27743. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27744. /** UNSIGNED_INT_5_9_9_9_REV */
  27745. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27746. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27747. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27748. /** nearest is mag = nearest and min = nearest and mip = linear */
  27749. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27751. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27752. /** Trilinear is mag = linear and min = linear and mip = linear */
  27753. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27754. /** nearest is mag = nearest and min = nearest and mip = linear */
  27755. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27757. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27758. /** Trilinear is mag = linear and min = linear and mip = linear */
  27759. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27760. /** mag = nearest and min = nearest and mip = nearest */
  27761. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27762. /** mag = nearest and min = linear and mip = nearest */
  27763. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27764. /** mag = nearest and min = linear and mip = linear */
  27765. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27766. /** mag = nearest and min = linear and mip = none */
  27767. static readonly TEXTURE_NEAREST_LINEAR: number;
  27768. /** mag = nearest and min = nearest and mip = none */
  27769. static readonly TEXTURE_NEAREST_NEAREST: number;
  27770. /** mag = linear and min = nearest and mip = nearest */
  27771. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27772. /** mag = linear and min = nearest and mip = linear */
  27773. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27774. /** mag = linear and min = linear and mip = none */
  27775. static readonly TEXTURE_LINEAR_LINEAR: number;
  27776. /** mag = linear and min = nearest and mip = none */
  27777. static readonly TEXTURE_LINEAR_NEAREST: number;
  27778. /** Explicit coordinates mode */
  27779. static readonly TEXTURE_EXPLICIT_MODE: number;
  27780. /** Spherical coordinates mode */
  27781. static readonly TEXTURE_SPHERICAL_MODE: number;
  27782. /** Planar coordinates mode */
  27783. static readonly TEXTURE_PLANAR_MODE: number;
  27784. /** Cubic coordinates mode */
  27785. static readonly TEXTURE_CUBIC_MODE: number;
  27786. /** Projection coordinates mode */
  27787. static readonly TEXTURE_PROJECTION_MODE: number;
  27788. /** Skybox coordinates mode */
  27789. static readonly TEXTURE_SKYBOX_MODE: number;
  27790. /** Inverse Cubic coordinates mode */
  27791. static readonly TEXTURE_INVCUBIC_MODE: number;
  27792. /** Equirectangular coordinates mode */
  27793. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27794. /** Equirectangular Fixed coordinates mode */
  27795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27796. /** Equirectangular Fixed Mirrored coordinates mode */
  27797. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27798. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27799. static readonly SCALEMODE_FLOOR: number;
  27800. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27801. static readonly SCALEMODE_NEAREST: number;
  27802. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27803. static readonly SCALEMODE_CEILING: number;
  27804. /**
  27805. * Returns the current npm package of the sdk
  27806. */
  27807. static readonly NpmPackage: string;
  27808. /**
  27809. * Returns the current version of the framework
  27810. */
  27811. static readonly Version: string;
  27812. /**
  27813. * Returns a string describing the current engine
  27814. */
  27815. readonly description: string;
  27816. /**
  27817. * Gets or sets the epsilon value used by collision engine
  27818. */
  27819. static CollisionsEpsilon: number;
  27820. /**
  27821. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27822. */
  27823. static ShadersRepository: string;
  27824. /**
  27825. * Method called to create the default loading screen.
  27826. * This can be overriden in your own app.
  27827. * @param canvas The rendering canvas element
  27828. * @returns The loading screen
  27829. */
  27830. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27831. /**
  27832. * Method called to create the default rescale post process on each engine.
  27833. */
  27834. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27835. /**
  27836. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27837. */
  27838. forcePOTTextures: boolean;
  27839. /**
  27840. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27841. */
  27842. isFullscreen: boolean;
  27843. /**
  27844. * Gets a boolean indicating if the pointer is currently locked
  27845. */
  27846. isPointerLock: boolean;
  27847. /**
  27848. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27849. */
  27850. cullBackFaces: boolean;
  27851. /**
  27852. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27853. */
  27854. renderEvenInBackground: boolean;
  27855. /**
  27856. * Gets or sets a boolean indicating that cache can be kept between frames
  27857. */
  27858. preventCacheWipeBetweenFrames: boolean;
  27859. /**
  27860. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27861. **/
  27862. enableOfflineSupport: boolean;
  27863. /**
  27864. * 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)
  27865. **/
  27866. disableManifestCheck: boolean;
  27867. /**
  27868. * Gets the list of created scenes
  27869. */
  27870. scenes: Scene[];
  27871. /**
  27872. * Event raised when a new scene is created
  27873. */
  27874. onNewSceneAddedObservable: Observable<Scene>;
  27875. /**
  27876. * Gets the list of created postprocesses
  27877. */
  27878. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27879. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27880. validateShaderPrograms: boolean;
  27881. /**
  27882. * Observable event triggered each time the rendering canvas is resized
  27883. */
  27884. onResizeObservable: Observable<Engine>;
  27885. /**
  27886. * Observable event triggered each time the canvas loses focus
  27887. */
  27888. onCanvasBlurObservable: Observable<Engine>;
  27889. /**
  27890. * Observable event triggered each time the canvas gains focus
  27891. */
  27892. onCanvasFocusObservable: Observable<Engine>;
  27893. /**
  27894. * Observable event triggered each time the canvas receives pointerout event
  27895. */
  27896. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27897. /**
  27898. * Observable event triggered before each texture is initialized
  27899. */
  27900. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27901. private _vrDisplay;
  27902. private _vrSupported;
  27903. private _oldSize;
  27904. private _oldHardwareScaleFactor;
  27905. private _vrExclusivePointerMode;
  27906. private _webVRInitPromise;
  27907. /**
  27908. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27909. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27910. */
  27911. readonly isInVRExclusivePointerMode: boolean;
  27912. /**
  27913. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27914. */
  27915. disableUniformBuffers: boolean;
  27916. /** @hidden */
  27917. _uniformBuffers: UniformBuffer[];
  27918. /**
  27919. * Gets a boolean indicating that the engine supports uniform buffers
  27920. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27921. */
  27922. readonly supportsUniformBuffers: boolean;
  27923. /**
  27924. * Observable raised when the engine begins a new frame
  27925. */
  27926. onBeginFrameObservable: Observable<Engine>;
  27927. /**
  27928. * If set, will be used to request the next animation frame for the render loop
  27929. */
  27930. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27931. /**
  27932. * Observable raised when the engine ends the current frame
  27933. */
  27934. onEndFrameObservable: Observable<Engine>;
  27935. /**
  27936. * Observable raised when the engine is about to compile a shader
  27937. */
  27938. onBeforeShaderCompilationObservable: Observable<Engine>;
  27939. /**
  27940. * Observable raised when the engine has jsut compiled a shader
  27941. */
  27942. onAfterShaderCompilationObservable: Observable<Engine>;
  27943. /** @hidden */
  27944. _gl: WebGLRenderingContext;
  27945. private _renderingCanvas;
  27946. private _windowIsBackground;
  27947. private _webGLVersion;
  27948. protected _highPrecisionShadersAllowed: boolean;
  27949. /** @hidden */
  27950. readonly _shouldUseHighPrecisionShader: boolean;
  27951. /**
  27952. * Gets a boolean indicating that only power of 2 textures are supported
  27953. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27954. */
  27955. readonly needPOTTextures: boolean;
  27956. /** @hidden */
  27957. _badOS: boolean;
  27958. /** @hidden */
  27959. _badDesktopOS: boolean;
  27960. /**
  27961. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27962. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27963. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27964. */
  27965. disableTextureBindingOptimization: boolean;
  27966. /**
  27967. * Gets the audio engine
  27968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27969. * @ignorenaming
  27970. */
  27971. static audioEngine: IAudioEngine;
  27972. /**
  27973. * Default AudioEngine factory responsible of creating the Audio Engine.
  27974. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27975. */
  27976. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27977. /**
  27978. * Default offline support factory responsible of creating a tool used to store data locally.
  27979. * By default, this will create a Database object if the workload has been embedded.
  27980. */
  27981. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27982. private _onFocus;
  27983. private _onBlur;
  27984. private _onCanvasPointerOut;
  27985. private _onCanvasBlur;
  27986. private _onCanvasFocus;
  27987. private _onFullscreenChange;
  27988. private _onPointerLockChange;
  27989. private _onVRDisplayPointerRestricted;
  27990. private _onVRDisplayPointerUnrestricted;
  27991. private _onVrDisplayConnect;
  27992. private _onVrDisplayDisconnect;
  27993. private _onVrDisplayPresentChange;
  27994. /**
  27995. * Observable signaled when VR display mode changes
  27996. */
  27997. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27998. /**
  27999. * Observable signaled when VR request present is complete
  28000. */
  28001. onVRRequestPresentComplete: Observable<boolean>;
  28002. /**
  28003. * Observable signaled when VR request present starts
  28004. */
  28005. onVRRequestPresentStart: Observable<Engine>;
  28006. private _hardwareScalingLevel;
  28007. /** @hidden */
  28008. protected _caps: EngineCapabilities;
  28009. private _pointerLockRequested;
  28010. private _isStencilEnable;
  28011. private _colorWrite;
  28012. private _loadingScreen;
  28013. /** @hidden */
  28014. _drawCalls: PerfCounter;
  28015. /** @hidden */
  28016. _textureCollisions: PerfCounter;
  28017. private _glVersion;
  28018. private _glRenderer;
  28019. private _glVendor;
  28020. private _videoTextureSupported;
  28021. private _renderingQueueLaunched;
  28022. private _activeRenderLoops;
  28023. private _deterministicLockstep;
  28024. private _lockstepMaxSteps;
  28025. /**
  28026. * Observable signaled when a context lost event is raised
  28027. */
  28028. onContextLostObservable: Observable<Engine>;
  28029. /**
  28030. * Observable signaled when a context restored event is raised
  28031. */
  28032. onContextRestoredObservable: Observable<Engine>;
  28033. private _onContextLost;
  28034. private _onContextRestored;
  28035. private _contextWasLost;
  28036. private _doNotHandleContextLost;
  28037. /**
  28038. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28040. */
  28041. doNotHandleContextLost: boolean;
  28042. private _performanceMonitor;
  28043. private _fps;
  28044. private _deltaTime;
  28045. /**
  28046. * Turn this value on if you want to pause FPS computation when in background
  28047. */
  28048. disablePerformanceMonitorInBackground: boolean;
  28049. /**
  28050. * Gets the performance monitor attached to this engine
  28051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28052. */
  28053. readonly performanceMonitor: PerformanceMonitor;
  28054. /**
  28055. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28056. */
  28057. disableVertexArrayObjects: boolean;
  28058. /** @hidden */
  28059. protected _depthCullingState: _DepthCullingState;
  28060. /** @hidden */
  28061. protected _stencilState: _StencilState;
  28062. /** @hidden */
  28063. protected _alphaState: _AlphaState;
  28064. /** @hidden */
  28065. protected _alphaMode: number;
  28066. protected _internalTexturesCache: InternalTexture[];
  28067. /** @hidden */
  28068. protected _activeChannel: number;
  28069. private _currentTextureChannel;
  28070. /** @hidden */
  28071. protected _boundTexturesCache: {
  28072. [key: string]: Nullable<InternalTexture>;
  28073. };
  28074. /** @hidden */
  28075. protected _currentEffect: Nullable<Effect>;
  28076. /** @hidden */
  28077. protected _currentProgram: Nullable<WebGLProgram>;
  28078. private _compiledEffects;
  28079. private _vertexAttribArraysEnabled;
  28080. /** @hidden */
  28081. protected _cachedViewport: Nullable<Viewport>;
  28082. private _cachedVertexArrayObject;
  28083. /** @hidden */
  28084. protected _cachedVertexBuffers: any;
  28085. /** @hidden */
  28086. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28087. /** @hidden */
  28088. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28089. /** @hidden */
  28090. protected _currentRenderTarget: Nullable<InternalTexture>;
  28091. private _uintIndicesCurrentlySet;
  28092. private _currentBoundBuffer;
  28093. /** @hidden */
  28094. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28095. private _currentBufferPointers;
  28096. private _currentInstanceLocations;
  28097. private _currentInstanceBuffers;
  28098. private _textureUnits;
  28099. private _firstBoundInternalTextureTracker;
  28100. private _lastBoundInternalTextureTracker;
  28101. private _workingCanvas;
  28102. private _workingContext;
  28103. private _rescalePostProcess;
  28104. private _dummyFramebuffer;
  28105. private _externalData;
  28106. private _bindedRenderFunction;
  28107. private _vaoRecordInProgress;
  28108. private _mustWipeVertexAttributes;
  28109. private _emptyTexture;
  28110. private _emptyCubeTexture;
  28111. private _emptyTexture3D;
  28112. /** @hidden */
  28113. _frameHandler: number;
  28114. private _nextFreeTextureSlots;
  28115. private _maxSimultaneousTextures;
  28116. private _activeRequests;
  28117. private _texturesSupported;
  28118. private _textureFormatInUse;
  28119. /**
  28120. * Gets the list of texture formats supported
  28121. */
  28122. readonly texturesSupported: Array<string>;
  28123. /**
  28124. * Gets the list of texture formats in use
  28125. */
  28126. readonly textureFormatInUse: Nullable<string>;
  28127. /**
  28128. * Gets the current viewport
  28129. */
  28130. readonly currentViewport: Nullable<Viewport>;
  28131. /**
  28132. * Gets the default empty texture
  28133. */
  28134. readonly emptyTexture: InternalTexture;
  28135. /**
  28136. * Gets the default empty 3D texture
  28137. */
  28138. readonly emptyTexture3D: InternalTexture;
  28139. /**
  28140. * Gets the default empty cube texture
  28141. */
  28142. readonly emptyCubeTexture: InternalTexture;
  28143. /**
  28144. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28145. */
  28146. readonly premultipliedAlpha: boolean;
  28147. /**
  28148. * Creates a new engine
  28149. * @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
  28150. * @param antialias defines enable antialiasing (default: false)
  28151. * @param options defines further options to be sent to the getContext() function
  28152. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28153. */
  28154. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28155. private _disableTouchAction;
  28156. private _rebuildInternalTextures;
  28157. private _rebuildEffects;
  28158. /**
  28159. * Gets a boolean indicating if all created effects are ready
  28160. * @returns true if all effects are ready
  28161. */
  28162. areAllEffectsReady(): boolean;
  28163. private _rebuildBuffers;
  28164. private _initGLContext;
  28165. /**
  28166. * Gets version of the current webGL context
  28167. */
  28168. readonly webGLVersion: number;
  28169. /**
  28170. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28171. */
  28172. readonly isStencilEnable: boolean;
  28173. private _prepareWorkingCanvas;
  28174. /**
  28175. * Reset the texture cache to empty state
  28176. */
  28177. resetTextureCache(): void;
  28178. /**
  28179. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28181. * @returns true if engine is in deterministic lock step mode
  28182. */
  28183. isDeterministicLockStep(): boolean;
  28184. /**
  28185. * Gets the max steps when engine is running in deterministic lock step
  28186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28187. * @returns the max steps
  28188. */
  28189. getLockstepMaxSteps(): number;
  28190. /**
  28191. * Gets an object containing information about the current webGL context
  28192. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28193. */
  28194. getGlInfo(): {
  28195. vendor: string;
  28196. renderer: string;
  28197. version: string;
  28198. };
  28199. /**
  28200. * Gets current aspect ratio
  28201. * @param camera defines the camera to use to get the aspect ratio
  28202. * @param useScreen defines if screen size must be used (or the current render target if any)
  28203. * @returns a number defining the aspect ratio
  28204. */
  28205. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28206. /**
  28207. * Gets current screen aspect ratio
  28208. * @returns a number defining the aspect ratio
  28209. */
  28210. getScreenAspectRatio(): number;
  28211. /**
  28212. * Gets the current render width
  28213. * @param useScreen defines if screen size must be used (or the current render target if any)
  28214. * @returns a number defining the current render width
  28215. */
  28216. getRenderWidth(useScreen?: boolean): number;
  28217. /**
  28218. * Gets the current render height
  28219. * @param useScreen defines if screen size must be used (or the current render target if any)
  28220. * @returns a number defining the current render height
  28221. */
  28222. getRenderHeight(useScreen?: boolean): number;
  28223. /**
  28224. * Gets the HTML canvas attached with the current webGL context
  28225. * @returns a HTML canvas
  28226. */
  28227. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28228. /**
  28229. * Gets the client rect of the HTML canvas attached with the current webGL context
  28230. * @returns a client rectanglee
  28231. */
  28232. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28233. /**
  28234. * Defines the hardware scaling level.
  28235. * By default the hardware scaling level is computed from the window device ratio.
  28236. * 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.
  28237. * @param level defines the level to use
  28238. */
  28239. setHardwareScalingLevel(level: number): void;
  28240. /**
  28241. * Gets the current hardware scaling level.
  28242. * By default the hardware scaling level is computed from the window device ratio.
  28243. * 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.
  28244. * @returns a number indicating the current hardware scaling level
  28245. */
  28246. getHardwareScalingLevel(): number;
  28247. /**
  28248. * Gets the list of loaded textures
  28249. * @returns an array containing all loaded textures
  28250. */
  28251. getLoadedTexturesCache(): InternalTexture[];
  28252. /**
  28253. * Gets the object containing all engine capabilities
  28254. * @returns the EngineCapabilities object
  28255. */
  28256. getCaps(): EngineCapabilities;
  28257. /**
  28258. * Gets the current depth function
  28259. * @returns a number defining the depth function
  28260. */
  28261. getDepthFunction(): Nullable<number>;
  28262. /**
  28263. * Sets the current depth function
  28264. * @param depthFunc defines the function to use
  28265. */
  28266. setDepthFunction(depthFunc: number): void;
  28267. /**
  28268. * Sets the current depth function to GREATER
  28269. */
  28270. setDepthFunctionToGreater(): void;
  28271. /**
  28272. * Sets the current depth function to GEQUAL
  28273. */
  28274. setDepthFunctionToGreaterOrEqual(): void;
  28275. /**
  28276. * Sets the current depth function to LESS
  28277. */
  28278. setDepthFunctionToLess(): void;
  28279. private _cachedStencilBuffer;
  28280. private _cachedStencilFunction;
  28281. private _cachedStencilMask;
  28282. private _cachedStencilOperationPass;
  28283. private _cachedStencilOperationFail;
  28284. private _cachedStencilOperationDepthFail;
  28285. private _cachedStencilReference;
  28286. /**
  28287. * Caches the the state of the stencil buffer
  28288. */
  28289. cacheStencilState(): void;
  28290. /**
  28291. * Restores the state of the stencil buffer
  28292. */
  28293. restoreStencilState(): void;
  28294. /**
  28295. * Sets the current depth function to LEQUAL
  28296. */
  28297. setDepthFunctionToLessOrEqual(): void;
  28298. /**
  28299. * Gets a boolean indicating if stencil buffer is enabled
  28300. * @returns the current stencil buffer state
  28301. */
  28302. getStencilBuffer(): boolean;
  28303. /**
  28304. * Enable or disable the stencil buffer
  28305. * @param enable defines if the stencil buffer must be enabled or disabled
  28306. */
  28307. setStencilBuffer(enable: boolean): void;
  28308. /**
  28309. * Gets the current stencil mask
  28310. * @returns a number defining the new stencil mask to use
  28311. */
  28312. getStencilMask(): number;
  28313. /**
  28314. * Sets the current stencil mask
  28315. * @param mask defines the new stencil mask to use
  28316. */
  28317. setStencilMask(mask: number): void;
  28318. /**
  28319. * Gets the current stencil function
  28320. * @returns a number defining the stencil function to use
  28321. */
  28322. getStencilFunction(): number;
  28323. /**
  28324. * Gets the current stencil reference value
  28325. * @returns a number defining the stencil reference value to use
  28326. */
  28327. getStencilFunctionReference(): number;
  28328. /**
  28329. * Gets the current stencil mask
  28330. * @returns a number defining the stencil mask to use
  28331. */
  28332. getStencilFunctionMask(): number;
  28333. /**
  28334. * Sets the current stencil function
  28335. * @param stencilFunc defines the new stencil function to use
  28336. */
  28337. setStencilFunction(stencilFunc: number): void;
  28338. /**
  28339. * Sets the current stencil reference
  28340. * @param reference defines the new stencil reference to use
  28341. */
  28342. setStencilFunctionReference(reference: number): void;
  28343. /**
  28344. * Sets the current stencil mask
  28345. * @param mask defines the new stencil mask to use
  28346. */
  28347. setStencilFunctionMask(mask: number): void;
  28348. /**
  28349. * Gets the current stencil operation when stencil fails
  28350. * @returns a number defining stencil operation to use when stencil fails
  28351. */
  28352. getStencilOperationFail(): number;
  28353. /**
  28354. * Gets the current stencil operation when depth fails
  28355. * @returns a number defining stencil operation to use when depth fails
  28356. */
  28357. getStencilOperationDepthFail(): number;
  28358. /**
  28359. * Gets the current stencil operation when stencil passes
  28360. * @returns a number defining stencil operation to use when stencil passes
  28361. */
  28362. getStencilOperationPass(): number;
  28363. /**
  28364. * Sets the stencil operation to use when stencil fails
  28365. * @param operation defines the stencil operation to use when stencil fails
  28366. */
  28367. setStencilOperationFail(operation: number): void;
  28368. /**
  28369. * Sets the stencil operation to use when depth fails
  28370. * @param operation defines the stencil operation to use when depth fails
  28371. */
  28372. setStencilOperationDepthFail(operation: number): void;
  28373. /**
  28374. * Sets the stencil operation to use when stencil passes
  28375. * @param operation defines the stencil operation to use when stencil passes
  28376. */
  28377. setStencilOperationPass(operation: number): void;
  28378. /**
  28379. * Sets a boolean indicating if the dithering state is enabled or disabled
  28380. * @param value defines the dithering state
  28381. */
  28382. setDitheringState(value: boolean): void;
  28383. /**
  28384. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28385. * @param value defines the rasterizer state
  28386. */
  28387. setRasterizerState(value: boolean): void;
  28388. /**
  28389. * stop executing a render loop function and remove it from the execution array
  28390. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28391. */
  28392. stopRenderLoop(renderFunction?: () => void): void;
  28393. /** @hidden */
  28394. _renderLoop(): void;
  28395. /**
  28396. * Register and execute a render loop. The engine can have more than one render function
  28397. * @param renderFunction defines the function to continuously execute
  28398. */
  28399. runRenderLoop(renderFunction: () => void): void;
  28400. /**
  28401. * Toggle full screen mode
  28402. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28403. */
  28404. switchFullscreen(requestPointerLock: boolean): void;
  28405. /**
  28406. * Enters full screen mode
  28407. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28408. */
  28409. enterFullscreen(requestPointerLock: boolean): void;
  28410. /**
  28411. * Exits full screen mode
  28412. */
  28413. exitFullscreen(): void;
  28414. /**
  28415. * Clear the current render buffer or the current render target (if any is set up)
  28416. * @param color defines the color to use
  28417. * @param backBuffer defines if the back buffer must be cleared
  28418. * @param depth defines if the depth buffer must be cleared
  28419. * @param stencil defines if the stencil buffer must be cleared
  28420. */
  28421. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28422. /**
  28423. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28424. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28425. * @param y defines the y-coordinate of the corner of the clear rectangle
  28426. * @param width defines the width of the clear rectangle
  28427. * @param height defines the height of the clear rectangle
  28428. * @param clearColor defines the clear color
  28429. */
  28430. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28431. /**
  28432. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28433. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28434. * @param y defines the y-coordinate of the corner of the clear rectangle
  28435. * @param width defines the width of the clear rectangle
  28436. * @param height defines the height of the clear rectangle
  28437. */
  28438. enableScissor(x: number, y: number, width: number, height: number): void;
  28439. /**
  28440. * Disable previously set scissor test rectangle
  28441. */
  28442. disableScissor(): void;
  28443. private _viewportCached;
  28444. /** @hidden */
  28445. _viewport(x: number, y: number, width: number, height: number): void;
  28446. /**
  28447. * Set the WebGL's viewport
  28448. * @param viewport defines the viewport element to be used
  28449. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28450. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28451. */
  28452. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28453. /**
  28454. * Directly set the WebGL Viewport
  28455. * @param x defines the x coordinate of the viewport (in screen space)
  28456. * @param y defines the y coordinate of the viewport (in screen space)
  28457. * @param width defines the width of the viewport (in screen space)
  28458. * @param height defines the height of the viewport (in screen space)
  28459. * @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
  28460. */
  28461. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28462. /**
  28463. * Begin a new frame
  28464. */
  28465. beginFrame(): void;
  28466. /**
  28467. * Enf the current frame
  28468. */
  28469. endFrame(): void;
  28470. /**
  28471. * Resize the view according to the canvas' size
  28472. */
  28473. resize(): void;
  28474. /**
  28475. * Force a specific size of the canvas
  28476. * @param width defines the new canvas' width
  28477. * @param height defines the new canvas' height
  28478. */
  28479. setSize(width: number, height: number): void;
  28480. /**
  28481. * Gets a boolean indicating if a webVR device was detected
  28482. * @returns true if a webVR device was detected
  28483. */
  28484. isVRDevicePresent(): boolean;
  28485. /**
  28486. * Gets the current webVR device
  28487. * @returns the current webVR device (or null)
  28488. */
  28489. getVRDevice(): any;
  28490. /**
  28491. * Initializes a webVR display and starts listening to display change events
  28492. * The onVRDisplayChangedObservable will be notified upon these changes
  28493. * @returns The onVRDisplayChangedObservable
  28494. */
  28495. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28496. /**
  28497. * Initializes a webVR display and starts listening to display change events
  28498. * The onVRDisplayChangedObservable will be notified upon these changes
  28499. * @returns A promise containing a VRDisplay and if vr is supported
  28500. */
  28501. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28502. /**
  28503. * Call this function to switch to webVR mode
  28504. * Will do nothing if webVR is not supported or if there is no webVR device
  28505. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28506. */
  28507. enableVR(): void;
  28508. /**
  28509. * Call this function to leave webVR mode
  28510. * Will do nothing if webVR is not supported or if there is no webVR device
  28511. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28512. */
  28513. disableVR(): void;
  28514. private _onVRFullScreenTriggered;
  28515. private _getVRDisplaysAsync;
  28516. /**
  28517. * Binds the frame buffer to the specified texture.
  28518. * @param texture The texture to render to or null for the default canvas
  28519. * @param faceIndex The face of the texture to render to in case of cube texture
  28520. * @param requiredWidth The width of the target to render to
  28521. * @param requiredHeight The height of the target to render to
  28522. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28523. * @param depthStencilTexture The depth stencil texture to use to render
  28524. * @param lodLevel defines le lod level to bind to the frame buffer
  28525. */
  28526. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28527. private bindUnboundFramebuffer;
  28528. /**
  28529. * Unbind the current render target texture from the webGL context
  28530. * @param texture defines the render target texture to unbind
  28531. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28532. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28533. */
  28534. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28535. /**
  28536. * Unbind a list of render target textures from the webGL context
  28537. * This is used only when drawBuffer extension or webGL2 are active
  28538. * @param textures defines the render target textures to unbind
  28539. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28540. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28541. */
  28542. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28543. /**
  28544. * Force the mipmap generation for the given render target texture
  28545. * @param texture defines the render target texture to use
  28546. */
  28547. generateMipMapsForCubemap(texture: InternalTexture): void;
  28548. /**
  28549. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28550. */
  28551. flushFramebuffer(): void;
  28552. /**
  28553. * Unbind the current render target and bind the default framebuffer
  28554. */
  28555. restoreDefaultFramebuffer(): void;
  28556. /**
  28557. * Create an uniform buffer
  28558. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28559. * @param elements defines the content of the uniform buffer
  28560. * @returns the webGL uniform buffer
  28561. */
  28562. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28563. /**
  28564. * Create a dynamic uniform buffer
  28565. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28566. * @param elements defines the content of the uniform buffer
  28567. * @returns the webGL uniform buffer
  28568. */
  28569. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28570. /**
  28571. * Update an existing uniform buffer
  28572. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28573. * @param uniformBuffer defines the target uniform buffer
  28574. * @param elements defines the content to update
  28575. * @param offset defines the offset in the uniform buffer where update should start
  28576. * @param count defines the size of the data to update
  28577. */
  28578. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28579. private _resetVertexBufferBinding;
  28580. /**
  28581. * Creates a vertex buffer
  28582. * @param data the data for the vertex buffer
  28583. * @returns the new WebGL static buffer
  28584. */
  28585. createVertexBuffer(data: DataArray): WebGLBuffer;
  28586. /**
  28587. * Creates a dynamic vertex buffer
  28588. * @param data the data for the dynamic vertex buffer
  28589. * @returns the new WebGL dynamic buffer
  28590. */
  28591. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28592. /**
  28593. * Update a dynamic index buffer
  28594. * @param indexBuffer defines the target index buffer
  28595. * @param indices defines the data to update
  28596. * @param offset defines the offset in the target index buffer where update should start
  28597. */
  28598. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28599. /**
  28600. * Updates a dynamic vertex buffer.
  28601. * @param vertexBuffer the vertex buffer to update
  28602. * @param data the data used to update the vertex buffer
  28603. * @param byteOffset the byte offset of the data
  28604. * @param byteLength the byte length of the data
  28605. */
  28606. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28607. private _resetIndexBufferBinding;
  28608. /**
  28609. * Creates a new index buffer
  28610. * @param indices defines the content of the index buffer
  28611. * @param updatable defines if the index buffer must be updatable
  28612. * @returns a new webGL buffer
  28613. */
  28614. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28615. /**
  28616. * Bind a webGL buffer to the webGL context
  28617. * @param buffer defines the buffer to bind
  28618. */
  28619. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28620. /**
  28621. * Bind an uniform buffer to the current webGL context
  28622. * @param buffer defines the buffer to bind
  28623. */
  28624. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28625. /**
  28626. * Bind a buffer to the current webGL context at a given location
  28627. * @param buffer defines the buffer to bind
  28628. * @param location defines the index where to bind the buffer
  28629. */
  28630. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28631. /**
  28632. * Bind a specific block at a given index in a specific shader program
  28633. * @param shaderProgram defines the shader program
  28634. * @param blockName defines the block name
  28635. * @param index defines the index where to bind the block
  28636. */
  28637. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28638. private bindIndexBuffer;
  28639. private bindBuffer;
  28640. /**
  28641. * update the bound buffer with the given data
  28642. * @param data defines the data to update
  28643. */
  28644. updateArrayBuffer(data: Float32Array): void;
  28645. private _vertexAttribPointer;
  28646. private _bindIndexBufferWithCache;
  28647. private _bindVertexBuffersAttributes;
  28648. /**
  28649. * Records a vertex array object
  28650. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28651. * @param vertexBuffers defines the list of vertex buffers to store
  28652. * @param indexBuffer defines the index buffer to store
  28653. * @param effect defines the effect to store
  28654. * @returns the new vertex array object
  28655. */
  28656. recordVertexArrayObject(vertexBuffers: {
  28657. [key: string]: VertexBuffer;
  28658. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28659. /**
  28660. * Bind a specific vertex array object
  28661. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28662. * @param vertexArrayObject defines the vertex array object to bind
  28663. * @param indexBuffer defines the index buffer to bind
  28664. */
  28665. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28666. /**
  28667. * Bind webGl buffers directly to the webGL context
  28668. * @param vertexBuffer defines the vertex buffer to bind
  28669. * @param indexBuffer defines the index buffer to bind
  28670. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28671. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28672. * @param effect defines the effect associated with the vertex buffer
  28673. */
  28674. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28675. private _unbindVertexArrayObject;
  28676. /**
  28677. * Bind a list of vertex buffers to the webGL context
  28678. * @param vertexBuffers defines the list of vertex buffers to bind
  28679. * @param indexBuffer defines the index buffer to bind
  28680. * @param effect defines the effect associated with the vertex buffers
  28681. */
  28682. bindBuffers(vertexBuffers: {
  28683. [key: string]: Nullable<VertexBuffer>;
  28684. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28685. /**
  28686. * Unbind all instance attributes
  28687. */
  28688. unbindInstanceAttributes(): void;
  28689. /**
  28690. * Release and free the memory of a vertex array object
  28691. * @param vao defines the vertex array object to delete
  28692. */
  28693. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28694. /** @hidden */
  28695. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28696. /**
  28697. * Creates a webGL buffer to use with instanciation
  28698. * @param capacity defines the size of the buffer
  28699. * @returns the webGL buffer
  28700. */
  28701. createInstancesBuffer(capacity: number): WebGLBuffer;
  28702. /**
  28703. * Delete a webGL buffer used with instanciation
  28704. * @param buffer defines the webGL buffer to delete
  28705. */
  28706. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28707. /**
  28708. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28709. * @param instancesBuffer defines the webGL buffer to update and bind
  28710. * @param data defines the data to store in the buffer
  28711. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28712. */
  28713. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28714. /**
  28715. * Apply all cached states (depth, culling, stencil and alpha)
  28716. */
  28717. applyStates(): void;
  28718. /**
  28719. * Send a draw order
  28720. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28721. * @param indexStart defines the starting index
  28722. * @param indexCount defines the number of index to draw
  28723. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28724. */
  28725. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28726. /**
  28727. * Draw a list of points
  28728. * @param verticesStart defines the index of first vertex to draw
  28729. * @param verticesCount defines the count of vertices to draw
  28730. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28731. */
  28732. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28733. /**
  28734. * Draw a list of unindexed primitives
  28735. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28736. * @param verticesStart defines the index of first vertex to draw
  28737. * @param verticesCount defines the count of vertices to draw
  28738. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28739. */
  28740. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28741. /**
  28742. * Draw a list of indexed primitives
  28743. * @param fillMode defines the primitive to use
  28744. * @param indexStart defines the starting index
  28745. * @param indexCount defines the number of index to draw
  28746. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28747. */
  28748. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28749. /**
  28750. * Draw a list of unindexed primitives
  28751. * @param fillMode defines the primitive to use
  28752. * @param verticesStart defines the index of first vertex to draw
  28753. * @param verticesCount defines the count of vertices to draw
  28754. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28755. */
  28756. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28757. private _drawMode;
  28758. /** @hidden */
  28759. _releaseEffect(effect: Effect): void;
  28760. /** @hidden */
  28761. _deleteProgram(program: WebGLProgram): void;
  28762. /**
  28763. * Create a new effect (used to store vertex/fragment shaders)
  28764. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28765. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28766. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28767. * @param samplers defines an array of string used to represent textures
  28768. * @param defines defines the string containing the defines to use to compile the shaders
  28769. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28770. * @param onCompiled defines a function to call when the effect creation is successful
  28771. * @param onError defines a function to call when the effect creation has failed
  28772. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28773. * @returns the new Effect
  28774. */
  28775. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28776. private _compileShader;
  28777. private _compileRawShader;
  28778. /**
  28779. * Directly creates a webGL program
  28780. * @param vertexCode defines the vertex shader code to use
  28781. * @param fragmentCode defines the fragment shader code to use
  28782. * @param context defines the webGL context to use (if not set, the current one will be used)
  28783. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28784. * @returns the new webGL program
  28785. */
  28786. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28787. /**
  28788. * Creates a webGL program
  28789. * @param vertexCode defines the vertex shader code to use
  28790. * @param fragmentCode defines the fragment shader code to use
  28791. * @param defines defines the string containing the defines to use to compile the shaders
  28792. * @param context defines the webGL context to use (if not set, the current one will be used)
  28793. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28794. * @returns the new webGL program
  28795. */
  28796. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28797. private _createShaderProgram;
  28798. private _finalizeProgram;
  28799. /** @hidden */
  28800. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28801. /** @hidden */
  28802. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28803. /**
  28804. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28805. * @param shaderProgram defines the webGL program to use
  28806. * @param uniformsNames defines the list of uniform names
  28807. * @returns an array of webGL uniform locations
  28808. */
  28809. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28810. /**
  28811. * Gets the lsit of active attributes for a given webGL program
  28812. * @param shaderProgram defines the webGL program to use
  28813. * @param attributesNames defines the list of attribute names to get
  28814. * @returns an array of indices indicating the offset of each attribute
  28815. */
  28816. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28817. /**
  28818. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28819. * @param effect defines the effect to activate
  28820. */
  28821. enableEffect(effect: Nullable<Effect>): void;
  28822. /**
  28823. * Set the value of an uniform to an array of int32
  28824. * @param uniform defines the webGL uniform location where to store the value
  28825. * @param array defines the array of int32 to store
  28826. */
  28827. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28828. /**
  28829. * Set the value of an uniform to an array of int32 (stored as vec2)
  28830. * @param uniform defines the webGL uniform location where to store the value
  28831. * @param array defines the array of int32 to store
  28832. */
  28833. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28834. /**
  28835. * Set the value of an uniform to an array of int32 (stored as vec3)
  28836. * @param uniform defines the webGL uniform location where to store the value
  28837. * @param array defines the array of int32 to store
  28838. */
  28839. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28840. /**
  28841. * Set the value of an uniform to an array of int32 (stored as vec4)
  28842. * @param uniform defines the webGL uniform location where to store the value
  28843. * @param array defines the array of int32 to store
  28844. */
  28845. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28846. /**
  28847. * Set the value of an uniform to an array of float32
  28848. * @param uniform defines the webGL uniform location where to store the value
  28849. * @param array defines the array of float32 to store
  28850. */
  28851. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28852. /**
  28853. * Set the value of an uniform to an array of float32 (stored as vec2)
  28854. * @param uniform defines the webGL uniform location where to store the value
  28855. * @param array defines the array of float32 to store
  28856. */
  28857. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28858. /**
  28859. * Set the value of an uniform to an array of float32 (stored as vec3)
  28860. * @param uniform defines the webGL uniform location where to store the value
  28861. * @param array defines the array of float32 to store
  28862. */
  28863. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28864. /**
  28865. * Set the value of an uniform to an array of float32 (stored as vec4)
  28866. * @param uniform defines the webGL uniform location where to store the value
  28867. * @param array defines the array of float32 to store
  28868. */
  28869. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28870. /**
  28871. * Set the value of an uniform to an array of number
  28872. * @param uniform defines the webGL uniform location where to store the value
  28873. * @param array defines the array of number to store
  28874. */
  28875. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28876. /**
  28877. * Set the value of an uniform to an array of number (stored as vec2)
  28878. * @param uniform defines the webGL uniform location where to store the value
  28879. * @param array defines the array of number to store
  28880. */
  28881. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28882. /**
  28883. * Set the value of an uniform to an array of number (stored as vec3)
  28884. * @param uniform defines the webGL uniform location where to store the value
  28885. * @param array defines the array of number to store
  28886. */
  28887. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28888. /**
  28889. * Set the value of an uniform to an array of number (stored as vec4)
  28890. * @param uniform defines the webGL uniform location where to store the value
  28891. * @param array defines the array of number to store
  28892. */
  28893. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28894. /**
  28895. * Set the value of an uniform to an array of float32 (stored as matrices)
  28896. * @param uniform defines the webGL uniform location where to store the value
  28897. * @param matrices defines the array of float32 to store
  28898. */
  28899. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28900. /**
  28901. * Set the value of an uniform to a matrix
  28902. * @param uniform defines the webGL uniform location where to store the value
  28903. * @param matrix defines the matrix to store
  28904. */
  28905. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28906. /**
  28907. * Set the value of an uniform to a matrix (3x3)
  28908. * @param uniform defines the webGL uniform location where to store the value
  28909. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28910. */
  28911. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28912. /**
  28913. * Set the value of an uniform to a matrix (2x2)
  28914. * @param uniform defines the webGL uniform location where to store the value
  28915. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28916. */
  28917. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28918. /**
  28919. * Set the value of an uniform to a number (int)
  28920. * @param uniform defines the webGL uniform location where to store the value
  28921. * @param value defines the int number to store
  28922. */
  28923. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28924. /**
  28925. * Set the value of an uniform to a number (float)
  28926. * @param uniform defines the webGL uniform location where to store the value
  28927. * @param value defines the float number to store
  28928. */
  28929. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28930. /**
  28931. * Set the value of an uniform to a vec2
  28932. * @param uniform defines the webGL uniform location where to store the value
  28933. * @param x defines the 1st component of the value
  28934. * @param y defines the 2nd component of the value
  28935. */
  28936. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28937. /**
  28938. * Set the value of an uniform to a vec3
  28939. * @param uniform defines the webGL uniform location where to store the value
  28940. * @param x defines the 1st component of the value
  28941. * @param y defines the 2nd component of the value
  28942. * @param z defines the 3rd component of the value
  28943. */
  28944. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28945. /**
  28946. * Set the value of an uniform to a boolean
  28947. * @param uniform defines the webGL uniform location where to store the value
  28948. * @param bool defines the boolean to store
  28949. */
  28950. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28951. /**
  28952. * Set the value of an uniform to a vec4
  28953. * @param uniform defines the webGL uniform location where to store the value
  28954. * @param x defines the 1st component of the value
  28955. * @param y defines the 2nd component of the value
  28956. * @param z defines the 3rd component of the value
  28957. * @param w defines the 4th component of the value
  28958. */
  28959. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28960. /**
  28961. * Set the value of an uniform to a Color3
  28962. * @param uniform defines the webGL uniform location where to store the value
  28963. * @param color3 defines the color to store
  28964. */
  28965. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28966. /**
  28967. * Set the value of an uniform to a Color3 and an alpha value
  28968. * @param uniform defines the webGL uniform location where to store the value
  28969. * @param color3 defines the color to store
  28970. * @param alpha defines the alpha component to store
  28971. */
  28972. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28973. /**
  28974. * Sets a Color4 on a uniform variable
  28975. * @param uniform defines the uniform location
  28976. * @param color4 defines the value to be set
  28977. */
  28978. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28979. /**
  28980. * Set various states to the webGL context
  28981. * @param culling defines backface culling state
  28982. * @param zOffset defines the value to apply to zOffset (0 by default)
  28983. * @param force defines if states must be applied even if cache is up to date
  28984. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28985. */
  28986. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28987. /**
  28988. * Set the z offset to apply to current rendering
  28989. * @param value defines the offset to apply
  28990. */
  28991. setZOffset(value: number): void;
  28992. /**
  28993. * Gets the current value of the zOffset
  28994. * @returns the current zOffset state
  28995. */
  28996. getZOffset(): number;
  28997. /**
  28998. * Enable or disable depth buffering
  28999. * @param enable defines the state to set
  29000. */
  29001. setDepthBuffer(enable: boolean): void;
  29002. /**
  29003. * Gets a boolean indicating if depth writing is enabled
  29004. * @returns the current depth writing state
  29005. */
  29006. getDepthWrite(): boolean;
  29007. /**
  29008. * Enable or disable depth writing
  29009. * @param enable defines the state to set
  29010. */
  29011. setDepthWrite(enable: boolean): void;
  29012. /**
  29013. * Enable or disable color writing
  29014. * @param enable defines the state to set
  29015. */
  29016. setColorWrite(enable: boolean): void;
  29017. /**
  29018. * Gets a boolean indicating if color writing is enabled
  29019. * @returns the current color writing state
  29020. */
  29021. getColorWrite(): boolean;
  29022. /**
  29023. * Sets alpha constants used by some alpha blending modes
  29024. * @param r defines the red component
  29025. * @param g defines the green component
  29026. * @param b defines the blue component
  29027. * @param a defines the alpha component
  29028. */
  29029. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29030. /**
  29031. * Sets the current alpha mode
  29032. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29033. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29034. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29035. */
  29036. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29037. /**
  29038. * Gets the current alpha mode
  29039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29040. * @returns the current alpha mode
  29041. */
  29042. getAlphaMode(): number;
  29043. /**
  29044. * Clears the list of texture accessible through engine.
  29045. * This can help preventing texture load conflict due to name collision.
  29046. */
  29047. clearInternalTexturesCache(): void;
  29048. /**
  29049. * Force the entire cache to be cleared
  29050. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29051. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29052. */
  29053. wipeCaches(bruteForce?: boolean): void;
  29054. /**
  29055. * Set the compressed texture format to use, based on the formats you have, and the formats
  29056. * supported by the hardware / browser.
  29057. *
  29058. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29059. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29060. * to API arguments needed to compressed textures. This puts the burden on the container
  29061. * generator to house the arcane code for determining these for current & future formats.
  29062. *
  29063. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29064. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29065. *
  29066. * Note: The result of this call is not taken into account when a texture is base64.
  29067. *
  29068. * @param formatsAvailable defines the list of those format families you have created
  29069. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29070. *
  29071. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29072. * @returns The extension selected.
  29073. */
  29074. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29075. private _getSamplingParameters;
  29076. private _partialLoadImg;
  29077. private _cascadeLoadImgs;
  29078. /** @hidden */
  29079. _createTexture(): WebGLTexture;
  29080. /**
  29081. * Usually called from Texture.ts.
  29082. * Passed information to create a WebGLTexture
  29083. * @param urlArg defines a value which contains one of the following:
  29084. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29085. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29086. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29087. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29088. * @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)
  29089. * @param scene needed for loading to the correct scene
  29090. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29091. * @param onLoad optional callback to be called upon successful completion
  29092. * @param onError optional callback to be called upon failure
  29093. * @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
  29094. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29095. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29096. * @param forcedExtension defines the extension to use to pick the right loader
  29097. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29098. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29099. */
  29100. 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;
  29101. private _rescaleTexture;
  29102. /**
  29103. * Update a raw texture
  29104. * @param texture defines the texture to update
  29105. * @param data defines the data to store in the texture
  29106. * @param format defines the format of the data
  29107. * @param invertY defines if data must be stored with Y axis inverted
  29108. * @param compression defines the compression used (null by default)
  29109. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29110. */
  29111. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29112. /**
  29113. * Creates a raw texture
  29114. * @param data defines the data to store in the texture
  29115. * @param width defines the width of the texture
  29116. * @param height defines the height of the texture
  29117. * @param format defines the format of the data
  29118. * @param generateMipMaps defines if the engine should generate the mip levels
  29119. * @param invertY defines if data must be stored with Y axis inverted
  29120. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29121. * @param compression defines the compression used (null by default)
  29122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29123. * @returns the raw texture inside an InternalTexture
  29124. */
  29125. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29126. private _unpackFlipYCached;
  29127. /**
  29128. * In case you are sharing the context with other applications, it might
  29129. * be interested to not cache the unpack flip y state to ensure a consistent
  29130. * value would be set.
  29131. */
  29132. enableUnpackFlipYCached: boolean;
  29133. /** @hidden */
  29134. _unpackFlipY(value: boolean): void;
  29135. /** @hidden */
  29136. _getUnpackAlignement(): number;
  29137. /**
  29138. * Creates a dynamic texture
  29139. * @param width defines the width of the texture
  29140. * @param height defines the height of the texture
  29141. * @param generateMipMaps defines if the engine should generate the mip levels
  29142. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29143. * @returns the dynamic texture inside an InternalTexture
  29144. */
  29145. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29146. /**
  29147. * Update the sampling mode of a given texture
  29148. * @param samplingMode defines the required sampling mode
  29149. * @param texture defines the texture to update
  29150. */
  29151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29152. /**
  29153. * Update the content of a dynamic texture
  29154. * @param texture defines the texture to update
  29155. * @param canvas defines the canvas containing the source
  29156. * @param invertY defines if data must be stored with Y axis inverted
  29157. * @param premulAlpha defines if alpha is stored as premultiplied
  29158. * @param format defines the format of the data
  29159. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29160. */
  29161. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29162. /**
  29163. * Update a video texture
  29164. * @param texture defines the texture to update
  29165. * @param video defines the video element to use
  29166. * @param invertY defines if data must be stored with Y axis inverted
  29167. */
  29168. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29169. /**
  29170. * Updates a depth texture Comparison Mode and Function.
  29171. * If the comparison Function is equal to 0, the mode will be set to none.
  29172. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29173. * @param texture The texture to set the comparison function for
  29174. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29175. */
  29176. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29177. private _setupDepthStencilTexture;
  29178. /**
  29179. * Creates a depth stencil texture.
  29180. * This is only available in WebGL 2 or with the depth texture extension available.
  29181. * @param size The size of face edge in the texture.
  29182. * @param options The options defining the texture.
  29183. * @returns The texture
  29184. */
  29185. createDepthStencilTexture(size: number | {
  29186. width: number;
  29187. height: number;
  29188. }, options: DepthTextureCreationOptions): InternalTexture;
  29189. /**
  29190. * Creates a depth stencil texture.
  29191. * This is only available in WebGL 2 or with the depth texture extension available.
  29192. * @param size The size of face edge in the texture.
  29193. * @param options The options defining the texture.
  29194. * @returns The texture
  29195. */
  29196. private _createDepthStencilTexture;
  29197. /**
  29198. * Creates a depth stencil cube texture.
  29199. * This is only available in WebGL 2.
  29200. * @param size The size of face edge in the cube texture.
  29201. * @param options The options defining the cube texture.
  29202. * @returns The cube texture
  29203. */
  29204. private _createDepthStencilCubeTexture;
  29205. /**
  29206. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29207. * @param renderTarget The render target to set the frame buffer for
  29208. */
  29209. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29210. /**
  29211. * Creates a new render target texture
  29212. * @param size defines the size of the texture
  29213. * @param options defines the options used to create the texture
  29214. * @returns a new render target texture stored in an InternalTexture
  29215. */
  29216. createRenderTargetTexture(size: number | {
  29217. width: number;
  29218. height: number;
  29219. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29220. /**
  29221. * Create a multi render target texture
  29222. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29223. * @param size defines the size of the texture
  29224. * @param options defines the creation options
  29225. * @returns the cube texture as an InternalTexture
  29226. */
  29227. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29228. private _setupFramebufferDepthAttachments;
  29229. /**
  29230. * Updates the sample count of a render target texture
  29231. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29232. * @param texture defines the texture to update
  29233. * @param samples defines the sample count to set
  29234. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29235. */
  29236. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29237. /**
  29238. * Update the sample count for a given multiple render target texture
  29239. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29240. * @param textures defines the textures to update
  29241. * @param samples defines the sample count to set
  29242. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29243. */
  29244. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29245. /** @hidden */
  29246. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29247. /** @hidden */
  29248. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29249. /** @hidden */
  29250. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29251. /** @hidden */
  29252. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29253. /**
  29254. * Creates a new render target cube texture
  29255. * @param size defines the size of the texture
  29256. * @param options defines the options used to create the texture
  29257. * @returns a new render target cube texture stored in an InternalTexture
  29258. */
  29259. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29260. /**
  29261. * Creates a cube texture
  29262. * @param rootUrl defines the url where the files to load is located
  29263. * @param scene defines the current scene
  29264. * @param files defines the list of files to load (1 per face)
  29265. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29266. * @param onLoad defines an optional callback raised when the texture is loaded
  29267. * @param onError defines an optional callback raised if there is an issue to load the texture
  29268. * @param format defines the format of the data
  29269. * @param forcedExtension defines the extension to use to pick the right loader
  29270. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29271. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29272. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29273. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29274. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29275. * @returns the cube texture as an InternalTexture
  29276. */
  29277. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29278. /**
  29279. * @hidden
  29280. */
  29281. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29282. /**
  29283. * Update a raw cube texture
  29284. * @param texture defines the texture to udpdate
  29285. * @param data defines the data to store
  29286. * @param format defines the data format
  29287. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29288. * @param invertY defines if data must be stored with Y axis inverted
  29289. * @param compression defines the compression used (null by default)
  29290. * @param level defines which level of the texture to update
  29291. */
  29292. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29293. /**
  29294. * Creates a new raw cube texture
  29295. * @param data defines the array of data to use to create each face
  29296. * @param size defines the size of the textures
  29297. * @param format defines the format of the data
  29298. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29299. * @param generateMipMaps defines if the engine should generate the mip levels
  29300. * @param invertY defines if data must be stored with Y axis inverted
  29301. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29302. * @param compression defines the compression used (null by default)
  29303. * @returns the cube texture as an InternalTexture
  29304. */
  29305. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29306. /**
  29307. * Creates a new raw cube texture from a specified url
  29308. * @param url defines the url where the data is located
  29309. * @param scene defines the current scene
  29310. * @param size defines the size of the textures
  29311. * @param format defines the format of the data
  29312. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29313. * @param noMipmap defines if the engine should avoid generating the mip levels
  29314. * @param callback defines a callback used to extract texture data from loaded data
  29315. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29316. * @param onLoad defines a callback called when texture is loaded
  29317. * @param onError defines a callback called if there is an error
  29318. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29319. * @param invertY defines if data must be stored with Y axis inverted
  29320. * @returns the cube texture as an InternalTexture
  29321. */
  29322. 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;
  29323. /**
  29324. * Update a raw 3D texture
  29325. * @param texture defines the texture to update
  29326. * @param data defines the data to store
  29327. * @param format defines the data format
  29328. * @param invertY defines if data must be stored with Y axis inverted
  29329. * @param compression defines the used compression (can be null)
  29330. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29331. */
  29332. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29333. /**
  29334. * Creates a new raw 3D texture
  29335. * @param data defines the data used to create the texture
  29336. * @param width defines the width of the texture
  29337. * @param height defines the height of the texture
  29338. * @param depth defines the depth of the texture
  29339. * @param format defines the format of the texture
  29340. * @param generateMipMaps defines if the engine must generate mip levels
  29341. * @param invertY defines if data must be stored with Y axis inverted
  29342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29343. * @param compression defines the compressed used (can be null)
  29344. * @param textureType defines the compressed used (can be null)
  29345. * @returns a new raw 3D texture (stored in an InternalTexture)
  29346. */
  29347. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29348. private _prepareWebGLTextureContinuation;
  29349. private _prepareWebGLTexture;
  29350. private _convertRGBtoRGBATextureData;
  29351. /** @hidden */
  29352. _releaseFramebufferObjects(texture: InternalTexture): void;
  29353. /** @hidden */
  29354. _releaseTexture(texture: InternalTexture): void;
  29355. private setProgram;
  29356. private _boundUniforms;
  29357. /**
  29358. * Binds an effect to the webGL context
  29359. * @param effect defines the effect to bind
  29360. */
  29361. bindSamplers(effect: Effect): void;
  29362. private _moveBoundTextureOnTop;
  29363. private _getCorrectTextureChannel;
  29364. private _linkTrackers;
  29365. private _removeDesignatedSlot;
  29366. private _activateCurrentTexture;
  29367. /** @hidden */
  29368. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29369. /** @hidden */
  29370. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29371. /**
  29372. * Sets a texture to the webGL context from a postprocess
  29373. * @param channel defines the channel to use
  29374. * @param postProcess defines the source postprocess
  29375. */
  29376. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29377. /**
  29378. * Binds the output of the passed in post process to the texture channel specified
  29379. * @param channel The channel the texture should be bound to
  29380. * @param postProcess The post process which's output should be bound
  29381. */
  29382. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29383. /**
  29384. * Unbind all textures from the webGL context
  29385. */
  29386. unbindAllTextures(): void;
  29387. /**
  29388. * Sets a texture to the according uniform.
  29389. * @param channel The texture channel
  29390. * @param uniform The uniform to set
  29391. * @param texture The texture to apply
  29392. */
  29393. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29394. /**
  29395. * Sets a depth stencil texture from a render target to the according uniform.
  29396. * @param channel The texture channel
  29397. * @param uniform The uniform to set
  29398. * @param texture The render target texture containing the depth stencil texture to apply
  29399. */
  29400. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29401. private _bindSamplerUniformToChannel;
  29402. private _getTextureWrapMode;
  29403. private _setTexture;
  29404. /**
  29405. * Sets an array of texture to the webGL context
  29406. * @param channel defines the channel where the texture array must be set
  29407. * @param uniform defines the associated uniform location
  29408. * @param textures defines the array of textures to bind
  29409. */
  29410. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29411. /** @hidden */
  29412. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29413. private _setTextureParameterFloat;
  29414. private _setTextureParameterInteger;
  29415. /**
  29416. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29417. * @param x defines the x coordinate of the rectangle where pixels must be read
  29418. * @param y defines the y coordinate of the rectangle where pixels must be read
  29419. * @param width defines the width of the rectangle where pixels must be read
  29420. * @param height defines the height of the rectangle where pixels must be read
  29421. * @returns a Uint8Array containing RGBA colors
  29422. */
  29423. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29424. /**
  29425. * Add an externaly attached data from its key.
  29426. * This method call will fail and return false, if such key already exists.
  29427. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29428. * @param key the unique key that identifies the data
  29429. * @param data the data object to associate to the key for this Engine instance
  29430. * @return true if no such key were already present and the data was added successfully, false otherwise
  29431. */
  29432. addExternalData<T>(key: string, data: T): boolean;
  29433. /**
  29434. * Get an externaly attached data from its key
  29435. * @param key the unique key that identifies the data
  29436. * @return the associated data, if present (can be null), or undefined if not present
  29437. */
  29438. getExternalData<T>(key: string): T;
  29439. /**
  29440. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29441. * @param key the unique key that identifies the data
  29442. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29443. * @return the associated data, can be null if the factory returned null.
  29444. */
  29445. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29446. /**
  29447. * Remove an externaly attached data from the Engine instance
  29448. * @param key the unique key that identifies the data
  29449. * @return true if the data was successfully removed, false if it doesn't exist
  29450. */
  29451. removeExternalData(key: string): boolean;
  29452. /**
  29453. * Unbind all vertex attributes from the webGL context
  29454. */
  29455. unbindAllAttributes(): void;
  29456. /**
  29457. * 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
  29458. */
  29459. releaseEffects(): void;
  29460. /**
  29461. * Dispose and release all associated resources
  29462. */
  29463. dispose(): void;
  29464. /**
  29465. * Display the loading screen
  29466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29467. */
  29468. displayLoadingUI(): void;
  29469. /**
  29470. * Hide the loading screen
  29471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29472. */
  29473. hideLoadingUI(): void;
  29474. /**
  29475. * Gets the current loading screen object
  29476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29477. */
  29478. /**
  29479. * Sets the current loading screen object
  29480. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29481. */
  29482. loadingScreen: ILoadingScreen;
  29483. /**
  29484. * Sets the current loading screen text
  29485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29486. */
  29487. loadingUIText: string;
  29488. /**
  29489. * Sets the current loading screen background color
  29490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29491. */
  29492. loadingUIBackgroundColor: string;
  29493. /**
  29494. * Attach a new callback raised when context lost event is fired
  29495. * @param callback defines the callback to call
  29496. */
  29497. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29498. /**
  29499. * Attach a new callback raised when context restored event is fired
  29500. * @param callback defines the callback to call
  29501. */
  29502. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29503. /**
  29504. * Gets the source code of the vertex shader associated with a specific webGL program
  29505. * @param program defines the program to use
  29506. * @returns a string containing the source code of the vertex shader associated with the program
  29507. */
  29508. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29509. /**
  29510. * Gets the source code of the fragment shader associated with a specific webGL program
  29511. * @param program defines the program to use
  29512. * @returns a string containing the source code of the fragment shader associated with the program
  29513. */
  29514. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29515. /**
  29516. * Get the current error code of the webGL context
  29517. * @returns the error code
  29518. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29519. */
  29520. getError(): number;
  29521. /**
  29522. * Gets the current framerate
  29523. * @returns a number representing the framerate
  29524. */
  29525. getFps(): number;
  29526. /**
  29527. * Gets the time spent between current and previous frame
  29528. * @returns a number representing the delta time in ms
  29529. */
  29530. getDeltaTime(): number;
  29531. private _measureFps;
  29532. /** @hidden */
  29533. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29534. private _canRenderToFloatFramebuffer;
  29535. private _canRenderToHalfFloatFramebuffer;
  29536. private _canRenderToFramebuffer;
  29537. /** @hidden */
  29538. _getWebGLTextureType(type: number): number;
  29539. private _getInternalFormat;
  29540. /** @hidden */
  29541. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29542. /** @hidden */
  29543. _getRGBAMultiSampleBufferFormat(type: number): number;
  29544. /** @hidden */
  29545. _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;
  29546. /** @hidden */
  29547. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29548. private _partialLoadFile;
  29549. private _cascadeLoadFiles;
  29550. /**
  29551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29552. * @returns true if the engine can be created
  29553. * @ignorenaming
  29554. */
  29555. static isSupported(): boolean;
  29556. }
  29557. }
  29558. declare module "babylonjs/Materials/effect" {
  29559. import { Observable } from "babylonjs/Misc/observable";
  29560. import { Nullable } from "babylonjs/types";
  29561. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29562. import { Engine } from "babylonjs/Engines/engine";
  29563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29564. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29565. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29566. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29568. /**
  29569. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29570. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29571. */
  29572. export class EffectFallbacks {
  29573. private _defines;
  29574. private _currentRank;
  29575. private _maxRank;
  29576. private _mesh;
  29577. /**
  29578. * Removes the fallback from the bound mesh.
  29579. */
  29580. unBindMesh(): void;
  29581. /**
  29582. * Adds a fallback on the specified property.
  29583. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29584. * @param define The name of the define in the shader
  29585. */
  29586. addFallback(rank: number, define: string): void;
  29587. /**
  29588. * Sets the mesh to use CPU skinning when needing to fallback.
  29589. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29590. * @param mesh The mesh to use the fallbacks.
  29591. */
  29592. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29593. /**
  29594. * Checks to see if more fallbacks are still availible.
  29595. */
  29596. readonly isMoreFallbacks: boolean;
  29597. /**
  29598. * Removes the defines that shoould be removed when falling back.
  29599. * @param currentDefines defines the current define statements for the shader.
  29600. * @param effect defines the current effect we try to compile
  29601. * @returns The resulting defines with defines of the current rank removed.
  29602. */
  29603. reduce(currentDefines: string, effect: Effect): string;
  29604. }
  29605. /**
  29606. * Options to be used when creating an effect.
  29607. */
  29608. export class EffectCreationOptions {
  29609. /**
  29610. * Atrributes that will be used in the shader.
  29611. */
  29612. attributes: string[];
  29613. /**
  29614. * Uniform varible names that will be set in the shader.
  29615. */
  29616. uniformsNames: string[];
  29617. /**
  29618. * Uniform buffer varible names that will be set in the shader.
  29619. */
  29620. uniformBuffersNames: string[];
  29621. /**
  29622. * Sampler texture variable names that will be set in the shader.
  29623. */
  29624. samplers: string[];
  29625. /**
  29626. * Define statements that will be set in the shader.
  29627. */
  29628. defines: any;
  29629. /**
  29630. * Possible fallbacks for this effect to improve performance when needed.
  29631. */
  29632. fallbacks: Nullable<EffectFallbacks>;
  29633. /**
  29634. * Callback that will be called when the shader is compiled.
  29635. */
  29636. onCompiled: Nullable<(effect: Effect) => void>;
  29637. /**
  29638. * Callback that will be called if an error occurs during shader compilation.
  29639. */
  29640. onError: Nullable<(effect: Effect, errors: string) => void>;
  29641. /**
  29642. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29643. */
  29644. indexParameters: any;
  29645. /**
  29646. * Max number of lights that can be used in the shader.
  29647. */
  29648. maxSimultaneousLights: number;
  29649. /**
  29650. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29651. */
  29652. transformFeedbackVaryings: Nullable<string[]>;
  29653. }
  29654. /**
  29655. * Effect containing vertex and fragment shader that can be executed on an object.
  29656. */
  29657. export class Effect {
  29658. /**
  29659. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29660. */
  29661. static ShadersRepository: string;
  29662. /**
  29663. * Name of the effect.
  29664. */
  29665. name: any;
  29666. /**
  29667. * String container all the define statements that should be set on the shader.
  29668. */
  29669. defines: string;
  29670. /**
  29671. * Callback that will be called when the shader is compiled.
  29672. */
  29673. onCompiled: Nullable<(effect: Effect) => void>;
  29674. /**
  29675. * Callback that will be called if an error occurs during shader compilation.
  29676. */
  29677. onError: Nullable<(effect: Effect, errors: string) => void>;
  29678. /**
  29679. * Callback that will be called when effect is bound.
  29680. */
  29681. onBind: Nullable<(effect: Effect) => void>;
  29682. /**
  29683. * Unique ID of the effect.
  29684. */
  29685. uniqueId: number;
  29686. /**
  29687. * Observable that will be called when the shader is compiled.
  29688. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29689. */
  29690. onCompileObservable: Observable<Effect>;
  29691. /**
  29692. * Observable that will be called if an error occurs during shader compilation.
  29693. */
  29694. onErrorObservable: Observable<Effect>;
  29695. /** @hidden */
  29696. _onBindObservable: Nullable<Observable<Effect>>;
  29697. /**
  29698. * Observable that will be called when effect is bound.
  29699. */
  29700. readonly onBindObservable: Observable<Effect>;
  29701. /** @hidden */
  29702. _bonesComputationForcedToCPU: boolean;
  29703. private static _uniqueIdSeed;
  29704. private _engine;
  29705. private _uniformBuffersNames;
  29706. private _uniformsNames;
  29707. private _samplers;
  29708. private _isReady;
  29709. private _compilationError;
  29710. private _attributesNames;
  29711. private _attributes;
  29712. private _uniforms;
  29713. /**
  29714. * Key for the effect.
  29715. * @hidden
  29716. */
  29717. _key: string;
  29718. private _indexParameters;
  29719. private _fallbacks;
  29720. private _vertexSourceCode;
  29721. private _fragmentSourceCode;
  29722. private _vertexSourceCodeOverride;
  29723. private _fragmentSourceCodeOverride;
  29724. private _transformFeedbackVaryings;
  29725. /**
  29726. * Compiled shader to webGL program.
  29727. * @hidden
  29728. */
  29729. _program: WebGLProgram;
  29730. private _valueCache;
  29731. private static _baseCache;
  29732. /**
  29733. * Instantiates an effect.
  29734. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29735. * @param baseName Name of the effect.
  29736. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29737. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29738. * @param samplers List of sampler variables that will be passed to the shader.
  29739. * @param engine Engine to be used to render the effect
  29740. * @param defines Define statements to be added to the shader.
  29741. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29742. * @param onCompiled Callback that will be called when the shader is compiled.
  29743. * @param onError Callback that will be called if an error occurs during shader compilation.
  29744. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29745. */
  29746. 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);
  29747. /**
  29748. * Unique key for this effect
  29749. */
  29750. readonly key: string;
  29751. /**
  29752. * If the effect has been compiled and prepared.
  29753. * @returns if the effect is compiled and prepared.
  29754. */
  29755. isReady(): boolean;
  29756. /**
  29757. * The engine the effect was initialized with.
  29758. * @returns the engine.
  29759. */
  29760. getEngine(): Engine;
  29761. /**
  29762. * The compiled webGL program for the effect
  29763. * @returns the webGL program.
  29764. */
  29765. getProgram(): WebGLProgram;
  29766. /**
  29767. * The set of names of attribute variables for the shader.
  29768. * @returns An array of attribute names.
  29769. */
  29770. getAttributesNames(): string[];
  29771. /**
  29772. * Returns the attribute at the given index.
  29773. * @param index The index of the attribute.
  29774. * @returns The location of the attribute.
  29775. */
  29776. getAttributeLocation(index: number): number;
  29777. /**
  29778. * Returns the attribute based on the name of the variable.
  29779. * @param name of the attribute to look up.
  29780. * @returns the attribute location.
  29781. */
  29782. getAttributeLocationByName(name: string): number;
  29783. /**
  29784. * The number of attributes.
  29785. * @returns the numnber of attributes.
  29786. */
  29787. getAttributesCount(): number;
  29788. /**
  29789. * Gets the index of a uniform variable.
  29790. * @param uniformName of the uniform to look up.
  29791. * @returns the index.
  29792. */
  29793. getUniformIndex(uniformName: string): number;
  29794. /**
  29795. * Returns the attribute based on the name of the variable.
  29796. * @param uniformName of the uniform to look up.
  29797. * @returns the location of the uniform.
  29798. */
  29799. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29800. /**
  29801. * Returns an array of sampler variable names
  29802. * @returns The array of sampler variable neames.
  29803. */
  29804. getSamplers(): string[];
  29805. /**
  29806. * The error from the last compilation.
  29807. * @returns the error string.
  29808. */
  29809. getCompilationError(): string;
  29810. /**
  29811. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29812. * @param func The callback to be used.
  29813. */
  29814. executeWhenCompiled(func: (effect: Effect) => void): void;
  29815. private _checkIsReady;
  29816. /** @hidden */
  29817. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29818. /** @hidden */
  29819. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29820. /** @hidden */
  29821. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29822. private _processShaderConversion;
  29823. private _processIncludes;
  29824. private _processPrecision;
  29825. /**
  29826. * Recompiles the webGL program
  29827. * @param vertexSourceCode The source code for the vertex shader.
  29828. * @param fragmentSourceCode The source code for the fragment shader.
  29829. * @param onCompiled Callback called when completed.
  29830. * @param onError Callback called on error.
  29831. * @hidden
  29832. */
  29833. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29834. /**
  29835. * Gets the uniform locations of the the specified variable names
  29836. * @param names THe names of the variables to lookup.
  29837. * @returns Array of locations in the same order as variable names.
  29838. */
  29839. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29840. /**
  29841. * Prepares the effect
  29842. * @hidden
  29843. */
  29844. _prepareEffect(): void;
  29845. /**
  29846. * Checks if the effect is supported. (Must be called after compilation)
  29847. */
  29848. readonly isSupported: boolean;
  29849. /**
  29850. * Binds a texture to the engine to be used as output of the shader.
  29851. * @param channel Name of the output variable.
  29852. * @param texture Texture to bind.
  29853. * @hidden
  29854. */
  29855. _bindTexture(channel: string, texture: InternalTexture): void;
  29856. /**
  29857. * Sets a texture on the engine to be used in the shader.
  29858. * @param channel Name of the sampler variable.
  29859. * @param texture Texture to set.
  29860. */
  29861. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29862. /**
  29863. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29864. * @param channel Name of the sampler variable.
  29865. * @param texture Texture to set.
  29866. */
  29867. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29868. /**
  29869. * Sets an array of textures on the engine to be used in the shader.
  29870. * @param channel Name of the variable.
  29871. * @param textures Textures to set.
  29872. */
  29873. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29874. /**
  29875. * 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)
  29876. * @param channel Name of the sampler variable.
  29877. * @param postProcess Post process to get the input texture from.
  29878. */
  29879. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29880. /**
  29881. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29882. * 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)
  29883. * @param channel Name of the sampler variable.
  29884. * @param postProcess Post process to get the output texture from.
  29885. */
  29886. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29887. /** @hidden */
  29888. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29889. /** @hidden */
  29890. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29891. /** @hidden */
  29892. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29893. /** @hidden */
  29894. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29895. /**
  29896. * Binds a buffer to a uniform.
  29897. * @param buffer Buffer to bind.
  29898. * @param name Name of the uniform variable to bind to.
  29899. */
  29900. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29901. /**
  29902. * Binds block to a uniform.
  29903. * @param blockName Name of the block to bind.
  29904. * @param index Index to bind.
  29905. */
  29906. bindUniformBlock(blockName: string, index: number): void;
  29907. /**
  29908. * Sets an interger value on a uniform variable.
  29909. * @param uniformName Name of the variable.
  29910. * @param value Value to be set.
  29911. * @returns this effect.
  29912. */
  29913. setInt(uniformName: string, value: number): Effect;
  29914. /**
  29915. * Sets an int array on a uniform variable.
  29916. * @param uniformName Name of the variable.
  29917. * @param array array to be set.
  29918. * @returns this effect.
  29919. */
  29920. setIntArray(uniformName: string, array: Int32Array): Effect;
  29921. /**
  29922. * 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)
  29923. * @param uniformName Name of the variable.
  29924. * @param array array to be set.
  29925. * @returns this effect.
  29926. */
  29927. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29928. /**
  29929. * 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)
  29930. * @param uniformName Name of the variable.
  29931. * @param array array to be set.
  29932. * @returns this effect.
  29933. */
  29934. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29935. /**
  29936. * 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)
  29937. * @param uniformName Name of the variable.
  29938. * @param array array to be set.
  29939. * @returns this effect.
  29940. */
  29941. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29942. /**
  29943. * Sets an float array on a uniform variable.
  29944. * @param uniformName Name of the variable.
  29945. * @param array array to be set.
  29946. * @returns this effect.
  29947. */
  29948. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29949. /**
  29950. * 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)
  29951. * @param uniformName Name of the variable.
  29952. * @param array array to be set.
  29953. * @returns this effect.
  29954. */
  29955. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29956. /**
  29957. * 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)
  29958. * @param uniformName Name of the variable.
  29959. * @param array array to be set.
  29960. * @returns this effect.
  29961. */
  29962. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29963. /**
  29964. * 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)
  29965. * @param uniformName Name of the variable.
  29966. * @param array array to be set.
  29967. * @returns this effect.
  29968. */
  29969. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29970. /**
  29971. * Sets an array on a uniform variable.
  29972. * @param uniformName Name of the variable.
  29973. * @param array array to be set.
  29974. * @returns this effect.
  29975. */
  29976. setArray(uniformName: string, array: number[]): Effect;
  29977. /**
  29978. * 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)
  29979. * @param uniformName Name of the variable.
  29980. * @param array array to be set.
  29981. * @returns this effect.
  29982. */
  29983. setArray2(uniformName: string, array: number[]): Effect;
  29984. /**
  29985. * 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)
  29986. * @param uniformName Name of the variable.
  29987. * @param array array to be set.
  29988. * @returns this effect.
  29989. */
  29990. setArray3(uniformName: string, array: number[]): Effect;
  29991. /**
  29992. * 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)
  29993. * @param uniformName Name of the variable.
  29994. * @param array array to be set.
  29995. * @returns this effect.
  29996. */
  29997. setArray4(uniformName: string, array: number[]): Effect;
  29998. /**
  29999. * Sets matrices on a uniform variable.
  30000. * @param uniformName Name of the variable.
  30001. * @param matrices matrices to be set.
  30002. * @returns this effect.
  30003. */
  30004. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30005. /**
  30006. * Sets matrix on a uniform variable.
  30007. * @param uniformName Name of the variable.
  30008. * @param matrix matrix to be set.
  30009. * @returns this effect.
  30010. */
  30011. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30012. /**
  30013. * 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)
  30014. * @param uniformName Name of the variable.
  30015. * @param matrix matrix to be set.
  30016. * @returns this effect.
  30017. */
  30018. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30019. /**
  30020. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30021. * @param uniformName Name of the variable.
  30022. * @param matrix matrix to be set.
  30023. * @returns this effect.
  30024. */
  30025. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30026. /**
  30027. * Sets a float on a uniform variable.
  30028. * @param uniformName Name of the variable.
  30029. * @param value value to be set.
  30030. * @returns this effect.
  30031. */
  30032. setFloat(uniformName: string, value: number): Effect;
  30033. /**
  30034. * Sets a boolean on a uniform variable.
  30035. * @param uniformName Name of the variable.
  30036. * @param bool value to be set.
  30037. * @returns this effect.
  30038. */
  30039. setBool(uniformName: string, bool: boolean): Effect;
  30040. /**
  30041. * Sets a Vector2 on a uniform variable.
  30042. * @param uniformName Name of the variable.
  30043. * @param vector2 vector2 to be set.
  30044. * @returns this effect.
  30045. */
  30046. setVector2(uniformName: string, vector2: Vector2): Effect;
  30047. /**
  30048. * Sets a float2 on a uniform variable.
  30049. * @param uniformName Name of the variable.
  30050. * @param x First float in float2.
  30051. * @param y Second float in float2.
  30052. * @returns this effect.
  30053. */
  30054. setFloat2(uniformName: string, x: number, y: number): Effect;
  30055. /**
  30056. * Sets a Vector3 on a uniform variable.
  30057. * @param uniformName Name of the variable.
  30058. * @param vector3 Value to be set.
  30059. * @returns this effect.
  30060. */
  30061. setVector3(uniformName: string, vector3: Vector3): Effect;
  30062. /**
  30063. * Sets a float3 on a uniform variable.
  30064. * @param uniformName Name of the variable.
  30065. * @param x First float in float3.
  30066. * @param y Second float in float3.
  30067. * @param z Third float in float3.
  30068. * @returns this effect.
  30069. */
  30070. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30071. /**
  30072. * Sets a Vector4 on a uniform variable.
  30073. * @param uniformName Name of the variable.
  30074. * @param vector4 Value to be set.
  30075. * @returns this effect.
  30076. */
  30077. setVector4(uniformName: string, vector4: Vector4): Effect;
  30078. /**
  30079. * Sets a float4 on a uniform variable.
  30080. * @param uniformName Name of the variable.
  30081. * @param x First float in float4.
  30082. * @param y Second float in float4.
  30083. * @param z Third float in float4.
  30084. * @param w Fourth float in float4.
  30085. * @returns this effect.
  30086. */
  30087. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30088. /**
  30089. * Sets a Color3 on a uniform variable.
  30090. * @param uniformName Name of the variable.
  30091. * @param color3 Value to be set.
  30092. * @returns this effect.
  30093. */
  30094. setColor3(uniformName: string, color3: Color3): Effect;
  30095. /**
  30096. * Sets a Color4 on a uniform variable.
  30097. * @param uniformName Name of the variable.
  30098. * @param color3 Value to be set.
  30099. * @param alpha Alpha value to be set.
  30100. * @returns this effect.
  30101. */
  30102. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30103. /**
  30104. * Sets a Color4 on a uniform variable
  30105. * @param uniformName defines the name of the variable
  30106. * @param color4 defines the value to be set
  30107. * @returns this effect.
  30108. */
  30109. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30110. /**
  30111. * This function will add a new shader to the shader store
  30112. * @param name the name of the shader
  30113. * @param pixelShader optional pixel shader content
  30114. * @param vertexShader optional vertex shader content
  30115. */
  30116. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30117. /**
  30118. * Store of each shader (The can be looked up using effect.key)
  30119. */
  30120. static ShadersStore: {
  30121. [key: string]: string;
  30122. };
  30123. /**
  30124. * Store of each included file for a shader (The can be looked up using effect.key)
  30125. */
  30126. static IncludesShadersStore: {
  30127. [key: string]: string;
  30128. };
  30129. /**
  30130. * Resets the cache of effects.
  30131. */
  30132. static ResetCache(): void;
  30133. }
  30134. }
  30135. declare module "babylonjs/Materials/colorCurves" {
  30136. import { Effect } from "babylonjs/Materials/effect";
  30137. /**
  30138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30140. * 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;
  30141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30142. */
  30143. export class ColorCurves {
  30144. private _dirty;
  30145. private _tempColor;
  30146. private _globalCurve;
  30147. private _highlightsCurve;
  30148. private _midtonesCurve;
  30149. private _shadowsCurve;
  30150. private _positiveCurve;
  30151. private _negativeCurve;
  30152. private _globalHue;
  30153. private _globalDensity;
  30154. private _globalSaturation;
  30155. private _globalExposure;
  30156. /**
  30157. * Gets the global Hue value.
  30158. * 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).
  30159. */
  30160. /**
  30161. * Sets the global Hue value.
  30162. * 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).
  30163. */
  30164. globalHue: number;
  30165. /**
  30166. * Gets the global Density value.
  30167. * 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.
  30168. * Values less than zero provide a filter of opposite hue.
  30169. */
  30170. /**
  30171. * Sets the global Density value.
  30172. * 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.
  30173. * Values less than zero provide a filter of opposite hue.
  30174. */
  30175. globalDensity: number;
  30176. /**
  30177. * Gets the global Saturation value.
  30178. * 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.
  30179. */
  30180. /**
  30181. * Sets the global Saturation value.
  30182. * 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.
  30183. */
  30184. globalSaturation: number;
  30185. /**
  30186. * Gets the global Exposure value.
  30187. * 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.
  30188. */
  30189. /**
  30190. * Sets the global Exposure value.
  30191. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30192. */
  30193. globalExposure: number;
  30194. private _highlightsHue;
  30195. private _highlightsDensity;
  30196. private _highlightsSaturation;
  30197. private _highlightsExposure;
  30198. /**
  30199. * Gets the highlights Hue value.
  30200. * 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).
  30201. */
  30202. /**
  30203. * Sets the highlights Hue value.
  30204. * 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).
  30205. */
  30206. highlightsHue: number;
  30207. /**
  30208. * Gets the highlights Density value.
  30209. * 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.
  30210. * Values less than zero provide a filter of opposite hue.
  30211. */
  30212. /**
  30213. * Sets the highlights Density value.
  30214. * 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.
  30215. * Values less than zero provide a filter of opposite hue.
  30216. */
  30217. highlightsDensity: number;
  30218. /**
  30219. * Gets the highlights Saturation value.
  30220. * 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.
  30221. */
  30222. /**
  30223. * Sets the highlights Saturation value.
  30224. * 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.
  30225. */
  30226. highlightsSaturation: number;
  30227. /**
  30228. * Gets the highlights Exposure value.
  30229. * 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.
  30230. */
  30231. /**
  30232. * Sets the highlights Exposure value.
  30233. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30234. */
  30235. highlightsExposure: number;
  30236. private _midtonesHue;
  30237. private _midtonesDensity;
  30238. private _midtonesSaturation;
  30239. private _midtonesExposure;
  30240. /**
  30241. * Gets the midtones Hue value.
  30242. * 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).
  30243. */
  30244. /**
  30245. * Sets the midtones Hue value.
  30246. * 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).
  30247. */
  30248. midtonesHue: number;
  30249. /**
  30250. * Gets the midtones Density value.
  30251. * 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.
  30252. * Values less than zero provide a filter of opposite hue.
  30253. */
  30254. /**
  30255. * Sets the midtones Density value.
  30256. * 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.
  30257. * Values less than zero provide a filter of opposite hue.
  30258. */
  30259. midtonesDensity: number;
  30260. /**
  30261. * Gets the midtones Saturation value.
  30262. * 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.
  30263. */
  30264. /**
  30265. * Sets the midtones Saturation value.
  30266. * 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.
  30267. */
  30268. midtonesSaturation: number;
  30269. /**
  30270. * Gets the midtones Exposure value.
  30271. * 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.
  30272. */
  30273. /**
  30274. * Sets the midtones Exposure value.
  30275. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30276. */
  30277. midtonesExposure: number;
  30278. private _shadowsHue;
  30279. private _shadowsDensity;
  30280. private _shadowsSaturation;
  30281. private _shadowsExposure;
  30282. /**
  30283. * Gets the shadows Hue value.
  30284. * 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).
  30285. */
  30286. /**
  30287. * Sets the shadows Hue value.
  30288. * 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).
  30289. */
  30290. shadowsHue: number;
  30291. /**
  30292. * Gets the shadows Density value.
  30293. * 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.
  30294. * Values less than zero provide a filter of opposite hue.
  30295. */
  30296. /**
  30297. * Sets the shadows Density value.
  30298. * 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.
  30299. * Values less than zero provide a filter of opposite hue.
  30300. */
  30301. shadowsDensity: number;
  30302. /**
  30303. * Gets the shadows Saturation value.
  30304. * 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.
  30305. */
  30306. /**
  30307. * Sets the shadows Saturation value.
  30308. * 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.
  30309. */
  30310. shadowsSaturation: number;
  30311. /**
  30312. * Gets the shadows Exposure value.
  30313. * 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.
  30314. */
  30315. /**
  30316. * Sets the shadows Exposure value.
  30317. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30318. */
  30319. shadowsExposure: number;
  30320. /**
  30321. * Returns the class name
  30322. * @returns The class name
  30323. */
  30324. getClassName(): string;
  30325. /**
  30326. * Binds the color curves to the shader.
  30327. * @param colorCurves The color curve to bind
  30328. * @param effect The effect to bind to
  30329. * @param positiveUniform The positive uniform shader parameter
  30330. * @param neutralUniform The neutral uniform shader parameter
  30331. * @param negativeUniform The negative uniform shader parameter
  30332. */
  30333. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30334. /**
  30335. * Prepare the list of uniforms associated with the ColorCurves effects.
  30336. * @param uniformsList The list of uniforms used in the effect
  30337. */
  30338. static PrepareUniforms(uniformsList: string[]): void;
  30339. /**
  30340. * Returns color grading data based on a hue, density, saturation and exposure value.
  30341. * @param filterHue The hue of the color filter.
  30342. * @param filterDensity The density of the color filter.
  30343. * @param saturation The saturation.
  30344. * @param exposure The exposure.
  30345. * @param result The result data container.
  30346. */
  30347. private getColorGradingDataToRef;
  30348. /**
  30349. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30350. * @param value The input slider value in range [-100,100].
  30351. * @returns Adjusted value.
  30352. */
  30353. private static applyColorGradingSliderNonlinear;
  30354. /**
  30355. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30356. * @param hue The hue (H) input.
  30357. * @param saturation The saturation (S) input.
  30358. * @param brightness The brightness (B) input.
  30359. * @result An RGBA color represented as Vector4.
  30360. */
  30361. private static fromHSBToRef;
  30362. /**
  30363. * Returns a value clamped between min and max
  30364. * @param value The value to clamp
  30365. * @param min The minimum of value
  30366. * @param max The maximum of value
  30367. * @returns The clamped value.
  30368. */
  30369. private static clamp;
  30370. /**
  30371. * Clones the current color curve instance.
  30372. * @return The cloned curves
  30373. */
  30374. clone(): ColorCurves;
  30375. /**
  30376. * Serializes the current color curve instance to a json representation.
  30377. * @return a JSON representation
  30378. */
  30379. serialize(): any;
  30380. /**
  30381. * Parses the color curve from a json representation.
  30382. * @param source the JSON source to parse
  30383. * @return The parsed curves
  30384. */
  30385. static Parse(source: any): ColorCurves;
  30386. }
  30387. }
  30388. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30389. import { Observable } from "babylonjs/Misc/observable";
  30390. import { Nullable } from "babylonjs/types";
  30391. import { Color4 } from "babylonjs/Maths/math";
  30392. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30393. import { Effect } from "babylonjs/Materials/effect";
  30394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30395. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30396. /**
  30397. * Interface to follow in your material defines to integrate easily the
  30398. * Image proccessing functions.
  30399. * @hidden
  30400. */
  30401. export interface IImageProcessingConfigurationDefines {
  30402. IMAGEPROCESSING: boolean;
  30403. VIGNETTE: boolean;
  30404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30405. VIGNETTEBLENDMODEOPAQUE: boolean;
  30406. TONEMAPPING: boolean;
  30407. TONEMAPPING_ACES: boolean;
  30408. CONTRAST: boolean;
  30409. EXPOSURE: boolean;
  30410. COLORCURVES: boolean;
  30411. COLORGRADING: boolean;
  30412. COLORGRADING3D: boolean;
  30413. SAMPLER3DGREENDEPTH: boolean;
  30414. SAMPLER3DBGRMAP: boolean;
  30415. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30416. }
  30417. /**
  30418. * @hidden
  30419. */
  30420. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30421. IMAGEPROCESSING: boolean;
  30422. VIGNETTE: boolean;
  30423. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30424. VIGNETTEBLENDMODEOPAQUE: boolean;
  30425. TONEMAPPING: boolean;
  30426. TONEMAPPING_ACES: boolean;
  30427. CONTRAST: boolean;
  30428. COLORCURVES: boolean;
  30429. COLORGRADING: boolean;
  30430. COLORGRADING3D: boolean;
  30431. SAMPLER3DGREENDEPTH: boolean;
  30432. SAMPLER3DBGRMAP: boolean;
  30433. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30434. EXPOSURE: boolean;
  30435. constructor();
  30436. }
  30437. /**
  30438. * This groups together the common properties used for image processing either in direct forward pass
  30439. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30440. * or not.
  30441. */
  30442. export class ImageProcessingConfiguration {
  30443. /**
  30444. * Default tone mapping applied in BabylonJS.
  30445. */
  30446. static readonly TONEMAPPING_STANDARD: number;
  30447. /**
  30448. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30449. * to other engines rendering to increase portability.
  30450. */
  30451. static readonly TONEMAPPING_ACES: number;
  30452. /**
  30453. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30454. */
  30455. colorCurves: Nullable<ColorCurves>;
  30456. private _colorCurvesEnabled;
  30457. /**
  30458. * Gets wether the color curves effect is enabled.
  30459. */
  30460. /**
  30461. * Sets wether the color curves effect is enabled.
  30462. */
  30463. colorCurvesEnabled: boolean;
  30464. private _colorGradingTexture;
  30465. /**
  30466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30467. */
  30468. /**
  30469. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30470. */
  30471. colorGradingTexture: Nullable<BaseTexture>;
  30472. private _colorGradingEnabled;
  30473. /**
  30474. * Gets wether the color grading effect is enabled.
  30475. */
  30476. /**
  30477. * Sets wether the color grading effect is enabled.
  30478. */
  30479. colorGradingEnabled: boolean;
  30480. private _colorGradingWithGreenDepth;
  30481. /**
  30482. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30483. */
  30484. /**
  30485. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30486. */
  30487. colorGradingWithGreenDepth: boolean;
  30488. private _colorGradingBGR;
  30489. /**
  30490. * Gets wether the color grading texture contains BGR values.
  30491. */
  30492. /**
  30493. * Sets wether the color grading texture contains BGR values.
  30494. */
  30495. colorGradingBGR: boolean;
  30496. /** @hidden */
  30497. _exposure: number;
  30498. /**
  30499. * Gets the Exposure used in the effect.
  30500. */
  30501. /**
  30502. * Sets the Exposure used in the effect.
  30503. */
  30504. exposure: number;
  30505. private _toneMappingEnabled;
  30506. /**
  30507. * Gets wether the tone mapping effect is enabled.
  30508. */
  30509. /**
  30510. * Sets wether the tone mapping effect is enabled.
  30511. */
  30512. toneMappingEnabled: boolean;
  30513. private _toneMappingType;
  30514. /**
  30515. * Gets the type of tone mapping effect.
  30516. */
  30517. /**
  30518. * Sets the type of tone mapping effect used in BabylonJS.
  30519. */
  30520. toneMappingType: number;
  30521. protected _contrast: number;
  30522. /**
  30523. * Gets the contrast used in the effect.
  30524. */
  30525. /**
  30526. * Sets the contrast used in the effect.
  30527. */
  30528. contrast: number;
  30529. /**
  30530. * Vignette stretch size.
  30531. */
  30532. vignetteStretch: number;
  30533. /**
  30534. * Vignette centre X Offset.
  30535. */
  30536. vignetteCentreX: number;
  30537. /**
  30538. * Vignette centre Y Offset.
  30539. */
  30540. vignetteCentreY: number;
  30541. /**
  30542. * Vignette weight or intensity of the vignette effect.
  30543. */
  30544. vignetteWeight: number;
  30545. /**
  30546. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30547. * if vignetteEnabled is set to true.
  30548. */
  30549. vignetteColor: Color4;
  30550. /**
  30551. * Camera field of view used by the Vignette effect.
  30552. */
  30553. vignetteCameraFov: number;
  30554. private _vignetteBlendMode;
  30555. /**
  30556. * Gets the vignette blend mode allowing different kind of effect.
  30557. */
  30558. /**
  30559. * Sets the vignette blend mode allowing different kind of effect.
  30560. */
  30561. vignetteBlendMode: number;
  30562. private _vignetteEnabled;
  30563. /**
  30564. * Gets wether the vignette effect is enabled.
  30565. */
  30566. /**
  30567. * Sets wether the vignette effect is enabled.
  30568. */
  30569. vignetteEnabled: boolean;
  30570. private _applyByPostProcess;
  30571. /**
  30572. * Gets wether the image processing is applied through a post process or not.
  30573. */
  30574. /**
  30575. * Sets wether the image processing is applied through a post process or not.
  30576. */
  30577. applyByPostProcess: boolean;
  30578. private _isEnabled;
  30579. /**
  30580. * Gets wether the image processing is enabled or not.
  30581. */
  30582. /**
  30583. * Sets wether the image processing is enabled or not.
  30584. */
  30585. isEnabled: boolean;
  30586. /**
  30587. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30588. */
  30589. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30590. /**
  30591. * Method called each time the image processing information changes requires to recompile the effect.
  30592. */
  30593. protected _updateParameters(): void;
  30594. /**
  30595. * Gets the current class name.
  30596. * @return "ImageProcessingConfiguration"
  30597. */
  30598. getClassName(): string;
  30599. /**
  30600. * Prepare the list of uniforms associated with the Image Processing effects.
  30601. * @param uniforms The list of uniforms used in the effect
  30602. * @param defines the list of defines currently in use
  30603. */
  30604. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30605. /**
  30606. * Prepare the list of samplers associated with the Image Processing effects.
  30607. * @param samplersList The list of uniforms used in the effect
  30608. * @param defines the list of defines currently in use
  30609. */
  30610. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30611. /**
  30612. * Prepare the list of defines associated to the shader.
  30613. * @param defines the list of defines to complete
  30614. * @param forPostProcess Define if we are currently in post process mode or not
  30615. */
  30616. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30617. /**
  30618. * Returns true if all the image processing information are ready.
  30619. * @returns True if ready, otherwise, false
  30620. */
  30621. isReady(): boolean;
  30622. /**
  30623. * Binds the image processing to the shader.
  30624. * @param effect The effect to bind to
  30625. * @param aspectRatio Define the current aspect ratio of the effect
  30626. */
  30627. bind(effect: Effect, aspectRatio?: number): void;
  30628. /**
  30629. * Clones the current image processing instance.
  30630. * @return The cloned image processing
  30631. */
  30632. clone(): ImageProcessingConfiguration;
  30633. /**
  30634. * Serializes the current image processing instance to a json representation.
  30635. * @return a JSON representation
  30636. */
  30637. serialize(): any;
  30638. /**
  30639. * Parses the image processing from a json representation.
  30640. * @param source the JSON source to parse
  30641. * @return The parsed image processing
  30642. */
  30643. static Parse(source: any): ImageProcessingConfiguration;
  30644. private static _VIGNETTEMODE_MULTIPLY;
  30645. private static _VIGNETTEMODE_OPAQUE;
  30646. /**
  30647. * Used to apply the vignette as a mix with the pixel color.
  30648. */
  30649. static readonly VIGNETTEMODE_MULTIPLY: number;
  30650. /**
  30651. * Used to apply the vignette as a replacement of the pixel color.
  30652. */
  30653. static readonly VIGNETTEMODE_OPAQUE: number;
  30654. }
  30655. }
  30656. declare module "babylonjs/Materials/fresnelParameters" {
  30657. import { Color3 } from "babylonjs/Maths/math";
  30658. /**
  30659. * This represents all the required information to add a fresnel effect on a material:
  30660. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30661. */
  30662. export class FresnelParameters {
  30663. private _isEnabled;
  30664. /**
  30665. * Define if the fresnel effect is enable or not.
  30666. */
  30667. isEnabled: boolean;
  30668. /**
  30669. * Define the color used on edges (grazing angle)
  30670. */
  30671. leftColor: Color3;
  30672. /**
  30673. * Define the color used on center
  30674. */
  30675. rightColor: Color3;
  30676. /**
  30677. * Define bias applied to computed fresnel term
  30678. */
  30679. bias: number;
  30680. /**
  30681. * Defined the power exponent applied to fresnel term
  30682. */
  30683. power: number;
  30684. /**
  30685. * Clones the current fresnel and its valuues
  30686. * @returns a clone fresnel configuration
  30687. */
  30688. clone(): FresnelParameters;
  30689. /**
  30690. * Serializes the current fresnel parameters to a JSON representation.
  30691. * @return the JSON serialization
  30692. */
  30693. serialize(): any;
  30694. /**
  30695. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30696. * @param parsedFresnelParameters Define the JSON representation
  30697. * @returns the parsed parameters
  30698. */
  30699. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30700. }
  30701. }
  30702. declare module "babylonjs/Misc/decorators" {
  30703. import { Nullable } from "babylonjs/types";
  30704. import { Scene } from "babylonjs/scene";
  30705. import { IAnimatable } from "babylonjs/Misc/tools";
  30706. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30707. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30708. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30709. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30710. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30711. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30712. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30713. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30714. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30715. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30716. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30717. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30718. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30719. /**
  30720. * Decorator used to define property that can be serialized as reference to a camera
  30721. * @param sourceName defines the name of the property to decorate
  30722. */
  30723. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30724. /**
  30725. * Class used to help serialization objects
  30726. */
  30727. export class SerializationHelper {
  30728. /** hidden */
  30729. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30730. /** hidden */
  30731. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30732. /** hidden */
  30733. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30734. /** hidden */
  30735. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30736. /**
  30737. * Appends the serialized animations from the source animations
  30738. * @param source Source containing the animations
  30739. * @param destination Target to store the animations
  30740. */
  30741. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30742. /**
  30743. * Static function used to serialized a specific entity
  30744. * @param entity defines the entity to serialize
  30745. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30746. * @returns a JSON compatible object representing the serialization of the entity
  30747. */
  30748. static Serialize<T>(entity: T, serializationObject?: any): any;
  30749. /**
  30750. * Creates a new entity from a serialization data object
  30751. * @param creationFunction defines a function used to instanciated the new entity
  30752. * @param source defines the source serialization data
  30753. * @param scene defines the hosting scene
  30754. * @param rootUrl defines the root url for resources
  30755. * @returns a new entity
  30756. */
  30757. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30758. /**
  30759. * Clones an object
  30760. * @param creationFunction defines the function used to instanciate the new object
  30761. * @param source defines the source object
  30762. * @returns the cloned object
  30763. */
  30764. static Clone<T>(creationFunction: () => T, source: T): T;
  30765. /**
  30766. * Instanciates a new object based on a source one (some data will be shared between both object)
  30767. * @param creationFunction defines the function used to instanciate the new object
  30768. * @param source defines the source object
  30769. * @returns the new object
  30770. */
  30771. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30772. }
  30773. }
  30774. declare module "babylonjs/Cameras/camera" {
  30775. import { SmartArray } from "babylonjs/Misc/smartArray";
  30776. import { Observable } from "babylonjs/Misc/observable";
  30777. import { Nullable } from "babylonjs/types";
  30778. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30779. import { Scene } from "babylonjs/scene";
  30780. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30781. import { Node } from "babylonjs/node";
  30782. import { Mesh } from "babylonjs/Meshes/mesh";
  30783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30784. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30788. import { Ray } from "babylonjs/Culling/ray";
  30789. /**
  30790. * This is the base class of all the camera used in the application.
  30791. * @see http://doc.babylonjs.com/features/cameras
  30792. */
  30793. export class Camera extends Node {
  30794. /** @hidden */
  30795. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30796. /**
  30797. * This is the default projection mode used by the cameras.
  30798. * It helps recreating a feeling of perspective and better appreciate depth.
  30799. * This is the best way to simulate real life cameras.
  30800. */
  30801. static readonly PERSPECTIVE_CAMERA: number;
  30802. /**
  30803. * This helps creating camera with an orthographic mode.
  30804. * 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.
  30805. */
  30806. static readonly ORTHOGRAPHIC_CAMERA: number;
  30807. /**
  30808. * This is the default FOV mode for perspective cameras.
  30809. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30810. */
  30811. static readonly FOVMODE_VERTICAL_FIXED: number;
  30812. /**
  30813. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30814. */
  30815. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30816. /**
  30817. * This specifies ther is no need for a camera rig.
  30818. * Basically only one eye is rendered corresponding to the camera.
  30819. */
  30820. static readonly RIG_MODE_NONE: number;
  30821. /**
  30822. * Simulates a camera Rig with one blue eye and one red eye.
  30823. * This can be use with 3d blue and red glasses.
  30824. */
  30825. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30826. /**
  30827. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30828. */
  30829. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30830. /**
  30831. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30832. */
  30833. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30834. /**
  30835. * Defines that both eyes of the camera will be rendered over under each other.
  30836. */
  30837. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30838. /**
  30839. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30840. */
  30841. static readonly RIG_MODE_VR: number;
  30842. /**
  30843. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30844. */
  30845. static readonly RIG_MODE_WEBVR: number;
  30846. /**
  30847. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30848. */
  30849. static readonly RIG_MODE_CUSTOM: number;
  30850. /**
  30851. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30852. */
  30853. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30854. /**
  30855. * Define the input manager associated with the camera.
  30856. */
  30857. inputs: CameraInputsManager<Camera>;
  30858. /** @hidden */
  30859. _position: Vector3;
  30860. /**
  30861. * Define the current local position of the camera in the scene
  30862. */
  30863. position: Vector3;
  30864. /**
  30865. * The vector the camera should consider as up.
  30866. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30867. */
  30868. upVector: Vector3;
  30869. /**
  30870. * Define the current limit on the left side for an orthographic camera
  30871. * In scene unit
  30872. */
  30873. orthoLeft: Nullable<number>;
  30874. /**
  30875. * Define the current limit on the right side for an orthographic camera
  30876. * In scene unit
  30877. */
  30878. orthoRight: Nullable<number>;
  30879. /**
  30880. * Define the current limit on the bottom side for an orthographic camera
  30881. * In scene unit
  30882. */
  30883. orthoBottom: Nullable<number>;
  30884. /**
  30885. * Define the current limit on the top side for an orthographic camera
  30886. * In scene unit
  30887. */
  30888. orthoTop: Nullable<number>;
  30889. /**
  30890. * Field Of View is set in Radians. (default is 0.8)
  30891. */
  30892. fov: number;
  30893. /**
  30894. * Define the minimum distance the camera can see from.
  30895. * This is important to note that the depth buffer are not infinite and the closer it starts
  30896. * the more your scene might encounter depth fighting issue.
  30897. */
  30898. minZ: number;
  30899. /**
  30900. * Define the maximum distance the camera can see to.
  30901. * This is important to note that the depth buffer are not infinite and the further it end
  30902. * the more your scene might encounter depth fighting issue.
  30903. */
  30904. maxZ: number;
  30905. /**
  30906. * Define the default inertia of the camera.
  30907. * This helps giving a smooth feeling to the camera movement.
  30908. */
  30909. inertia: number;
  30910. /**
  30911. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30912. */
  30913. mode: number;
  30914. /**
  30915. * Define wether the camera is intermediate.
  30916. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30917. */
  30918. isIntermediate: boolean;
  30919. /**
  30920. * Define the viewport of the camera.
  30921. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30922. */
  30923. viewport: Viewport;
  30924. /**
  30925. * Restricts the camera to viewing objects with the same layerMask.
  30926. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30927. */
  30928. layerMask: number;
  30929. /**
  30930. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30931. */
  30932. fovMode: number;
  30933. /**
  30934. * Rig mode of the camera.
  30935. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30936. * This is normally controlled byt the camera themselves as internal use.
  30937. */
  30938. cameraRigMode: number;
  30939. /**
  30940. * Defines the distance between both "eyes" in case of a RIG
  30941. */
  30942. interaxialDistance: number;
  30943. /**
  30944. * Defines if stereoscopic rendering is done side by side or over under.
  30945. */
  30946. isStereoscopicSideBySide: boolean;
  30947. /**
  30948. * 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
  30949. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30950. * else in the scene.
  30951. */
  30952. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30953. /**
  30954. * When set, the camera will render to this render target instead of the default canvas
  30955. */
  30956. outputRenderTarget: Nullable<RenderTargetTexture>;
  30957. /**
  30958. * Observable triggered when the camera view matrix has changed.
  30959. */
  30960. onViewMatrixChangedObservable: Observable<Camera>;
  30961. /**
  30962. * Observable triggered when the camera Projection matrix has changed.
  30963. */
  30964. onProjectionMatrixChangedObservable: Observable<Camera>;
  30965. /**
  30966. * Observable triggered when the inputs have been processed.
  30967. */
  30968. onAfterCheckInputsObservable: Observable<Camera>;
  30969. /**
  30970. * Observable triggered when reset has been called and applied to the camera.
  30971. */
  30972. onRestoreStateObservable: Observable<Camera>;
  30973. /** @hidden */
  30974. _cameraRigParams: any;
  30975. /** @hidden */
  30976. _rigCameras: Camera[];
  30977. /** @hidden */
  30978. _rigPostProcess: Nullable<PostProcess>;
  30979. protected _webvrViewMatrix: Matrix;
  30980. /** @hidden */
  30981. _skipRendering: boolean;
  30982. /** @hidden */
  30983. _projectionMatrix: Matrix;
  30984. /** @hidden */
  30985. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30986. /** @hidden */
  30987. _activeMeshes: SmartArray<AbstractMesh>;
  30988. protected _globalPosition: Vector3;
  30989. /** hidden */
  30990. _computedViewMatrix: Matrix;
  30991. private _doNotComputeProjectionMatrix;
  30992. private _transformMatrix;
  30993. private _frustumPlanes;
  30994. private _refreshFrustumPlanes;
  30995. private _storedFov;
  30996. private _stateStored;
  30997. /**
  30998. * Instantiates a new camera object.
  30999. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31000. * @see http://doc.babylonjs.com/features/cameras
  31001. * @param name Defines the name of the camera in the scene
  31002. * @param position Defines the position of the camera
  31003. * @param scene Defines the scene the camera belongs too
  31004. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31005. */
  31006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31007. /**
  31008. * Store current camera state (fov, position, etc..)
  31009. * @returns the camera
  31010. */
  31011. storeState(): Camera;
  31012. /**
  31013. * Restores the camera state values if it has been stored. You must call storeState() first
  31014. */
  31015. protected _restoreStateValues(): boolean;
  31016. /**
  31017. * Restored camera state. You must call storeState() first.
  31018. * @returns true if restored and false otherwise
  31019. */
  31020. restoreState(): boolean;
  31021. /**
  31022. * Gets the class name of the camera.
  31023. * @returns the class name
  31024. */
  31025. getClassName(): string;
  31026. /** @hidden */
  31027. readonly _isCamera: boolean;
  31028. /**
  31029. * Gets a string representation of the camera useful for debug purpose.
  31030. * @param fullDetails Defines that a more verboe level of logging is required
  31031. * @returns the string representation
  31032. */
  31033. toString(fullDetails?: boolean): string;
  31034. /**
  31035. * Gets the current world space position of the camera.
  31036. */
  31037. readonly globalPosition: Vector3;
  31038. /**
  31039. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31040. * @returns the active meshe list
  31041. */
  31042. getActiveMeshes(): SmartArray<AbstractMesh>;
  31043. /**
  31044. * Check wether a mesh is part of the current active mesh list of the camera
  31045. * @param mesh Defines the mesh to check
  31046. * @returns true if active, false otherwise
  31047. */
  31048. isActiveMesh(mesh: Mesh): boolean;
  31049. /**
  31050. * Is this camera ready to be used/rendered
  31051. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31052. * @return true if the camera is ready
  31053. */
  31054. isReady(completeCheck?: boolean): boolean;
  31055. /** @hidden */
  31056. _initCache(): void;
  31057. /** @hidden */
  31058. _updateCache(ignoreParentClass?: boolean): void;
  31059. /** @hidden */
  31060. _isSynchronized(): boolean;
  31061. /** @hidden */
  31062. _isSynchronizedViewMatrix(): boolean;
  31063. /** @hidden */
  31064. _isSynchronizedProjectionMatrix(): boolean;
  31065. /**
  31066. * Attach the input controls to a specific dom element to get the input from.
  31067. * @param element Defines the element the controls should be listened from
  31068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31069. */
  31070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31071. /**
  31072. * Detach the current controls from the specified dom element.
  31073. * @param element Defines the element to stop listening the inputs from
  31074. */
  31075. detachControl(element: HTMLElement): void;
  31076. /**
  31077. * Update the camera state according to the different inputs gathered during the frame.
  31078. */
  31079. update(): void;
  31080. /** @hidden */
  31081. _checkInputs(): void;
  31082. /** @hidden */
  31083. readonly rigCameras: Camera[];
  31084. /**
  31085. * Gets the post process used by the rig cameras
  31086. */
  31087. readonly rigPostProcess: Nullable<PostProcess>;
  31088. /**
  31089. * Internal, gets the first post proces.
  31090. * @returns the first post process to be run on this camera.
  31091. */
  31092. _getFirstPostProcess(): Nullable<PostProcess>;
  31093. private _cascadePostProcessesToRigCams;
  31094. /**
  31095. * Attach a post process to the camera.
  31096. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31097. * @param postProcess The post process to attach to the camera
  31098. * @param insertAt The position of the post process in case several of them are in use in the scene
  31099. * @returns the position the post process has been inserted at
  31100. */
  31101. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31102. /**
  31103. * Detach a post process to the camera.
  31104. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31105. * @param postProcess The post process to detach from the camera
  31106. */
  31107. detachPostProcess(postProcess: PostProcess): void;
  31108. /**
  31109. * Gets the current world matrix of the camera
  31110. */
  31111. getWorldMatrix(): Matrix;
  31112. /** @hidden */
  31113. _getViewMatrix(): Matrix;
  31114. /**
  31115. * Gets the current view matrix of the camera.
  31116. * @param force forces the camera to recompute the matrix without looking at the cached state
  31117. * @returns the view matrix
  31118. */
  31119. getViewMatrix(force?: boolean): Matrix;
  31120. /**
  31121. * Freeze the projection matrix.
  31122. * It will prevent the cache check of the camera projection compute and can speed up perf
  31123. * if no parameter of the camera are meant to change
  31124. * @param projection Defines manually a projection if necessary
  31125. */
  31126. freezeProjectionMatrix(projection?: Matrix): void;
  31127. /**
  31128. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31129. */
  31130. unfreezeProjectionMatrix(): void;
  31131. /**
  31132. * Gets the current projection matrix of the camera.
  31133. * @param force forces the camera to recompute the matrix without looking at the cached state
  31134. * @returns the projection matrix
  31135. */
  31136. getProjectionMatrix(force?: boolean): Matrix;
  31137. /**
  31138. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31139. * @returns a Matrix
  31140. */
  31141. getTransformationMatrix(): Matrix;
  31142. private _updateFrustumPlanes;
  31143. /**
  31144. * Checks if a cullable object (mesh...) is in the camera frustum
  31145. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31146. * @param target The object to check
  31147. * @returns true if the object is in frustum otherwise false
  31148. */
  31149. isInFrustum(target: ICullable): boolean;
  31150. /**
  31151. * Checks if a cullable object (mesh...) is in the camera frustum
  31152. * Unlike isInFrustum this cheks the full bounding box
  31153. * @param target The object to check
  31154. * @returns true if the object is in frustum otherwise false
  31155. */
  31156. isCompletelyInFrustum(target: ICullable): boolean;
  31157. /**
  31158. * Gets a ray in the forward direction from the camera.
  31159. * @param length Defines the length of the ray to create
  31160. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31161. * @param origin Defines the start point of the ray which defaults to the camera position
  31162. * @returns the forward ray
  31163. */
  31164. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31165. /**
  31166. * Releases resources associated with this node.
  31167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31169. */
  31170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31171. /** @hidden */
  31172. _isLeftCamera: boolean;
  31173. /**
  31174. * Gets the left camera of a rig setup in case of Rigged Camera
  31175. */
  31176. readonly isLeftCamera: boolean;
  31177. /** @hidden */
  31178. _isRightCamera: boolean;
  31179. /**
  31180. * Gets the right camera of a rig setup in case of Rigged Camera
  31181. */
  31182. readonly isRightCamera: boolean;
  31183. /**
  31184. * Gets the left camera of a rig setup in case of Rigged Camera
  31185. */
  31186. readonly leftCamera: Nullable<FreeCamera>;
  31187. /**
  31188. * Gets the right camera of a rig setup in case of Rigged Camera
  31189. */
  31190. readonly rightCamera: Nullable<FreeCamera>;
  31191. /**
  31192. * Gets the left camera target of a rig setup in case of Rigged Camera
  31193. * @returns the target position
  31194. */
  31195. getLeftTarget(): Nullable<Vector3>;
  31196. /**
  31197. * Gets the right camera target of a rig setup in case of Rigged Camera
  31198. * @returns the target position
  31199. */
  31200. getRightTarget(): Nullable<Vector3>;
  31201. /**
  31202. * @hidden
  31203. */
  31204. setCameraRigMode(mode: number, rigParams: any): void;
  31205. /** @hidden */
  31206. static _setStereoscopicRigMode(camera: Camera): void;
  31207. /** @hidden */
  31208. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31209. /** @hidden */
  31210. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31211. /** @hidden */
  31212. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31213. /** @hidden */
  31214. _getVRProjectionMatrix(): Matrix;
  31215. protected _updateCameraRotationMatrix(): void;
  31216. protected _updateWebVRCameraRotationMatrix(): void;
  31217. /**
  31218. * This function MUST be overwritten by the different WebVR cameras available.
  31219. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31220. * @hidden
  31221. */
  31222. _getWebVRProjectionMatrix(): Matrix;
  31223. /**
  31224. * This function MUST be overwritten by the different WebVR cameras available.
  31225. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31226. * @hidden
  31227. */
  31228. _getWebVRViewMatrix(): Matrix;
  31229. /** @hidden */
  31230. setCameraRigParameter(name: string, value: any): void;
  31231. /**
  31232. * needs to be overridden by children so sub has required properties to be copied
  31233. * @hidden
  31234. */
  31235. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31236. /**
  31237. * May need to be overridden by children
  31238. * @hidden
  31239. */
  31240. _updateRigCameras(): void;
  31241. /** @hidden */
  31242. _setupInputs(): void;
  31243. /**
  31244. * Serialiaze the camera setup to a json represention
  31245. * @returns the JSON representation
  31246. */
  31247. serialize(): any;
  31248. /**
  31249. * Clones the current camera.
  31250. * @param name The cloned camera name
  31251. * @returns the cloned camera
  31252. */
  31253. clone(name: string): Camera;
  31254. /**
  31255. * Gets the direction of the camera relative to a given local axis.
  31256. * @param localAxis Defines the reference axis to provide a relative direction.
  31257. * @return the direction
  31258. */
  31259. getDirection(localAxis: Vector3): Vector3;
  31260. /**
  31261. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31262. * @param localAxis Defines the reference axis to provide a relative direction.
  31263. * @param result Defines the vector to store the result in
  31264. */
  31265. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31266. /**
  31267. * Gets a camera constructor for a given camera type
  31268. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31269. * @param name The name of the camera the result will be able to instantiate
  31270. * @param scene The scene the result will construct the camera in
  31271. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31272. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31273. * @returns a factory method to construc the camera
  31274. */
  31275. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31276. /**
  31277. * Compute the world matrix of the camera.
  31278. * @returns the camera workd matrix
  31279. */
  31280. computeWorldMatrix(): Matrix;
  31281. /**
  31282. * Parse a JSON and creates the camera from the parsed information
  31283. * @param parsedCamera The JSON to parse
  31284. * @param scene The scene to instantiate the camera in
  31285. * @returns the newly constructed camera
  31286. */
  31287. static Parse(parsedCamera: any, scene: Scene): Camera;
  31288. }
  31289. }
  31290. declare module "babylonjs/Misc/tools" {
  31291. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31292. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31294. import { Observable } from "babylonjs/Misc/observable";
  31295. import { DomManagement } from "babylonjs/Misc/domManagement";
  31296. import { WebRequest } from "babylonjs/Misc/webRequest";
  31297. import { Camera } from "babylonjs/Cameras/camera";
  31298. import { Engine } from "babylonjs/Engines/engine";
  31299. import { Animation } from "babylonjs/Animations/animation";
  31300. /**
  31301. * Interface for any object that can request an animation frame
  31302. */
  31303. export interface ICustomAnimationFrameRequester {
  31304. /**
  31305. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31306. */
  31307. renderFunction?: Function;
  31308. /**
  31309. * Called to request the next frame to render to
  31310. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31311. */
  31312. requestAnimationFrame: Function;
  31313. /**
  31314. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31315. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31316. */
  31317. requestID?: number;
  31318. }
  31319. /**
  31320. * Interface containing an array of animations
  31321. */
  31322. export interface IAnimatable {
  31323. /**
  31324. * Array of animations
  31325. */
  31326. animations: Array<Animation>;
  31327. }
  31328. /** Interface used by value gradients (color, factor, ...) */
  31329. export interface IValueGradient {
  31330. /**
  31331. * Gets or sets the gradient value (between 0 and 1)
  31332. */
  31333. gradient: number;
  31334. }
  31335. /** Class used to store color4 gradient */
  31336. export class ColorGradient implements IValueGradient {
  31337. /**
  31338. * Gets or sets the gradient value (between 0 and 1)
  31339. */
  31340. gradient: number;
  31341. /**
  31342. * Gets or sets first associated color
  31343. */
  31344. color1: Color4;
  31345. /**
  31346. * Gets or sets second associated color
  31347. */
  31348. color2?: Color4;
  31349. /**
  31350. * Will get a color picked randomly between color1 and color2.
  31351. * If color2 is undefined then color1 will be used
  31352. * @param result defines the target Color4 to store the result in
  31353. */
  31354. getColorToRef(result: Color4): void;
  31355. }
  31356. /** Class used to store color 3 gradient */
  31357. export class Color3Gradient implements IValueGradient {
  31358. /**
  31359. * Gets or sets the gradient value (between 0 and 1)
  31360. */
  31361. gradient: number;
  31362. /**
  31363. * Gets or sets the associated color
  31364. */
  31365. color: Color3;
  31366. }
  31367. /** Class used to store factor gradient */
  31368. export class FactorGradient implements IValueGradient {
  31369. /**
  31370. * Gets or sets the gradient value (between 0 and 1)
  31371. */
  31372. gradient: number;
  31373. /**
  31374. * Gets or sets first associated factor
  31375. */
  31376. factor1: number;
  31377. /**
  31378. * Gets or sets second associated factor
  31379. */
  31380. factor2?: number;
  31381. /**
  31382. * Will get a number picked randomly between factor1 and factor2.
  31383. * If factor2 is undefined then factor1 will be used
  31384. * @returns the picked number
  31385. */
  31386. getFactor(): number;
  31387. }
  31388. /**
  31389. * @ignore
  31390. * Application error to support additional information when loading a file
  31391. */
  31392. export class LoadFileError extends Error {
  31393. /** defines the optional web request */
  31394. request?: WebRequest | undefined;
  31395. private static _setPrototypeOf;
  31396. /**
  31397. * Creates a new LoadFileError
  31398. * @param message defines the message of the error
  31399. * @param request defines the optional web request
  31400. */
  31401. constructor(message: string,
  31402. /** defines the optional web request */
  31403. request?: WebRequest | undefined);
  31404. }
  31405. /**
  31406. * Class used to define a retry strategy when error happens while loading assets
  31407. */
  31408. export class RetryStrategy {
  31409. /**
  31410. * Function used to defines an exponential back off strategy
  31411. * @param maxRetries defines the maximum number of retries (3 by default)
  31412. * @param baseInterval defines the interval between retries
  31413. * @returns the strategy function to use
  31414. */
  31415. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31416. }
  31417. /**
  31418. * File request interface
  31419. */
  31420. export interface IFileRequest {
  31421. /**
  31422. * Raised when the request is complete (success or error).
  31423. */
  31424. onCompleteObservable: Observable<IFileRequest>;
  31425. /**
  31426. * Aborts the request for a file.
  31427. */
  31428. abort: () => void;
  31429. }
  31430. /**
  31431. * Class containing a set of static utilities functions
  31432. */
  31433. export class Tools {
  31434. /**
  31435. * Gets or sets the base URL to use to load assets
  31436. */
  31437. static BaseUrl: string;
  31438. /**
  31439. * Enable/Disable Custom HTTP Request Headers globally.
  31440. * default = false
  31441. * @see CustomRequestHeaders
  31442. */
  31443. static UseCustomRequestHeaders: boolean;
  31444. /**
  31445. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31446. * i.e. when loading files, where the server/service expects an Authorization header
  31447. */
  31448. static CustomRequestHeaders: {
  31449. [key: string]: string;
  31450. };
  31451. /**
  31452. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31453. */
  31454. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31455. /**
  31456. * Default behaviour for cors in the application.
  31457. * It can be a string if the expected behavior is identical in the entire app.
  31458. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31459. */
  31460. static CorsBehavior: string | ((url: string | string[]) => string);
  31461. /**
  31462. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31463. * @ignorenaming
  31464. */
  31465. static UseFallbackTexture: boolean;
  31466. /**
  31467. * Use this object to register external classes like custom textures or material
  31468. * to allow the laoders to instantiate them
  31469. */
  31470. static RegisteredExternalClasses: {
  31471. [key: string]: Object;
  31472. };
  31473. /**
  31474. * Texture content used if a texture cannot loaded
  31475. * @ignorenaming
  31476. */
  31477. static fallbackTexture: string;
  31478. /**
  31479. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31480. * @param u defines the coordinate on X axis
  31481. * @param v defines the coordinate on Y axis
  31482. * @param width defines the width of the source data
  31483. * @param height defines the height of the source data
  31484. * @param pixels defines the source byte array
  31485. * @param color defines the output color
  31486. */
  31487. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31488. /**
  31489. * Interpolates between a and b via alpha
  31490. * @param a The lower value (returned when alpha = 0)
  31491. * @param b The upper value (returned when alpha = 1)
  31492. * @param alpha The interpolation-factor
  31493. * @return The mixed value
  31494. */
  31495. static Mix(a: number, b: number, alpha: number): number;
  31496. /**
  31497. * Tries to instantiate a new object from a given class name
  31498. * @param className defines the class name to instantiate
  31499. * @returns the new object or null if the system was not able to do the instantiation
  31500. */
  31501. static Instantiate(className: string): any;
  31502. /**
  31503. * Provides a slice function that will work even on IE
  31504. * @param data defines the array to slice
  31505. * @param start defines the start of the data (optional)
  31506. * @param end defines the end of the data (optional)
  31507. * @returns the new sliced array
  31508. */
  31509. static Slice<T>(data: T, start?: number, end?: number): T;
  31510. /**
  31511. * Polyfill for setImmediate
  31512. * @param action defines the action to execute after the current execution block
  31513. */
  31514. static SetImmediate(action: () => void): void;
  31515. /**
  31516. * Function indicating if a number is an exponent of 2
  31517. * @param value defines the value to test
  31518. * @returns true if the value is an exponent of 2
  31519. */
  31520. static IsExponentOfTwo(value: number): boolean;
  31521. private static _tmpFloatArray;
  31522. /**
  31523. * Returns the nearest 32-bit single precision float representation of a Number
  31524. * @param value A Number. If the parameter is of a different type, it will get converted
  31525. * to a number or to NaN if it cannot be converted
  31526. * @returns number
  31527. */
  31528. static FloatRound(value: number): number;
  31529. /**
  31530. * Find the next highest power of two.
  31531. * @param x Number to start search from.
  31532. * @return Next highest power of two.
  31533. */
  31534. static CeilingPOT(x: number): number;
  31535. /**
  31536. * Find the next lowest power of two.
  31537. * @param x Number to start search from.
  31538. * @return Next lowest power of two.
  31539. */
  31540. static FloorPOT(x: number): number;
  31541. /**
  31542. * Find the nearest power of two.
  31543. * @param x Number to start search from.
  31544. * @return Next nearest power of two.
  31545. */
  31546. static NearestPOT(x: number): number;
  31547. /**
  31548. * Get the closest exponent of two
  31549. * @param value defines the value to approximate
  31550. * @param max defines the maximum value to return
  31551. * @param mode defines how to define the closest value
  31552. * @returns closest exponent of two of the given value
  31553. */
  31554. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31555. /**
  31556. * Extracts the filename from a path
  31557. * @param path defines the path to use
  31558. * @returns the filename
  31559. */
  31560. static GetFilename(path: string): string;
  31561. /**
  31562. * Extracts the "folder" part of a path (everything before the filename).
  31563. * @param uri The URI to extract the info from
  31564. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31565. * @returns The "folder" part of the path
  31566. */
  31567. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31568. /**
  31569. * Extracts text content from a DOM element hierarchy
  31570. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31571. */
  31572. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31573. /**
  31574. * Convert an angle in radians to degrees
  31575. * @param angle defines the angle to convert
  31576. * @returns the angle in degrees
  31577. */
  31578. static ToDegrees(angle: number): number;
  31579. /**
  31580. * Convert an angle in degrees to radians
  31581. * @param angle defines the angle to convert
  31582. * @returns the angle in radians
  31583. */
  31584. static ToRadians(angle: number): number;
  31585. /**
  31586. * Encode a buffer to a base64 string
  31587. * @param buffer defines the buffer to encode
  31588. * @returns the encoded string
  31589. */
  31590. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31591. /**
  31592. * Extracts minimum and maximum values from a list of indexed positions
  31593. * @param positions defines the positions to use
  31594. * @param indices defines the indices to the positions
  31595. * @param indexStart defines the start index
  31596. * @param indexCount defines the end index
  31597. * @param bias defines bias value to add to the result
  31598. * @return minimum and maximum values
  31599. */
  31600. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31601. minimum: Vector3;
  31602. maximum: Vector3;
  31603. };
  31604. /**
  31605. * Extracts minimum and maximum values from a list of positions
  31606. * @param positions defines the positions to use
  31607. * @param start defines the start index in the positions array
  31608. * @param count defines the number of positions to handle
  31609. * @param bias defines bias value to add to the result
  31610. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31611. * @return minimum and maximum values
  31612. */
  31613. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31614. minimum: Vector3;
  31615. maximum: Vector3;
  31616. };
  31617. /**
  31618. * Returns an array if obj is not an array
  31619. * @param obj defines the object to evaluate as an array
  31620. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31621. * @returns either obj directly if obj is an array or a new array containing obj
  31622. */
  31623. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31624. /**
  31625. * Gets the pointer prefix to use
  31626. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31627. */
  31628. static GetPointerPrefix(): string;
  31629. /**
  31630. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31631. * @param func - the function to be called
  31632. * @param requester - the object that will request the next frame. Falls back to window.
  31633. * @returns frame number
  31634. */
  31635. static QueueNewFrame(func: () => void, requester?: any): number;
  31636. /**
  31637. * Ask the browser to promote the current element to fullscreen rendering mode
  31638. * @param element defines the DOM element to promote
  31639. */
  31640. static RequestFullscreen(element: HTMLElement): void;
  31641. /**
  31642. * Asks the browser to exit fullscreen mode
  31643. */
  31644. static ExitFullscreen(): void;
  31645. /**
  31646. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31647. * @param url define the url we are trying
  31648. * @param element define the dom element where to configure the cors policy
  31649. */
  31650. static SetCorsBehavior(url: string | string[], element: {
  31651. crossOrigin: string | null;
  31652. }): void;
  31653. /**
  31654. * Removes unwanted characters from an url
  31655. * @param url defines the url to clean
  31656. * @returns the cleaned url
  31657. */
  31658. static CleanUrl(url: string): string;
  31659. /**
  31660. * Gets or sets a function used to pre-process url before using them to load assets
  31661. */
  31662. static PreprocessUrl: (url: string) => string;
  31663. /**
  31664. * Loads an image as an HTMLImageElement.
  31665. * @param input url string, ArrayBuffer, or Blob to load
  31666. * @param onLoad callback called when the image successfully loads
  31667. * @param onError callback called when the image fails to load
  31668. * @param offlineProvider offline provider for caching
  31669. * @returns the HTMLImageElement of the loaded image
  31670. */
  31671. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31672. /**
  31673. * Loads a file
  31674. * @param url url string, ArrayBuffer, or Blob to load
  31675. * @param onSuccess callback called when the file successfully loads
  31676. * @param onProgress callback called while file is loading (if the server supports this mode)
  31677. * @param offlineProvider defines the offline provider for caching
  31678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31679. * @param onError callback called when the file fails to load
  31680. * @returns a file request object
  31681. */
  31682. 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;
  31683. /**
  31684. * Load a script (identified by an url). When the url returns, the
  31685. * content of this file is added into a new script element, attached to the DOM (body element)
  31686. * @param scriptUrl defines the url of the script to laod
  31687. * @param onSuccess defines the callback called when the script is loaded
  31688. * @param onError defines the callback to call if an error occurs
  31689. * @param scriptId defines the id of the script element
  31690. */
  31691. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31692. /**
  31693. * Load an asynchronous script (identified by an url). When the url returns, the
  31694. * content of this file is added into a new script element, attached to the DOM (body element)
  31695. * @param scriptUrl defines the url of the script to laod
  31696. * @param scriptId defines the id of the script element
  31697. * @returns a promise request object
  31698. */
  31699. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31700. /**
  31701. * Loads a file from a blob
  31702. * @param fileToLoad defines the blob to use
  31703. * @param callback defines the callback to call when data is loaded
  31704. * @param progressCallback defines the callback to call during loading process
  31705. * @returns a file request object
  31706. */
  31707. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31708. /**
  31709. * Loads a file
  31710. * @param fileToLoad defines the file to load
  31711. * @param callback defines the callback to call when data is loaded
  31712. * @param progressCallBack defines the callback to call during loading process
  31713. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31714. * @returns a file request object
  31715. */
  31716. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31717. /**
  31718. * Creates a data url from a given string content
  31719. * @param content defines the content to convert
  31720. * @returns the new data url link
  31721. */
  31722. static FileAsURL(content: string): string;
  31723. /**
  31724. * Format the given number to a specific decimal format
  31725. * @param value defines the number to format
  31726. * @param decimals defines the number of decimals to use
  31727. * @returns the formatted string
  31728. */
  31729. static Format(value: number, decimals?: number): string;
  31730. /**
  31731. * Checks if a given vector is inside a specific range
  31732. * @param v defines the vector to test
  31733. * @param min defines the minimum range
  31734. * @param max defines the maximum range
  31735. */
  31736. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31737. /**
  31738. * Tries to copy an object by duplicating every property
  31739. * @param source defines the source object
  31740. * @param destination defines the target object
  31741. * @param doNotCopyList defines a list of properties to avoid
  31742. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31743. */
  31744. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31745. /**
  31746. * Gets a boolean indicating if the given object has no own property
  31747. * @param obj defines the object to test
  31748. * @returns true if object has no own property
  31749. */
  31750. static IsEmpty(obj: any): boolean;
  31751. /**
  31752. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31753. * @param str Source string
  31754. * @param suffix Suffix to search for in the source string
  31755. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31756. */
  31757. static EndsWith(str: string, suffix: string): boolean;
  31758. /**
  31759. * Function used to register events at window level
  31760. * @param events defines the events to register
  31761. */
  31762. static RegisterTopRootEvents(events: {
  31763. name: string;
  31764. handler: Nullable<(e: FocusEvent) => any>;
  31765. }[]): void;
  31766. /**
  31767. * Function used to unregister events from window level
  31768. * @param events defines the events to unregister
  31769. */
  31770. static UnregisterTopRootEvents(events: {
  31771. name: string;
  31772. handler: Nullable<(e: FocusEvent) => any>;
  31773. }[]): void;
  31774. /**
  31775. * @ignore
  31776. */
  31777. static _ScreenshotCanvas: HTMLCanvasElement;
  31778. /**
  31779. * Dumps the current bound framebuffer
  31780. * @param width defines the rendering width
  31781. * @param height defines the rendering height
  31782. * @param engine defines the hosting engine
  31783. * @param successCallback defines the callback triggered once the data are available
  31784. * @param mimeType defines the mime type of the result
  31785. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31786. */
  31787. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31788. /**
  31789. * Converts the canvas data to blob.
  31790. * This acts as a polyfill for browsers not supporting the to blob function.
  31791. * @param canvas Defines the canvas to extract the data from
  31792. * @param successCallback Defines the callback triggered once the data are available
  31793. * @param mimeType Defines the mime type of the result
  31794. */
  31795. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31796. /**
  31797. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31798. * @param successCallback defines the callback triggered once the data are available
  31799. * @param mimeType defines the mime type of the result
  31800. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31801. */
  31802. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31803. /**
  31804. * Downloads a blob in the browser
  31805. * @param blob defines the blob to download
  31806. * @param fileName defines the name of the downloaded file
  31807. */
  31808. static Download(blob: Blob, fileName: string): void;
  31809. /**
  31810. * Captures a screenshot of the current rendering
  31811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31812. * @param engine defines the rendering engine
  31813. * @param camera defines the source camera
  31814. * @param size This parameter can be set to a single number or to an object with the
  31815. * following (optional) properties: precision, width, height. If a single number is passed,
  31816. * it will be used for both width and height. If an object is passed, the screenshot size
  31817. * will be derived from the parameters. The precision property is a multiplier allowing
  31818. * rendering at a higher or lower resolution
  31819. * @param successCallback defines the callback receives a single parameter which contains the
  31820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31821. * src parameter of an <img> to display it
  31822. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31823. * Check your browser for supported MIME types
  31824. */
  31825. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31826. /**
  31827. * Generates an image screenshot from the specified camera.
  31828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31829. * @param engine The engine to use for rendering
  31830. * @param camera The camera to use for rendering
  31831. * @param size This parameter can be set to a single number or to an object with the
  31832. * following (optional) properties: precision, width, height. If a single number is passed,
  31833. * it will be used for both width and height. If an object is passed, the screenshot size
  31834. * will be derived from the parameters. The precision property is a multiplier allowing
  31835. * rendering at a higher or lower resolution
  31836. * @param successCallback The callback receives a single parameter which contains the
  31837. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31838. * src parameter of an <img> to display it
  31839. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31840. * Check your browser for supported MIME types
  31841. * @param samples Texture samples (default: 1)
  31842. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31843. * @param fileName A name for for the downloaded file.
  31844. */
  31845. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31846. /**
  31847. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31848. * Be aware Math.random() could cause collisions, but:
  31849. * "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"
  31850. * @returns a pseudo random id
  31851. */
  31852. static RandomId(): string;
  31853. /**
  31854. * Test if the given uri is a base64 string
  31855. * @param uri The uri to test
  31856. * @return True if the uri is a base64 string or false otherwise
  31857. */
  31858. static IsBase64(uri: string): boolean;
  31859. /**
  31860. * Decode the given base64 uri.
  31861. * @param uri The uri to decode
  31862. * @return The decoded base64 data.
  31863. */
  31864. static DecodeBase64(uri: string): ArrayBuffer;
  31865. /**
  31866. * No log
  31867. */
  31868. static readonly NoneLogLevel: number;
  31869. /**
  31870. * Only message logs
  31871. */
  31872. static readonly MessageLogLevel: number;
  31873. /**
  31874. * Only warning logs
  31875. */
  31876. static readonly WarningLogLevel: number;
  31877. /**
  31878. * Only error logs
  31879. */
  31880. static readonly ErrorLogLevel: number;
  31881. /**
  31882. * All logs
  31883. */
  31884. static readonly AllLogLevel: number;
  31885. /**
  31886. * Gets a value indicating the number of loading errors
  31887. * @ignorenaming
  31888. */
  31889. static readonly errorsCount: number;
  31890. /**
  31891. * Callback called when a new log is added
  31892. */
  31893. static OnNewCacheEntry: (entry: string) => void;
  31894. /**
  31895. * Log a message to the console
  31896. * @param message defines the message to log
  31897. */
  31898. static Log(message: string): void;
  31899. /**
  31900. * Write a warning message to the console
  31901. * @param message defines the message to log
  31902. */
  31903. static Warn(message: string): void;
  31904. /**
  31905. * Write an error message to the console
  31906. * @param message defines the message to log
  31907. */
  31908. static Error(message: string): void;
  31909. /**
  31910. * Gets current log cache (list of logs)
  31911. */
  31912. static readonly LogCache: string;
  31913. /**
  31914. * Clears the log cache
  31915. */
  31916. static ClearLogCache(): void;
  31917. /**
  31918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31919. */
  31920. static LogLevels: number;
  31921. /**
  31922. * Checks if the loaded document was accessed via `file:`-Protocol.
  31923. * @returns boolean
  31924. */
  31925. static IsFileURL(): boolean;
  31926. /**
  31927. * Checks if the window object exists
  31928. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31929. */
  31930. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31931. /**
  31932. * No performance log
  31933. */
  31934. static readonly PerformanceNoneLogLevel: number;
  31935. /**
  31936. * Use user marks to log performance
  31937. */
  31938. static readonly PerformanceUserMarkLogLevel: number;
  31939. /**
  31940. * Log performance to the console
  31941. */
  31942. static readonly PerformanceConsoleLogLevel: number;
  31943. private static _performance;
  31944. /**
  31945. * Sets the current performance log level
  31946. */
  31947. static PerformanceLogLevel: number;
  31948. private static _StartPerformanceCounterDisabled;
  31949. private static _EndPerformanceCounterDisabled;
  31950. private static _StartUserMark;
  31951. private static _EndUserMark;
  31952. private static _StartPerformanceConsole;
  31953. private static _EndPerformanceConsole;
  31954. /**
  31955. * Starts a performance counter
  31956. */
  31957. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31958. /**
  31959. * Ends a specific performance coutner
  31960. */
  31961. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31962. /**
  31963. * Gets either window.performance.now() if supported or Date.now() else
  31964. */
  31965. static readonly Now: number;
  31966. /**
  31967. * This method will return the name of the class used to create the instance of the given object.
  31968. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31969. * @param object the object to get the class name from
  31970. * @param isType defines if the object is actually a type
  31971. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31972. */
  31973. static GetClassName(object: any, isType?: boolean): string;
  31974. /**
  31975. * Gets the first element of an array satisfying a given predicate
  31976. * @param array defines the array to browse
  31977. * @param predicate defines the predicate to use
  31978. * @returns null if not found or the element
  31979. */
  31980. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31981. /**
  31982. * This method will return the name of the full name of the class, including its owning module (if any).
  31983. * 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).
  31984. * @param object the object to get the class name from
  31985. * @param isType defines if the object is actually a type
  31986. * @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.
  31987. * @ignorenaming
  31988. */
  31989. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31990. /**
  31991. * Returns a promise that resolves after the given amount of time.
  31992. * @param delay Number of milliseconds to delay
  31993. * @returns Promise that resolves after the given amount of time
  31994. */
  31995. static DelayAsync(delay: number): Promise<void>;
  31996. /**
  31997. * Gets the current gradient from an array of IValueGradient
  31998. * @param ratio defines the current ratio to get
  31999. * @param gradients defines the array of IValueGradient
  32000. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32001. */
  32002. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32003. }
  32004. /**
  32005. * This class is used to track a performance counter which is number based.
  32006. * The user has access to many properties which give statistics of different nature.
  32007. *
  32008. * The implementer can track two kinds of Performance Counter: time and count.
  32009. * 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.
  32010. * 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.
  32011. */
  32012. export class PerfCounter {
  32013. /**
  32014. * Gets or sets a global boolean to turn on and off all the counters
  32015. */
  32016. static Enabled: boolean;
  32017. /**
  32018. * Returns the smallest value ever
  32019. */
  32020. readonly min: number;
  32021. /**
  32022. * Returns the biggest value ever
  32023. */
  32024. readonly max: number;
  32025. /**
  32026. * Returns the average value since the performance counter is running
  32027. */
  32028. readonly average: number;
  32029. /**
  32030. * Returns the average value of the last second the counter was monitored
  32031. */
  32032. readonly lastSecAverage: number;
  32033. /**
  32034. * Returns the current value
  32035. */
  32036. readonly current: number;
  32037. /**
  32038. * Gets the accumulated total
  32039. */
  32040. readonly total: number;
  32041. /**
  32042. * Gets the total value count
  32043. */
  32044. readonly count: number;
  32045. /**
  32046. * Creates a new counter
  32047. */
  32048. constructor();
  32049. /**
  32050. * Call this method to start monitoring a new frame.
  32051. * 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.
  32052. */
  32053. fetchNewFrame(): void;
  32054. /**
  32055. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32056. * @param newCount the count value to add to the monitored count
  32057. * @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.
  32058. */
  32059. addCount(newCount: number, fetchResult: boolean): void;
  32060. /**
  32061. * Start monitoring this performance counter
  32062. */
  32063. beginMonitoring(): void;
  32064. /**
  32065. * Compute the time lapsed since the previous beginMonitoring() call.
  32066. * @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
  32067. */
  32068. endMonitoring(newFrame?: boolean): void;
  32069. private _fetchResult;
  32070. private _startMonitoringTime;
  32071. private _min;
  32072. private _max;
  32073. private _average;
  32074. private _current;
  32075. private _totalValueCount;
  32076. private _totalAccumulated;
  32077. private _lastSecAverage;
  32078. private _lastSecAccumulated;
  32079. private _lastSecTime;
  32080. private _lastSecValueCount;
  32081. }
  32082. /**
  32083. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32084. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32085. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32086. * @param name The name of the class, case should be preserved
  32087. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32088. */
  32089. export function className(name: string, module?: string): (target: Object) => void;
  32090. /**
  32091. * An implementation of a loop for asynchronous functions.
  32092. */
  32093. export class AsyncLoop {
  32094. /**
  32095. * Defines the number of iterations for the loop
  32096. */
  32097. iterations: number;
  32098. /**
  32099. * Defines the current index of the loop.
  32100. */
  32101. index: number;
  32102. private _done;
  32103. private _fn;
  32104. private _successCallback;
  32105. /**
  32106. * Constructor.
  32107. * @param iterations the number of iterations.
  32108. * @param func the function to run each iteration
  32109. * @param successCallback the callback that will be called upon succesful execution
  32110. * @param offset starting offset.
  32111. */
  32112. constructor(
  32113. /**
  32114. * Defines the number of iterations for the loop
  32115. */
  32116. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32117. /**
  32118. * Execute the next iteration. Must be called after the last iteration was finished.
  32119. */
  32120. executeNext(): void;
  32121. /**
  32122. * Break the loop and run the success callback.
  32123. */
  32124. breakLoop(): void;
  32125. /**
  32126. * Create and run an async loop.
  32127. * @param iterations the number of iterations.
  32128. * @param fn the function to run each iteration
  32129. * @param successCallback the callback that will be called upon succesful execution
  32130. * @param offset starting offset.
  32131. * @returns the created async loop object
  32132. */
  32133. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32134. /**
  32135. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32136. * @param iterations total number of iterations
  32137. * @param syncedIterations number of synchronous iterations in each async iteration.
  32138. * @param fn the function to call each iteration.
  32139. * @param callback a success call back that will be called when iterating stops.
  32140. * @param breakFunction a break condition (optional)
  32141. * @param timeout timeout settings for the setTimeout function. default - 0.
  32142. * @returns the created async loop object
  32143. */
  32144. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32145. }
  32146. }
  32147. declare module "babylonjs/Collisions/collisionCoordinator" {
  32148. import { Nullable } from "babylonjs/types";
  32149. import { Scene } from "babylonjs/scene";
  32150. import { Vector3 } from "babylonjs/Maths/math";
  32151. import { Collider } from "babylonjs/Collisions/collider";
  32152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32153. /** @hidden */
  32154. export interface ICollisionCoordinator {
  32155. createCollider(): Collider;
  32156. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32157. init(scene: Scene): void;
  32158. }
  32159. /** @hidden */
  32160. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32161. private _scene;
  32162. private _scaledPosition;
  32163. private _scaledVelocity;
  32164. private _finalPosition;
  32165. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32166. createCollider(): Collider;
  32167. init(scene: Scene): void;
  32168. private _collideWithWorld;
  32169. }
  32170. }
  32171. declare module "babylonjs/Animations/animationGroup" {
  32172. import { Animatable } from "babylonjs/Animations/animatable";
  32173. import { Animation } from "babylonjs/Animations/animation";
  32174. import { Scene, IDisposable } from "babylonjs/scene";
  32175. import { Observable } from "babylonjs/Misc/observable";
  32176. import { Nullable } from "babylonjs/types";
  32177. /**
  32178. * This class defines the direct association between an animation and a target
  32179. */
  32180. export class TargetedAnimation {
  32181. /**
  32182. * Animation to perform
  32183. */
  32184. animation: Animation;
  32185. /**
  32186. * Target to animate
  32187. */
  32188. target: any;
  32189. }
  32190. /**
  32191. * Use this class to create coordinated animations on multiple targets
  32192. */
  32193. export class AnimationGroup implements IDisposable {
  32194. /** The name of the animation group */
  32195. name: string;
  32196. private _scene;
  32197. private _targetedAnimations;
  32198. private _animatables;
  32199. private _from;
  32200. private _to;
  32201. private _isStarted;
  32202. private _isPaused;
  32203. private _speedRatio;
  32204. /**
  32205. * Gets or sets the unique id of the node
  32206. */
  32207. uniqueId: number;
  32208. /**
  32209. * This observable will notify when one animation have ended
  32210. */
  32211. onAnimationEndObservable: Observable<TargetedAnimation>;
  32212. /**
  32213. * Observer raised when one animation loops
  32214. */
  32215. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32216. /**
  32217. * This observable will notify when all animations have ended.
  32218. */
  32219. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32220. /**
  32221. * This observable will notify when all animations have paused.
  32222. */
  32223. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32224. /**
  32225. * This observable will notify when all animations are playing.
  32226. */
  32227. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32228. /**
  32229. * Gets the first frame
  32230. */
  32231. readonly from: number;
  32232. /**
  32233. * Gets the last frame
  32234. */
  32235. readonly to: number;
  32236. /**
  32237. * Define if the animations are started
  32238. */
  32239. readonly isStarted: boolean;
  32240. /**
  32241. * Gets a value indicating that the current group is playing
  32242. */
  32243. readonly isPlaying: boolean;
  32244. /**
  32245. * Gets or sets the speed ratio to use for all animations
  32246. */
  32247. /**
  32248. * Gets or sets the speed ratio to use for all animations
  32249. */
  32250. speedRatio: number;
  32251. /**
  32252. * Gets the targeted animations for this animation group
  32253. */
  32254. readonly targetedAnimations: Array<TargetedAnimation>;
  32255. /**
  32256. * returning the list of animatables controlled by this animation group.
  32257. */
  32258. readonly animatables: Array<Animatable>;
  32259. /**
  32260. * Instantiates a new Animation Group.
  32261. * This helps managing several animations at once.
  32262. * @see http://doc.babylonjs.com/how_to/group
  32263. * @param name Defines the name of the group
  32264. * @param scene Defines the scene the group belongs to
  32265. */
  32266. constructor(
  32267. /** The name of the animation group */
  32268. name: string, scene?: Nullable<Scene>);
  32269. /**
  32270. * Add an animation (with its target) in the group
  32271. * @param animation defines the animation we want to add
  32272. * @param target defines the target of the animation
  32273. * @returns the TargetedAnimation object
  32274. */
  32275. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32276. /**
  32277. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32278. * It can add constant keys at begin or end
  32279. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32280. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32281. * @returns the animation group
  32282. */
  32283. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32284. /**
  32285. * Start all animations on given targets
  32286. * @param loop defines if animations must loop
  32287. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32288. * @param from defines the from key (optional)
  32289. * @param to defines the to key (optional)
  32290. * @returns the current animation group
  32291. */
  32292. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32293. /**
  32294. * Pause all animations
  32295. * @returns the animation group
  32296. */
  32297. pause(): AnimationGroup;
  32298. /**
  32299. * Play all animations to initial state
  32300. * This function will start() the animations if they were not started or will restart() them if they were paused
  32301. * @param loop defines if animations must loop
  32302. * @returns the animation group
  32303. */
  32304. play(loop?: boolean): AnimationGroup;
  32305. /**
  32306. * Reset all animations to initial state
  32307. * @returns the animation group
  32308. */
  32309. reset(): AnimationGroup;
  32310. /**
  32311. * Restart animations from key 0
  32312. * @returns the animation group
  32313. */
  32314. restart(): AnimationGroup;
  32315. /**
  32316. * Stop all animations
  32317. * @returns the animation group
  32318. */
  32319. stop(): AnimationGroup;
  32320. /**
  32321. * Set animation weight for all animatables
  32322. * @param weight defines the weight to use
  32323. * @return the animationGroup
  32324. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32325. */
  32326. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32327. /**
  32328. * Synchronize and normalize all animatables with a source animatable
  32329. * @param root defines the root animatable to synchronize with
  32330. * @return the animationGroup
  32331. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32332. */
  32333. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32334. /**
  32335. * Goes to a specific frame in this animation group
  32336. * @param frame the frame number to go to
  32337. * @return the animationGroup
  32338. */
  32339. goToFrame(frame: number): AnimationGroup;
  32340. /**
  32341. * Dispose all associated resources
  32342. */
  32343. dispose(): void;
  32344. private _checkAnimationGroupEnded;
  32345. /**
  32346. * Clone the current animation group and returns a copy
  32347. * @param newName defines the name of the new group
  32348. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32349. * @returns the new aniamtion group
  32350. */
  32351. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32352. /**
  32353. * Returns a new AnimationGroup object parsed from the source provided.
  32354. * @param parsedAnimationGroup defines the source
  32355. * @param scene defines the scene that will receive the animationGroup
  32356. * @returns a new AnimationGroup
  32357. */
  32358. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32359. /**
  32360. * Returns the string "AnimationGroup"
  32361. * @returns "AnimationGroup"
  32362. */
  32363. getClassName(): string;
  32364. /**
  32365. * Creates a detailled string about the object
  32366. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32367. * @returns a string representing the object
  32368. */
  32369. toString(fullDetails?: boolean): string;
  32370. }
  32371. }
  32372. declare module "babylonjs/scene" {
  32373. import { Nullable } from "babylonjs/types";
  32374. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32375. import { Observable } from "babylonjs/Misc/observable";
  32376. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32377. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32378. import { Geometry } from "babylonjs/Meshes/geometry";
  32379. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32382. import { Mesh } from "babylonjs/Meshes/mesh";
  32383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32384. import { Bone } from "babylonjs/Bones/bone";
  32385. import { Skeleton } from "babylonjs/Bones/skeleton";
  32386. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32387. import { Camera } from "babylonjs/Cameras/camera";
  32388. import { AbstractScene } from "babylonjs/abstractScene";
  32389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32391. import { Material } from "babylonjs/Materials/material";
  32392. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32393. import { Effect } from "babylonjs/Materials/effect";
  32394. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32395. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32396. import { Light } from "babylonjs/Lights/light";
  32397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32398. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32399. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32400. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32402. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32403. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32404. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32405. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32406. import { Engine } from "babylonjs/Engines/engine";
  32407. import { Node } from "babylonjs/node";
  32408. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32409. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32410. import { WebRequest } from "babylonjs/Misc/webRequest";
  32411. import { Ray } from "babylonjs/Culling/ray";
  32412. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32413. import { Animation } from "babylonjs/Animations/animation";
  32414. import { Animatable } from "babylonjs/Animations/animatable";
  32415. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32416. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32417. import { Collider } from "babylonjs/Collisions/collider";
  32418. /**
  32419. * Define an interface for all classes that will hold resources
  32420. */
  32421. export interface IDisposable {
  32422. /**
  32423. * Releases all held resources
  32424. */
  32425. dispose(): void;
  32426. }
  32427. /** Interface defining initialization parameters for Scene class */
  32428. export interface SceneOptions {
  32429. /**
  32430. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32431. * It will improve performance when the number of geometries becomes important.
  32432. */
  32433. useGeometryUniqueIdsMap?: boolean;
  32434. /**
  32435. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32436. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32437. */
  32438. useMaterialMeshMap?: boolean;
  32439. /**
  32440. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32441. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32442. */
  32443. useClonedMeshhMap?: boolean;
  32444. }
  32445. /**
  32446. * Represents a scene to be rendered by the engine.
  32447. * @see http://doc.babylonjs.com/features/scene
  32448. */
  32449. export class Scene extends AbstractScene implements IAnimatable {
  32450. private static _uniqueIdCounter;
  32451. /** The fog is deactivated */
  32452. static readonly FOGMODE_NONE: number;
  32453. /** The fog density is following an exponential function */
  32454. static readonly FOGMODE_EXP: number;
  32455. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32456. static readonly FOGMODE_EXP2: number;
  32457. /** The fog density is following a linear function. */
  32458. static readonly FOGMODE_LINEAR: number;
  32459. /**
  32460. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32462. */
  32463. static MinDeltaTime: number;
  32464. /**
  32465. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32467. */
  32468. static MaxDeltaTime: number;
  32469. /**
  32470. * Factory used to create the default material.
  32471. * @param name The name of the material to create
  32472. * @param scene The scene to create the material for
  32473. * @returns The default material
  32474. */
  32475. static DefaultMaterialFactory(scene: Scene): Material;
  32476. /**
  32477. * Factory used to create the a collision coordinator.
  32478. * @returns The collision coordinator
  32479. */
  32480. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32481. /** @hidden */
  32482. readonly _isScene: boolean;
  32483. /**
  32484. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32485. */
  32486. autoClear: boolean;
  32487. /**
  32488. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32489. */
  32490. autoClearDepthAndStencil: boolean;
  32491. /**
  32492. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32493. */
  32494. clearColor: Color4;
  32495. /**
  32496. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32497. */
  32498. ambientColor: Color3;
  32499. /**
  32500. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32501. * It should only be one of the following (if not the default embedded one):
  32502. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32503. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32504. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32505. * The material properties need to be setup according to the type of texture in use.
  32506. */
  32507. environmentBRDFTexture: BaseTexture;
  32508. /** @hidden */
  32509. protected _environmentTexture: Nullable<BaseTexture>;
  32510. /**
  32511. * Texture used in all pbr material as the reflection texture.
  32512. * As in the majority of the scene they are the same (exception for multi room and so on),
  32513. * this is easier to reference from here than from all the materials.
  32514. */
  32515. /**
  32516. * Texture used in all pbr material as the reflection texture.
  32517. * As in the majority of the scene they are the same (exception for multi room and so on),
  32518. * this is easier to set here than in all the materials.
  32519. */
  32520. environmentTexture: Nullable<BaseTexture>;
  32521. /** @hidden */
  32522. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32523. /**
  32524. * Default image processing configuration used either in the rendering
  32525. * Forward main pass or through the imageProcessingPostProcess if present.
  32526. * As in the majority of the scene they are the same (exception for multi camera),
  32527. * this is easier to reference from here than from all the materials and post process.
  32528. *
  32529. * No setter as we it is a shared configuration, you can set the values instead.
  32530. */
  32531. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32532. private _forceWireframe;
  32533. /**
  32534. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32535. */
  32536. forceWireframe: boolean;
  32537. private _forcePointsCloud;
  32538. /**
  32539. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32540. */
  32541. forcePointsCloud: boolean;
  32542. /**
  32543. * Gets or sets the active clipplane 1
  32544. */
  32545. clipPlane: Nullable<Plane>;
  32546. /**
  32547. * Gets or sets the active clipplane 2
  32548. */
  32549. clipPlane2: Nullable<Plane>;
  32550. /**
  32551. * Gets or sets the active clipplane 3
  32552. */
  32553. clipPlane3: Nullable<Plane>;
  32554. /**
  32555. * Gets or sets the active clipplane 4
  32556. */
  32557. clipPlane4: Nullable<Plane>;
  32558. /**
  32559. * Gets or sets a boolean indicating if animations are enabled
  32560. */
  32561. animationsEnabled: boolean;
  32562. private _animationPropertiesOverride;
  32563. /**
  32564. * Gets or sets the animation properties override
  32565. */
  32566. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32567. /**
  32568. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32569. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32570. */
  32571. useConstantAnimationDeltaTime: boolean;
  32572. /**
  32573. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32574. * Please note that it requires to run a ray cast through the scene on every frame
  32575. */
  32576. constantlyUpdateMeshUnderPointer: boolean;
  32577. /**
  32578. * Defines the HTML cursor to use when hovering over interactive elements
  32579. */
  32580. hoverCursor: string;
  32581. /**
  32582. * Defines the HTML default cursor to use (empty by default)
  32583. */
  32584. defaultCursor: string;
  32585. /**
  32586. * This is used to call preventDefault() on pointer down
  32587. * in order to block unwanted artifacts like system double clicks
  32588. */
  32589. preventDefaultOnPointerDown: boolean;
  32590. /**
  32591. * This is used to call preventDefault() on pointer up
  32592. * in order to block unwanted artifacts like system double clicks
  32593. */
  32594. preventDefaultOnPointerUp: boolean;
  32595. /**
  32596. * Gets or sets user defined metadata
  32597. */
  32598. metadata: any;
  32599. /**
  32600. * For internal use only. Please do not use.
  32601. */
  32602. reservedDataStore: any;
  32603. /**
  32604. * Gets the name of the plugin used to load this scene (null by default)
  32605. */
  32606. loadingPluginName: string;
  32607. /**
  32608. * Use this array to add regular expressions used to disable offline support for specific urls
  32609. */
  32610. disableOfflineSupportExceptionRules: RegExp[];
  32611. /**
  32612. * An event triggered when the scene is disposed.
  32613. */
  32614. onDisposeObservable: Observable<Scene>;
  32615. private _onDisposeObserver;
  32616. /** Sets a function to be executed when this scene is disposed. */
  32617. onDispose: () => void;
  32618. /**
  32619. * An event triggered before rendering the scene (right after animations and physics)
  32620. */
  32621. onBeforeRenderObservable: Observable<Scene>;
  32622. private _onBeforeRenderObserver;
  32623. /** Sets a function to be executed before rendering this scene */
  32624. beforeRender: Nullable<() => void>;
  32625. /**
  32626. * An event triggered after rendering the scene
  32627. */
  32628. onAfterRenderObservable: Observable<Scene>;
  32629. private _onAfterRenderObserver;
  32630. /** Sets a function to be executed after rendering this scene */
  32631. afterRender: Nullable<() => void>;
  32632. /**
  32633. * An event triggered before animating the scene
  32634. */
  32635. onBeforeAnimationsObservable: Observable<Scene>;
  32636. /**
  32637. * An event triggered after animations processing
  32638. */
  32639. onAfterAnimationsObservable: Observable<Scene>;
  32640. /**
  32641. * An event triggered before draw calls are ready to be sent
  32642. */
  32643. onBeforeDrawPhaseObservable: Observable<Scene>;
  32644. /**
  32645. * An event triggered after draw calls have been sent
  32646. */
  32647. onAfterDrawPhaseObservable: Observable<Scene>;
  32648. /**
  32649. * An event triggered when the scene is ready
  32650. */
  32651. onReadyObservable: Observable<Scene>;
  32652. /**
  32653. * An event triggered before rendering a camera
  32654. */
  32655. onBeforeCameraRenderObservable: Observable<Camera>;
  32656. private _onBeforeCameraRenderObserver;
  32657. /** Sets a function to be executed before rendering a camera*/
  32658. beforeCameraRender: () => void;
  32659. /**
  32660. * An event triggered after rendering a camera
  32661. */
  32662. onAfterCameraRenderObservable: Observable<Camera>;
  32663. private _onAfterCameraRenderObserver;
  32664. /** Sets a function to be executed after rendering a camera*/
  32665. afterCameraRender: () => void;
  32666. /**
  32667. * An event triggered when active meshes evaluation is about to start
  32668. */
  32669. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32670. /**
  32671. * An event triggered when active meshes evaluation is done
  32672. */
  32673. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32674. /**
  32675. * An event triggered when particles rendering is about to start
  32676. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32677. */
  32678. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32679. /**
  32680. * An event triggered when particles rendering is done
  32681. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32682. */
  32683. onAfterParticlesRenderingObservable: Observable<Scene>;
  32684. /**
  32685. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32686. */
  32687. onDataLoadedObservable: Observable<Scene>;
  32688. /**
  32689. * An event triggered when a camera is created
  32690. */
  32691. onNewCameraAddedObservable: Observable<Camera>;
  32692. /**
  32693. * An event triggered when a camera is removed
  32694. */
  32695. onCameraRemovedObservable: Observable<Camera>;
  32696. /**
  32697. * An event triggered when a light is created
  32698. */
  32699. onNewLightAddedObservable: Observable<Light>;
  32700. /**
  32701. * An event triggered when a light is removed
  32702. */
  32703. onLightRemovedObservable: Observable<Light>;
  32704. /**
  32705. * An event triggered when a geometry is created
  32706. */
  32707. onNewGeometryAddedObservable: Observable<Geometry>;
  32708. /**
  32709. * An event triggered when a geometry is removed
  32710. */
  32711. onGeometryRemovedObservable: Observable<Geometry>;
  32712. /**
  32713. * An event triggered when a transform node is created
  32714. */
  32715. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32716. /**
  32717. * An event triggered when a transform node is removed
  32718. */
  32719. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32720. /**
  32721. * An event triggered when a mesh is created
  32722. */
  32723. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32724. /**
  32725. * An event triggered when a mesh is removed
  32726. */
  32727. onMeshRemovedObservable: Observable<AbstractMesh>;
  32728. /**
  32729. * An event triggered when a skeleton is created
  32730. */
  32731. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32732. /**
  32733. * An event triggered when a skeleton is removed
  32734. */
  32735. onSkeletonRemovedObservable: Observable<Skeleton>;
  32736. /**
  32737. * An event triggered when a material is created
  32738. */
  32739. onNewMaterialAddedObservable: Observable<Material>;
  32740. /**
  32741. * An event triggered when a material is removed
  32742. */
  32743. onMaterialRemovedObservable: Observable<Material>;
  32744. /**
  32745. * An event triggered when a texture is created
  32746. */
  32747. onNewTextureAddedObservable: Observable<BaseTexture>;
  32748. /**
  32749. * An event triggered when a texture is removed
  32750. */
  32751. onTextureRemovedObservable: Observable<BaseTexture>;
  32752. /**
  32753. * An event triggered when render targets are about to be rendered
  32754. * Can happen multiple times per frame.
  32755. */
  32756. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32757. /**
  32758. * An event triggered when render targets were rendered.
  32759. * Can happen multiple times per frame.
  32760. */
  32761. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32762. /**
  32763. * An event triggered before calculating deterministic simulation step
  32764. */
  32765. onBeforeStepObservable: Observable<Scene>;
  32766. /**
  32767. * An event triggered after calculating deterministic simulation step
  32768. */
  32769. onAfterStepObservable: Observable<Scene>;
  32770. /**
  32771. * An event triggered when the activeCamera property is updated
  32772. */
  32773. onActiveCameraChanged: Observable<Scene>;
  32774. /**
  32775. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32776. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32777. * 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)
  32778. */
  32779. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32780. /**
  32781. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32782. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32783. * 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)
  32784. */
  32785. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32786. /**
  32787. * This Observable will when a mesh has been imported into the scene.
  32788. */
  32789. onMeshImportedObservable: Observable<AbstractMesh>;
  32790. /**
  32791. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32792. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32793. */
  32794. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32795. /** @hidden */
  32796. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32797. /**
  32798. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32799. */
  32800. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32801. /**
  32802. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32803. */
  32804. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32805. /**
  32806. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32807. */
  32808. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32809. private _onPointerMove;
  32810. private _onPointerDown;
  32811. private _onPointerUp;
  32812. /** Callback called when a pointer move is detected */
  32813. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32814. /** Callback called when a pointer down is detected */
  32815. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32816. /** Callback called when a pointer up is detected */
  32817. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32818. /** Callback called when a pointer pick is detected */
  32819. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32820. /**
  32821. * 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).
  32822. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32823. */
  32824. onPrePointerObservable: Observable<PointerInfoPre>;
  32825. /**
  32826. * Observable event triggered each time an input event is received from the rendering canvas
  32827. */
  32828. onPointerObservable: Observable<PointerInfo>;
  32829. /**
  32830. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32831. */
  32832. readonly unTranslatedPointer: Vector2;
  32833. /** The distance in pixel that you have to move to prevent some events */
  32834. static DragMovementThreshold: number;
  32835. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32836. static LongPressDelay: number;
  32837. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32838. static DoubleClickDelay: number;
  32839. /** If you need to check double click without raising a single click at first click, enable this flag */
  32840. static ExclusiveDoubleClickMode: boolean;
  32841. private _initClickEvent;
  32842. private _initActionManager;
  32843. private _delayedSimpleClick;
  32844. private _delayedSimpleClickTimeout;
  32845. private _previousDelayedSimpleClickTimeout;
  32846. private _meshPickProceed;
  32847. private _previousButtonPressed;
  32848. private _currentPickResult;
  32849. private _previousPickResult;
  32850. private _totalPointersPressed;
  32851. private _doubleClickOccured;
  32852. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32853. cameraToUseForPointers: Nullable<Camera>;
  32854. private _pointerX;
  32855. private _pointerY;
  32856. private _unTranslatedPointerX;
  32857. private _unTranslatedPointerY;
  32858. private _startingPointerPosition;
  32859. private _previousStartingPointerPosition;
  32860. private _startingPointerTime;
  32861. private _previousStartingPointerTime;
  32862. private _pointerCaptures;
  32863. private _timeAccumulator;
  32864. private _currentStepId;
  32865. private _currentInternalStep;
  32866. /** @hidden */
  32867. _mirroredCameraPosition: Nullable<Vector3>;
  32868. /**
  32869. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32870. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32871. */
  32872. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32873. /**
  32874. * Observable event triggered each time an keyboard event is received from the hosting window
  32875. */
  32876. onKeyboardObservable: Observable<KeyboardInfo>;
  32877. private _onKeyDown;
  32878. private _onKeyUp;
  32879. private _onCanvasFocusObserver;
  32880. private _onCanvasBlurObserver;
  32881. private _useRightHandedSystem;
  32882. /**
  32883. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32884. */
  32885. useRightHandedSystem: boolean;
  32886. /**
  32887. * Sets the step Id used by deterministic lock step
  32888. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32889. * @param newStepId defines the step Id
  32890. */
  32891. setStepId(newStepId: number): void;
  32892. /**
  32893. * Gets the step Id used by deterministic lock step
  32894. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32895. * @returns the step Id
  32896. */
  32897. getStepId(): number;
  32898. /**
  32899. * Gets the internal step used by deterministic lock step
  32900. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32901. * @returns the internal step
  32902. */
  32903. getInternalStep(): number;
  32904. private _fogEnabled;
  32905. /**
  32906. * Gets or sets a boolean indicating if fog is enabled on this scene
  32907. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32908. * (Default is true)
  32909. */
  32910. fogEnabled: boolean;
  32911. private _fogMode;
  32912. /**
  32913. * Gets or sets the fog mode to use
  32914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32915. * | mode | value |
  32916. * | --- | --- |
  32917. * | FOGMODE_NONE | 0 |
  32918. * | FOGMODE_EXP | 1 |
  32919. * | FOGMODE_EXP2 | 2 |
  32920. * | FOGMODE_LINEAR | 3 |
  32921. */
  32922. fogMode: number;
  32923. /**
  32924. * Gets or sets the fog color to use
  32925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32926. * (Default is Color3(0.2, 0.2, 0.3))
  32927. */
  32928. fogColor: Color3;
  32929. /**
  32930. * Gets or sets the fog density to use
  32931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32932. * (Default is 0.1)
  32933. */
  32934. fogDensity: number;
  32935. /**
  32936. * Gets or sets the fog start distance to use
  32937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32938. * (Default is 0)
  32939. */
  32940. fogStart: number;
  32941. /**
  32942. * Gets or sets the fog end distance to use
  32943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32944. * (Default is 1000)
  32945. */
  32946. fogEnd: number;
  32947. private _shadowsEnabled;
  32948. /**
  32949. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32950. */
  32951. shadowsEnabled: boolean;
  32952. private _lightsEnabled;
  32953. /**
  32954. * Gets or sets a boolean indicating if lights are enabled on this scene
  32955. */
  32956. lightsEnabled: boolean;
  32957. /** All of the active cameras added to this scene. */
  32958. activeCameras: Camera[];
  32959. /** @hidden */
  32960. _activeCamera: Nullable<Camera>;
  32961. /** Gets or sets the current active camera */
  32962. activeCamera: Nullable<Camera>;
  32963. private _defaultMaterial;
  32964. /** The default material used on meshes when no material is affected */
  32965. /** The default material used on meshes when no material is affected */
  32966. defaultMaterial: Material;
  32967. private _texturesEnabled;
  32968. /**
  32969. * Gets or sets a boolean indicating if textures are enabled on this scene
  32970. */
  32971. texturesEnabled: boolean;
  32972. /**
  32973. * Gets or sets a boolean indicating if particles are enabled on this scene
  32974. */
  32975. particlesEnabled: boolean;
  32976. /**
  32977. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32978. */
  32979. spritesEnabled: boolean;
  32980. private _skeletonsEnabled;
  32981. /**
  32982. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32983. */
  32984. skeletonsEnabled: boolean;
  32985. /**
  32986. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32987. */
  32988. lensFlaresEnabled: boolean;
  32989. /**
  32990. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32992. */
  32993. collisionsEnabled: boolean;
  32994. private _collisionCoordinator;
  32995. /** @hidden */
  32996. readonly collisionCoordinator: ICollisionCoordinator;
  32997. /**
  32998. * Defines the gravity applied to this scene (used only for collisions)
  32999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33000. */
  33001. gravity: Vector3;
  33002. /**
  33003. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33004. */
  33005. postProcessesEnabled: boolean;
  33006. /**
  33007. * The list of postprocesses added to the scene
  33008. */
  33009. postProcesses: PostProcess[];
  33010. /**
  33011. * Gets the current postprocess manager
  33012. */
  33013. postProcessManager: PostProcessManager;
  33014. /**
  33015. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33016. */
  33017. renderTargetsEnabled: boolean;
  33018. /**
  33019. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33020. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33021. */
  33022. dumpNextRenderTargets: boolean;
  33023. /**
  33024. * The list of user defined render targets added to the scene
  33025. */
  33026. customRenderTargets: RenderTargetTexture[];
  33027. /**
  33028. * Defines if texture loading must be delayed
  33029. * If true, textures will only be loaded when they need to be rendered
  33030. */
  33031. useDelayedTextureLoading: boolean;
  33032. /**
  33033. * Gets the list of meshes imported to the scene through SceneLoader
  33034. */
  33035. importedMeshesFiles: String[];
  33036. /**
  33037. * Gets or sets a boolean indicating if probes are enabled on this scene
  33038. */
  33039. probesEnabled: boolean;
  33040. /**
  33041. * Gets or sets the current offline provider to use to store scene data
  33042. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33043. */
  33044. offlineProvider: IOfflineProvider;
  33045. /**
  33046. * Gets or sets the action manager associated with the scene
  33047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33048. */
  33049. actionManager: AbstractActionManager;
  33050. private _meshesForIntersections;
  33051. /**
  33052. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33053. */
  33054. proceduralTexturesEnabled: boolean;
  33055. private _engine;
  33056. private _totalVertices;
  33057. /** @hidden */
  33058. _activeIndices: PerfCounter;
  33059. /** @hidden */
  33060. _activeParticles: PerfCounter;
  33061. /** @hidden */
  33062. _activeBones: PerfCounter;
  33063. private _animationRatio;
  33064. /** @hidden */
  33065. _animationTimeLast: number;
  33066. /** @hidden */
  33067. _animationTime: number;
  33068. /**
  33069. * Gets or sets a general scale for animation speed
  33070. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33071. */
  33072. animationTimeScale: number;
  33073. /** @hidden */
  33074. _cachedMaterial: Nullable<Material>;
  33075. /** @hidden */
  33076. _cachedEffect: Nullable<Effect>;
  33077. /** @hidden */
  33078. _cachedVisibility: Nullable<number>;
  33079. private _renderId;
  33080. private _frameId;
  33081. private _executeWhenReadyTimeoutId;
  33082. private _intermediateRendering;
  33083. private _viewUpdateFlag;
  33084. private _projectionUpdateFlag;
  33085. /** @hidden */
  33086. _toBeDisposed: Nullable<IDisposable>[];
  33087. private _activeRequests;
  33088. /** @hidden */
  33089. _pendingData: any[];
  33090. private _isDisposed;
  33091. /**
  33092. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33093. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33094. */
  33095. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33096. private _activeMeshes;
  33097. private _processedMaterials;
  33098. private _renderTargets;
  33099. /** @hidden */
  33100. _activeParticleSystems: SmartArray<IParticleSystem>;
  33101. private _activeSkeletons;
  33102. private _softwareSkinnedMeshes;
  33103. private _renderingManager;
  33104. /** @hidden */
  33105. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33106. private _transformMatrix;
  33107. private _sceneUbo;
  33108. /** @hidden */
  33109. _viewMatrix: Matrix;
  33110. private _projectionMatrix;
  33111. private _wheelEventName;
  33112. /** @hidden */
  33113. _forcedViewPosition: Nullable<Vector3>;
  33114. /** @hidden */
  33115. _frustumPlanes: Plane[];
  33116. /**
  33117. * Gets the list of frustum planes (built from the active camera)
  33118. */
  33119. readonly frustumPlanes: Plane[];
  33120. /**
  33121. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33122. * This is useful if there are more lights that the maximum simulteanous authorized
  33123. */
  33124. requireLightSorting: boolean;
  33125. /** @hidden */
  33126. readonly useMaterialMeshMap: boolean;
  33127. /** @hidden */
  33128. readonly useClonedMeshhMap: boolean;
  33129. private _pointerOverMesh;
  33130. private _pickedDownMesh;
  33131. private _pickedUpMesh;
  33132. private _externalData;
  33133. private _uid;
  33134. /**
  33135. * @hidden
  33136. * Backing store of defined scene components.
  33137. */
  33138. _components: ISceneComponent[];
  33139. /**
  33140. * @hidden
  33141. * Backing store of defined scene components.
  33142. */
  33143. _serializableComponents: ISceneSerializableComponent[];
  33144. /**
  33145. * List of components to register on the next registration step.
  33146. */
  33147. private _transientComponents;
  33148. /**
  33149. * Registers the transient components if needed.
  33150. */
  33151. private _registerTransientComponents;
  33152. /**
  33153. * @hidden
  33154. * Add a component to the scene.
  33155. * Note that the ccomponent could be registered on th next frame if this is called after
  33156. * the register component stage.
  33157. * @param component Defines the component to add to the scene
  33158. */
  33159. _addComponent(component: ISceneComponent): void;
  33160. /**
  33161. * @hidden
  33162. * Gets a component from the scene.
  33163. * @param name defines the name of the component to retrieve
  33164. * @returns the component or null if not present
  33165. */
  33166. _getComponent(name: string): Nullable<ISceneComponent>;
  33167. /**
  33168. * @hidden
  33169. * Defines the actions happening before camera updates.
  33170. */
  33171. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33172. /**
  33173. * @hidden
  33174. * Defines the actions happening before clear the canvas.
  33175. */
  33176. _beforeClearStage: Stage<SimpleStageAction>;
  33177. /**
  33178. * @hidden
  33179. * Defines the actions when collecting render targets for the frame.
  33180. */
  33181. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33182. /**
  33183. * @hidden
  33184. * Defines the actions happening for one camera in the frame.
  33185. */
  33186. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33187. /**
  33188. * @hidden
  33189. * Defines the actions happening during the per mesh ready checks.
  33190. */
  33191. _isReadyForMeshStage: Stage<MeshStageAction>;
  33192. /**
  33193. * @hidden
  33194. * Defines the actions happening before evaluate active mesh checks.
  33195. */
  33196. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33197. /**
  33198. * @hidden
  33199. * Defines the actions happening during the evaluate sub mesh checks.
  33200. */
  33201. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33202. /**
  33203. * @hidden
  33204. * Defines the actions happening during the active mesh stage.
  33205. */
  33206. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33207. /**
  33208. * @hidden
  33209. * Defines the actions happening during the per camera render target step.
  33210. */
  33211. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33212. /**
  33213. * @hidden
  33214. * Defines the actions happening just before the active camera is drawing.
  33215. */
  33216. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33217. /**
  33218. * @hidden
  33219. * Defines the actions happening just before a render target is drawing.
  33220. */
  33221. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33222. /**
  33223. * @hidden
  33224. * Defines the actions happening just before a rendering group is drawing.
  33225. */
  33226. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33227. /**
  33228. * @hidden
  33229. * Defines the actions happening just before a mesh is drawing.
  33230. */
  33231. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33232. /**
  33233. * @hidden
  33234. * Defines the actions happening just after a mesh has been drawn.
  33235. */
  33236. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33237. /**
  33238. * @hidden
  33239. * Defines the actions happening just after a rendering group has been drawn.
  33240. */
  33241. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33242. /**
  33243. * @hidden
  33244. * Defines the actions happening just after the active camera has been drawn.
  33245. */
  33246. _afterCameraDrawStage: Stage<CameraStageAction>;
  33247. /**
  33248. * @hidden
  33249. * Defines the actions happening just after a render target has been drawn.
  33250. */
  33251. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33252. /**
  33253. * @hidden
  33254. * Defines the actions happening just after rendering all cameras and computing intersections.
  33255. */
  33256. _afterRenderStage: Stage<SimpleStageAction>;
  33257. /**
  33258. * @hidden
  33259. * Defines the actions happening when a pointer move event happens.
  33260. */
  33261. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33262. /**
  33263. * @hidden
  33264. * Defines the actions happening when a pointer down event happens.
  33265. */
  33266. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33267. /**
  33268. * @hidden
  33269. * Defines the actions happening when a pointer up event happens.
  33270. */
  33271. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33272. /**
  33273. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33274. */
  33275. private geometriesByUniqueId;
  33276. /**
  33277. * Creates a new Scene
  33278. * @param engine defines the engine to use to render this scene
  33279. * @param options defines the scene options
  33280. */
  33281. constructor(engine: Engine, options?: SceneOptions);
  33282. /**
  33283. * Gets a string idenfifying the name of the class
  33284. * @returns "Scene" string
  33285. */
  33286. getClassName(): string;
  33287. private _defaultMeshCandidates;
  33288. /**
  33289. * @hidden
  33290. */
  33291. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33292. private _defaultSubMeshCandidates;
  33293. /**
  33294. * @hidden
  33295. */
  33296. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33297. /**
  33298. * Sets the default candidate providers for the scene.
  33299. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33300. * and getCollidingSubMeshCandidates to their default function
  33301. */
  33302. setDefaultCandidateProviders(): void;
  33303. /**
  33304. * Gets the mesh that is currently under the pointer
  33305. */
  33306. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33307. /**
  33308. * Gets or sets the current on-screen X position of the pointer
  33309. */
  33310. pointerX: number;
  33311. /**
  33312. * Gets or sets the current on-screen Y position of the pointer
  33313. */
  33314. pointerY: number;
  33315. /**
  33316. * Gets the cached material (ie. the latest rendered one)
  33317. * @returns the cached material
  33318. */
  33319. getCachedMaterial(): Nullable<Material>;
  33320. /**
  33321. * Gets the cached effect (ie. the latest rendered one)
  33322. * @returns the cached effect
  33323. */
  33324. getCachedEffect(): Nullable<Effect>;
  33325. /**
  33326. * Gets the cached visibility state (ie. the latest rendered one)
  33327. * @returns the cached visibility state
  33328. */
  33329. getCachedVisibility(): Nullable<number>;
  33330. /**
  33331. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33332. * @param material defines the current material
  33333. * @param effect defines the current effect
  33334. * @param visibility defines the current visibility state
  33335. * @returns true if one parameter is not cached
  33336. */
  33337. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33338. /**
  33339. * Gets the engine associated with the scene
  33340. * @returns an Engine
  33341. */
  33342. getEngine(): Engine;
  33343. /**
  33344. * Gets the total number of vertices rendered per frame
  33345. * @returns the total number of vertices rendered per frame
  33346. */
  33347. getTotalVertices(): number;
  33348. /**
  33349. * Gets the performance counter for total vertices
  33350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33351. */
  33352. readonly totalVerticesPerfCounter: PerfCounter;
  33353. /**
  33354. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33355. * @returns the total number of active indices rendered per frame
  33356. */
  33357. getActiveIndices(): number;
  33358. /**
  33359. * Gets the performance counter for active indices
  33360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33361. */
  33362. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33363. /**
  33364. * Gets the total number of active particles rendered per frame
  33365. * @returns the total number of active particles rendered per frame
  33366. */
  33367. getActiveParticles(): number;
  33368. /**
  33369. * Gets the performance counter for active particles
  33370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33371. */
  33372. readonly activeParticlesPerfCounter: PerfCounter;
  33373. /**
  33374. * Gets the total number of active bones rendered per frame
  33375. * @returns the total number of active bones rendered per frame
  33376. */
  33377. getActiveBones(): number;
  33378. /**
  33379. * Gets the performance counter for active bones
  33380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33381. */
  33382. readonly activeBonesPerfCounter: PerfCounter;
  33383. /**
  33384. * Gets the array of active meshes
  33385. * @returns an array of AbstractMesh
  33386. */
  33387. getActiveMeshes(): SmartArray<AbstractMesh>;
  33388. /**
  33389. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33390. * @returns a number
  33391. */
  33392. getAnimationRatio(): number;
  33393. /**
  33394. * Gets an unique Id for the current render phase
  33395. * @returns a number
  33396. */
  33397. getRenderId(): number;
  33398. /**
  33399. * Gets an unique Id for the current frame
  33400. * @returns a number
  33401. */
  33402. getFrameId(): number;
  33403. /** Call this function if you want to manually increment the render Id*/
  33404. incrementRenderId(): void;
  33405. private _updatePointerPosition;
  33406. private _createUbo;
  33407. private _setRayOnPointerInfo;
  33408. /**
  33409. * Use this method to simulate a pointer move on a mesh
  33410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33413. * @returns the current scene
  33414. */
  33415. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33416. private _processPointerMove;
  33417. private _checkPrePointerObservable;
  33418. /**
  33419. * Use this method to simulate a pointer down on a mesh
  33420. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33421. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33422. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33423. * @returns the current scene
  33424. */
  33425. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33426. private _processPointerDown;
  33427. /**
  33428. * Use this method to simulate a pointer up on a mesh
  33429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33432. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33433. * @returns the current scene
  33434. */
  33435. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33436. private _processPointerUp;
  33437. /**
  33438. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33439. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33440. * @returns true if the pointer was captured
  33441. */
  33442. isPointerCaptured(pointerId?: number): boolean;
  33443. /** @hidden */
  33444. _isPointerSwiping(): boolean;
  33445. /**
  33446. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33447. * @param attachUp defines if you want to attach events to pointerup
  33448. * @param attachDown defines if you want to attach events to pointerdown
  33449. * @param attachMove defines if you want to attach events to pointermove
  33450. */
  33451. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33452. /** Detaches all event handlers*/
  33453. detachControl(): void;
  33454. /**
  33455. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33456. * Delay loaded resources are not taking in account
  33457. * @return true if all required resources are ready
  33458. */
  33459. isReady(): boolean;
  33460. /** Resets all cached information relative to material (including effect and visibility) */
  33461. resetCachedMaterial(): void;
  33462. /**
  33463. * Registers a function to be called before every frame render
  33464. * @param func defines the function to register
  33465. */
  33466. registerBeforeRender(func: () => void): void;
  33467. /**
  33468. * Unregisters a function called before every frame render
  33469. * @param func defines the function to unregister
  33470. */
  33471. unregisterBeforeRender(func: () => void): void;
  33472. /**
  33473. * Registers a function to be called after every frame render
  33474. * @param func defines the function to register
  33475. */
  33476. registerAfterRender(func: () => void): void;
  33477. /**
  33478. * Unregisters a function called after every frame render
  33479. * @param func defines the function to unregister
  33480. */
  33481. unregisterAfterRender(func: () => void): void;
  33482. private _executeOnceBeforeRender;
  33483. /**
  33484. * The provided function will run before render once and will be disposed afterwards.
  33485. * A timeout delay can be provided so that the function will be executed in N ms.
  33486. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33487. * @param func The function to be executed.
  33488. * @param timeout optional delay in ms
  33489. */
  33490. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33491. /** @hidden */
  33492. _addPendingData(data: any): void;
  33493. /** @hidden */
  33494. _removePendingData(data: any): void;
  33495. /**
  33496. * Returns the number of items waiting to be loaded
  33497. * @returns the number of items waiting to be loaded
  33498. */
  33499. getWaitingItemsCount(): number;
  33500. /**
  33501. * Returns a boolean indicating if the scene is still loading data
  33502. */
  33503. readonly isLoading: boolean;
  33504. /**
  33505. * Registers a function to be executed when the scene is ready
  33506. * @param {Function} func - the function to be executed
  33507. */
  33508. executeWhenReady(func: () => void): void;
  33509. /**
  33510. * Returns a promise that resolves when the scene is ready
  33511. * @returns A promise that resolves when the scene is ready
  33512. */
  33513. whenReadyAsync(): Promise<void>;
  33514. /** @hidden */
  33515. _checkIsReady(): void;
  33516. /**
  33517. * Gets all animatable attached to the scene
  33518. */
  33519. readonly animatables: Animatable[];
  33520. /**
  33521. * Resets the last animation time frame.
  33522. * Useful to override when animations start running when loading a scene for the first time.
  33523. */
  33524. resetLastAnimationTimeFrame(): void;
  33525. /**
  33526. * Gets the current view matrix
  33527. * @returns a Matrix
  33528. */
  33529. getViewMatrix(): Matrix;
  33530. /**
  33531. * Gets the current projection matrix
  33532. * @returns a Matrix
  33533. */
  33534. getProjectionMatrix(): Matrix;
  33535. /**
  33536. * Gets the current transform matrix
  33537. * @returns a Matrix made of View * Projection
  33538. */
  33539. getTransformMatrix(): Matrix;
  33540. /**
  33541. * Sets the current transform matrix
  33542. * @param viewL defines the View matrix to use
  33543. * @param projectionL defines the Projection matrix to use
  33544. * @param viewR defines the right View matrix to use (if provided)
  33545. * @param projectionR defines the right Projection matrix to use (if provided)
  33546. */
  33547. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33548. /**
  33549. * Gets the uniform buffer used to store scene data
  33550. * @returns a UniformBuffer
  33551. */
  33552. getSceneUniformBuffer(): UniformBuffer;
  33553. /**
  33554. * Gets an unique (relatively to the current scene) Id
  33555. * @returns an unique number for the scene
  33556. */
  33557. getUniqueId(): number;
  33558. /**
  33559. * Add a mesh to the list of scene's meshes
  33560. * @param newMesh defines the mesh to add
  33561. * @param recursive if all child meshes should also be added to the scene
  33562. */
  33563. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33564. /**
  33565. * Remove a mesh for the list of scene's meshes
  33566. * @param toRemove defines the mesh to remove
  33567. * @param recursive if all child meshes should also be removed from the scene
  33568. * @returns the index where the mesh was in the mesh list
  33569. */
  33570. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33571. /**
  33572. * Add a transform node to the list of scene's transform nodes
  33573. * @param newTransformNode defines the transform node to add
  33574. */
  33575. addTransformNode(newTransformNode: TransformNode): void;
  33576. /**
  33577. * Remove a transform node for the list of scene's transform nodes
  33578. * @param toRemove defines the transform node to remove
  33579. * @returns the index where the transform node was in the transform node list
  33580. */
  33581. removeTransformNode(toRemove: TransformNode): number;
  33582. /**
  33583. * Remove a skeleton for the list of scene's skeletons
  33584. * @param toRemove defines the skeleton to remove
  33585. * @returns the index where the skeleton was in the skeleton list
  33586. */
  33587. removeSkeleton(toRemove: Skeleton): number;
  33588. /**
  33589. * Remove a morph target for the list of scene's morph targets
  33590. * @param toRemove defines the morph target to remove
  33591. * @returns the index where the morph target was in the morph target list
  33592. */
  33593. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33594. /**
  33595. * Remove a light for the list of scene's lights
  33596. * @param toRemove defines the light to remove
  33597. * @returns the index where the light was in the light list
  33598. */
  33599. removeLight(toRemove: Light): number;
  33600. /**
  33601. * Remove a camera for the list of scene's cameras
  33602. * @param toRemove defines the camera to remove
  33603. * @returns the index where the camera was in the camera list
  33604. */
  33605. removeCamera(toRemove: Camera): number;
  33606. /**
  33607. * Remove a particle system for the list of scene's particle systems
  33608. * @param toRemove defines the particle system to remove
  33609. * @returns the index where the particle system was in the particle system list
  33610. */
  33611. removeParticleSystem(toRemove: IParticleSystem): number;
  33612. /**
  33613. * Remove a animation for the list of scene's animations
  33614. * @param toRemove defines the animation to remove
  33615. * @returns the index where the animation was in the animation list
  33616. */
  33617. removeAnimation(toRemove: Animation): number;
  33618. /**
  33619. * Removes the given animation group from this scene.
  33620. * @param toRemove The animation group to remove
  33621. * @returns The index of the removed animation group
  33622. */
  33623. removeAnimationGroup(toRemove: AnimationGroup): number;
  33624. /**
  33625. * Removes the given multi-material from this scene.
  33626. * @param toRemove The multi-material to remove
  33627. * @returns The index of the removed multi-material
  33628. */
  33629. removeMultiMaterial(toRemove: MultiMaterial): number;
  33630. /**
  33631. * Removes the given material from this scene.
  33632. * @param toRemove The material to remove
  33633. * @returns The index of the removed material
  33634. */
  33635. removeMaterial(toRemove: Material): number;
  33636. /**
  33637. * Removes the given action manager from this scene.
  33638. * @param toRemove The action manager to remove
  33639. * @returns The index of the removed action manager
  33640. */
  33641. removeActionManager(toRemove: AbstractActionManager): number;
  33642. /**
  33643. * Removes the given texture from this scene.
  33644. * @param toRemove The texture to remove
  33645. * @returns The index of the removed texture
  33646. */
  33647. removeTexture(toRemove: BaseTexture): number;
  33648. /**
  33649. * Adds the given light to this scene
  33650. * @param newLight The light to add
  33651. */
  33652. addLight(newLight: Light): void;
  33653. /**
  33654. * Sorts the list list based on light priorities
  33655. */
  33656. sortLightsByPriority(): void;
  33657. /**
  33658. * Adds the given camera to this scene
  33659. * @param newCamera The camera to add
  33660. */
  33661. addCamera(newCamera: Camera): void;
  33662. /**
  33663. * Adds the given skeleton to this scene
  33664. * @param newSkeleton The skeleton to add
  33665. */
  33666. addSkeleton(newSkeleton: Skeleton): void;
  33667. /**
  33668. * Adds the given particle system to this scene
  33669. * @param newParticleSystem The particle system to add
  33670. */
  33671. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33672. /**
  33673. * Adds the given animation to this scene
  33674. * @param newAnimation The animation to add
  33675. */
  33676. addAnimation(newAnimation: Animation): void;
  33677. /**
  33678. * Adds the given animation group to this scene.
  33679. * @param newAnimationGroup The animation group to add
  33680. */
  33681. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33682. /**
  33683. * Adds the given multi-material to this scene
  33684. * @param newMultiMaterial The multi-material to add
  33685. */
  33686. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33687. /**
  33688. * Adds the given material to this scene
  33689. * @param newMaterial The material to add
  33690. */
  33691. addMaterial(newMaterial: Material): void;
  33692. /**
  33693. * Adds the given morph target to this scene
  33694. * @param newMorphTargetManager The morph target to add
  33695. */
  33696. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33697. /**
  33698. * Adds the given geometry to this scene
  33699. * @param newGeometry The geometry to add
  33700. */
  33701. addGeometry(newGeometry: Geometry): void;
  33702. /**
  33703. * Adds the given action manager to this scene
  33704. * @param newActionManager The action manager to add
  33705. */
  33706. addActionManager(newActionManager: AbstractActionManager): void;
  33707. /**
  33708. * Adds the given texture to this scene.
  33709. * @param newTexture The texture to add
  33710. */
  33711. addTexture(newTexture: BaseTexture): void;
  33712. /**
  33713. * Switch active camera
  33714. * @param newCamera defines the new active camera
  33715. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33716. */
  33717. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33718. /**
  33719. * sets the active camera of the scene using its ID
  33720. * @param id defines the camera's ID
  33721. * @return the new active camera or null if none found.
  33722. */
  33723. setActiveCameraByID(id: string): Nullable<Camera>;
  33724. /**
  33725. * sets the active camera of the scene using its name
  33726. * @param name defines the camera's name
  33727. * @returns the new active camera or null if none found.
  33728. */
  33729. setActiveCameraByName(name: string): Nullable<Camera>;
  33730. /**
  33731. * get an animation group using its name
  33732. * @param name defines the material's name
  33733. * @return the animation group or null if none found.
  33734. */
  33735. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33736. /**
  33737. * Get a material using its unique id
  33738. * @param uniqueId defines the material's unique id
  33739. * @return the material or null if none found.
  33740. */
  33741. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33742. /**
  33743. * get a material using its id
  33744. * @param id defines the material's ID
  33745. * @return the material or null if none found.
  33746. */
  33747. getMaterialByID(id: string): Nullable<Material>;
  33748. /**
  33749. * Gets a material using its name
  33750. * @param name defines the material's name
  33751. * @return the material or null if none found.
  33752. */
  33753. getMaterialByName(name: string): Nullable<Material>;
  33754. /**
  33755. * Gets a camera using its id
  33756. * @param id defines the id to look for
  33757. * @returns the camera or null if not found
  33758. */
  33759. getCameraByID(id: string): Nullable<Camera>;
  33760. /**
  33761. * Gets a camera using its unique id
  33762. * @param uniqueId defines the unique id to look for
  33763. * @returns the camera or null if not found
  33764. */
  33765. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33766. /**
  33767. * Gets a camera using its name
  33768. * @param name defines the camera's name
  33769. * @return the camera or null if none found.
  33770. */
  33771. getCameraByName(name: string): Nullable<Camera>;
  33772. /**
  33773. * Gets a bone using its id
  33774. * @param id defines the bone's id
  33775. * @return the bone or null if not found
  33776. */
  33777. getBoneByID(id: string): Nullable<Bone>;
  33778. /**
  33779. * Gets a bone using its id
  33780. * @param name defines the bone's name
  33781. * @return the bone or null if not found
  33782. */
  33783. getBoneByName(name: string): Nullable<Bone>;
  33784. /**
  33785. * Gets a light node using its name
  33786. * @param name defines the the light's name
  33787. * @return the light or null if none found.
  33788. */
  33789. getLightByName(name: string): Nullable<Light>;
  33790. /**
  33791. * Gets a light node using its id
  33792. * @param id defines the light's id
  33793. * @return the light or null if none found.
  33794. */
  33795. getLightByID(id: string): Nullable<Light>;
  33796. /**
  33797. * Gets a light node using its scene-generated unique ID
  33798. * @param uniqueId defines the light's unique id
  33799. * @return the light or null if none found.
  33800. */
  33801. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33802. /**
  33803. * Gets a particle system by id
  33804. * @param id defines the particle system id
  33805. * @return the corresponding system or null if none found
  33806. */
  33807. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33808. /**
  33809. * Gets a geometry using its ID
  33810. * @param id defines the geometry's id
  33811. * @return the geometry or null if none found.
  33812. */
  33813. getGeometryByID(id: string): Nullable<Geometry>;
  33814. private _getGeometryByUniqueID;
  33815. /**
  33816. * Add a new geometry to this scene
  33817. * @param geometry defines the geometry to be added to the scene.
  33818. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33819. * @return a boolean defining if the geometry was added or not
  33820. */
  33821. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33822. /**
  33823. * Removes an existing geometry
  33824. * @param geometry defines the geometry to be removed from the scene
  33825. * @return a boolean defining if the geometry was removed or not
  33826. */
  33827. removeGeometry(geometry: Geometry): boolean;
  33828. /**
  33829. * Gets the list of geometries attached to the scene
  33830. * @returns an array of Geometry
  33831. */
  33832. getGeometries(): Geometry[];
  33833. /**
  33834. * Gets the first added mesh found of a given ID
  33835. * @param id defines the id to search for
  33836. * @return the mesh found or null if not found at all
  33837. */
  33838. getMeshByID(id: string): Nullable<AbstractMesh>;
  33839. /**
  33840. * Gets a list of meshes using their id
  33841. * @param id defines the id to search for
  33842. * @returns a list of meshes
  33843. */
  33844. getMeshesByID(id: string): Array<AbstractMesh>;
  33845. /**
  33846. * Gets the first added transform node found of a given ID
  33847. * @param id defines the id to search for
  33848. * @return the found transform node or null if not found at all.
  33849. */
  33850. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33851. /**
  33852. * Gets a transform node with its auto-generated unique id
  33853. * @param uniqueId efines the unique id to search for
  33854. * @return the found transform node or null if not found at all.
  33855. */
  33856. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33857. /**
  33858. * Gets a list of transform nodes using their id
  33859. * @param id defines the id to search for
  33860. * @returns a list of transform nodes
  33861. */
  33862. getTransformNodesByID(id: string): Array<TransformNode>;
  33863. /**
  33864. * Gets a mesh with its auto-generated unique id
  33865. * @param uniqueId defines the unique id to search for
  33866. * @return the found mesh or null if not found at all.
  33867. */
  33868. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33869. /**
  33870. * Gets a the last added mesh using a given id
  33871. * @param id defines the id to search for
  33872. * @return the found mesh or null if not found at all.
  33873. */
  33874. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33875. /**
  33876. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33877. * @param id defines the id to search for
  33878. * @return the found node or null if not found at all
  33879. */
  33880. getLastEntryByID(id: string): Nullable<Node>;
  33881. /**
  33882. * Gets a node (Mesh, Camera, Light) using a given id
  33883. * @param id defines the id to search for
  33884. * @return the found node or null if not found at all
  33885. */
  33886. getNodeByID(id: string): Nullable<Node>;
  33887. /**
  33888. * Gets a node (Mesh, Camera, Light) using a given name
  33889. * @param name defines the name to search for
  33890. * @return the found node or null if not found at all.
  33891. */
  33892. getNodeByName(name: string): Nullable<Node>;
  33893. /**
  33894. * Gets a mesh using a given name
  33895. * @param name defines the name to search for
  33896. * @return the found mesh or null if not found at all.
  33897. */
  33898. getMeshByName(name: string): Nullable<AbstractMesh>;
  33899. /**
  33900. * Gets a transform node using a given name
  33901. * @param name defines the name to search for
  33902. * @return the found transform node or null if not found at all.
  33903. */
  33904. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33905. /**
  33906. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33907. * @param id defines the id to search for
  33908. * @return the found skeleton or null if not found at all.
  33909. */
  33910. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33911. /**
  33912. * Gets a skeleton using a given auto generated unique id
  33913. * @param uniqueId defines the unique id to search for
  33914. * @return the found skeleton or null if not found at all.
  33915. */
  33916. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33917. /**
  33918. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33919. * @param id defines the id to search for
  33920. * @return the found skeleton or null if not found at all.
  33921. */
  33922. getSkeletonById(id: string): Nullable<Skeleton>;
  33923. /**
  33924. * Gets a skeleton using a given name
  33925. * @param name defines the name to search for
  33926. * @return the found skeleton or null if not found at all.
  33927. */
  33928. getSkeletonByName(name: string): Nullable<Skeleton>;
  33929. /**
  33930. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33931. * @param id defines the id to search for
  33932. * @return the found morph target manager or null if not found at all.
  33933. */
  33934. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33935. /**
  33936. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33937. * @param id defines the id to search for
  33938. * @return the found morph target or null if not found at all.
  33939. */
  33940. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33941. /**
  33942. * Gets a boolean indicating if the given mesh is active
  33943. * @param mesh defines the mesh to look for
  33944. * @returns true if the mesh is in the active list
  33945. */
  33946. isActiveMesh(mesh: AbstractMesh): boolean;
  33947. /**
  33948. * Return a unique id as a string which can serve as an identifier for the scene
  33949. */
  33950. readonly uid: string;
  33951. /**
  33952. * Add an externaly attached data from its key.
  33953. * This method call will fail and return false, if such key already exists.
  33954. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33955. * @param key the unique key that identifies the data
  33956. * @param data the data object to associate to the key for this Engine instance
  33957. * @return true if no such key were already present and the data was added successfully, false otherwise
  33958. */
  33959. addExternalData<T>(key: string, data: T): boolean;
  33960. /**
  33961. * Get an externaly attached data from its key
  33962. * @param key the unique key that identifies the data
  33963. * @return the associated data, if present (can be null), or undefined if not present
  33964. */
  33965. getExternalData<T>(key: string): Nullable<T>;
  33966. /**
  33967. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33968. * @param key the unique key that identifies the data
  33969. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33970. * @return the associated data, can be null if the factory returned null.
  33971. */
  33972. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33973. /**
  33974. * Remove an externaly attached data from the Engine instance
  33975. * @param key the unique key that identifies the data
  33976. * @return true if the data was successfully removed, false if it doesn't exist
  33977. */
  33978. removeExternalData(key: string): boolean;
  33979. private _evaluateSubMesh;
  33980. /**
  33981. * Clear the processed materials smart array preventing retention point in material dispose.
  33982. */
  33983. freeProcessedMaterials(): void;
  33984. private _preventFreeActiveMeshesAndRenderingGroups;
  33985. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33986. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33987. * when disposing several meshes in a row or a hierarchy of meshes.
  33988. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33989. */
  33990. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33991. /**
  33992. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33993. */
  33994. freeActiveMeshes(): void;
  33995. /**
  33996. * Clear the info related to rendering groups preventing retention points during dispose.
  33997. */
  33998. freeRenderingGroups(): void;
  33999. /** @hidden */
  34000. _isInIntermediateRendering(): boolean;
  34001. /**
  34002. * Lambda returning the list of potentially active meshes.
  34003. */
  34004. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34005. /**
  34006. * Lambda returning the list of potentially active sub meshes.
  34007. */
  34008. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34009. /**
  34010. * Lambda returning the list of potentially intersecting sub meshes.
  34011. */
  34012. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34013. /**
  34014. * Lambda returning the list of potentially colliding sub meshes.
  34015. */
  34016. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34017. private _activeMeshesFrozen;
  34018. /**
  34019. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34020. * @returns the current scene
  34021. */
  34022. freezeActiveMeshes(): Scene;
  34023. /**
  34024. * Use this function to restart evaluating active meshes on every frame
  34025. * @returns the current scene
  34026. */
  34027. unfreezeActiveMeshes(): Scene;
  34028. private _evaluateActiveMeshes;
  34029. private _activeMesh;
  34030. /**
  34031. * Update the transform matrix to update from the current active camera
  34032. * @param force defines a boolean used to force the update even if cache is up to date
  34033. */
  34034. updateTransformMatrix(force?: boolean): void;
  34035. private _bindFrameBuffer;
  34036. /** @hidden */
  34037. _allowPostProcessClearColor: boolean;
  34038. /** @hidden */
  34039. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34040. private _processSubCameras;
  34041. private _checkIntersections;
  34042. /** @hidden */
  34043. _advancePhysicsEngineStep(step: number): void;
  34044. /**
  34045. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34046. */
  34047. getDeterministicFrameTime: () => number;
  34048. /** @hidden */
  34049. _animate(): void;
  34050. /**
  34051. * Render the scene
  34052. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34053. */
  34054. render(updateCameras?: boolean): void;
  34055. /**
  34056. * Freeze all materials
  34057. * A frozen material will not be updatable but should be faster to render
  34058. */
  34059. freezeMaterials(): void;
  34060. /**
  34061. * Unfreeze all materials
  34062. * A frozen material will not be updatable but should be faster to render
  34063. */
  34064. unfreezeMaterials(): void;
  34065. /**
  34066. * Releases all held ressources
  34067. */
  34068. dispose(): void;
  34069. /**
  34070. * Gets if the scene is already disposed
  34071. */
  34072. readonly isDisposed: boolean;
  34073. /**
  34074. * Call this function to reduce memory footprint of the scene.
  34075. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34076. */
  34077. clearCachedVertexData(): void;
  34078. /**
  34079. * This function will remove the local cached buffer data from texture.
  34080. * It will save memory but will prevent the texture from being rebuilt
  34081. */
  34082. cleanCachedTextureBuffer(): void;
  34083. /**
  34084. * Get the world extend vectors with an optional filter
  34085. *
  34086. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34087. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34088. */
  34089. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34090. min: Vector3;
  34091. max: Vector3;
  34092. };
  34093. /**
  34094. * Creates a ray that can be used to pick in the scene
  34095. * @param x defines the x coordinate of the origin (on-screen)
  34096. * @param y defines the y coordinate of the origin (on-screen)
  34097. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34098. * @param camera defines the camera to use for the picking
  34099. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34100. * @returns a Ray
  34101. */
  34102. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34103. /**
  34104. * Creates a ray that can be used to pick in the scene
  34105. * @param x defines the x coordinate of the origin (on-screen)
  34106. * @param y defines the y coordinate of the origin (on-screen)
  34107. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34108. * @param result defines the ray where to store the picking ray
  34109. * @param camera defines the camera to use for the picking
  34110. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34111. * @returns the current scene
  34112. */
  34113. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34114. /**
  34115. * Creates a ray that can be used to pick in the scene
  34116. * @param x defines the x coordinate of the origin (on-screen)
  34117. * @param y defines the y coordinate of the origin (on-screen)
  34118. * @param camera defines the camera to use for the picking
  34119. * @returns a Ray
  34120. */
  34121. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34122. /**
  34123. * Creates a ray that can be used to pick in the scene
  34124. * @param x defines the x coordinate of the origin (on-screen)
  34125. * @param y defines the y coordinate of the origin (on-screen)
  34126. * @param result defines the ray where to store the picking ray
  34127. * @param camera defines the camera to use for the picking
  34128. * @returns the current scene
  34129. */
  34130. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34131. /** Launch a ray to try to pick a mesh in the scene
  34132. * @param x position on screen
  34133. * @param y position on screen
  34134. * @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
  34135. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34136. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34137. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34138. * @returns a PickingInfo
  34139. */
  34140. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34141. /** Use the given ray to pick a mesh in the scene
  34142. * @param ray The ray to use to pick meshes
  34143. * @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
  34144. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34146. * @returns a PickingInfo
  34147. */
  34148. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34149. /**
  34150. * Launch a ray to try to pick a mesh in the scene
  34151. * @param x X position on screen
  34152. * @param y Y position on screen
  34153. * @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
  34154. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34155. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34156. * @returns an array of PickingInfo
  34157. */
  34158. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34159. /**
  34160. * Launch a ray to try to pick a mesh in the scene
  34161. * @param ray Ray to use
  34162. * @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
  34163. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34164. * @returns an array of PickingInfo
  34165. */
  34166. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34167. /**
  34168. * Force the value of meshUnderPointer
  34169. * @param mesh defines the mesh to use
  34170. */
  34171. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34172. /**
  34173. * Gets the mesh under the pointer
  34174. * @returns a Mesh or null if no mesh is under the pointer
  34175. */
  34176. getPointerOverMesh(): Nullable<AbstractMesh>;
  34177. /** @hidden */
  34178. _rebuildGeometries(): void;
  34179. /** @hidden */
  34180. _rebuildTextures(): void;
  34181. private _getByTags;
  34182. /**
  34183. * Get a list of meshes by tags
  34184. * @param tagsQuery defines the tags query to use
  34185. * @param forEach defines a predicate used to filter results
  34186. * @returns an array of Mesh
  34187. */
  34188. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34189. /**
  34190. * Get a list of cameras by tags
  34191. * @param tagsQuery defines the tags query to use
  34192. * @param forEach defines a predicate used to filter results
  34193. * @returns an array of Camera
  34194. */
  34195. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34196. /**
  34197. * Get a list of lights by tags
  34198. * @param tagsQuery defines the tags query to use
  34199. * @param forEach defines a predicate used to filter results
  34200. * @returns an array of Light
  34201. */
  34202. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34203. /**
  34204. * Get a list of materials by tags
  34205. * @param tagsQuery defines the tags query to use
  34206. * @param forEach defines a predicate used to filter results
  34207. * @returns an array of Material
  34208. */
  34209. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34210. /**
  34211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34212. * This allowed control for front to back rendering or reversly depending of the special needs.
  34213. *
  34214. * @param renderingGroupId The rendering group id corresponding to its index
  34215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34218. */
  34219. 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;
  34220. /**
  34221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34222. *
  34223. * @param renderingGroupId The rendering group id corresponding to its index
  34224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34227. */
  34228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34229. /**
  34230. * Gets the current auto clear configuration for one rendering group of the rendering
  34231. * manager.
  34232. * @param index the rendering group index to get the information for
  34233. * @returns The auto clear setup for the requested rendering group
  34234. */
  34235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34236. private _blockMaterialDirtyMechanism;
  34237. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34238. blockMaterialDirtyMechanism: boolean;
  34239. /**
  34240. * Will flag all materials as dirty to trigger new shader compilation
  34241. * @param flag defines the flag used to specify which material part must be marked as dirty
  34242. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34243. */
  34244. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34245. /** @hidden */
  34246. _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;
  34247. /** @hidden */
  34248. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34249. }
  34250. }
  34251. declare module "babylonjs/assetContainer" {
  34252. import { AbstractScene } from "babylonjs/abstractScene";
  34253. import { Scene } from "babylonjs/scene";
  34254. import { Mesh } from "babylonjs/Meshes/mesh";
  34255. /**
  34256. * Set of assets to keep when moving a scene into an asset container.
  34257. */
  34258. export class KeepAssets extends AbstractScene {
  34259. }
  34260. /**
  34261. * Container with a set of assets that can be added or removed from a scene.
  34262. */
  34263. export class AssetContainer extends AbstractScene {
  34264. /**
  34265. * The scene the AssetContainer belongs to.
  34266. */
  34267. scene: Scene;
  34268. /**
  34269. * Instantiates an AssetContainer.
  34270. * @param scene The scene the AssetContainer belongs to.
  34271. */
  34272. constructor(scene: Scene);
  34273. /**
  34274. * Adds all the assets from the container to the scene.
  34275. */
  34276. addAllToScene(): void;
  34277. /**
  34278. * Removes all the assets in the container from the scene
  34279. */
  34280. removeAllFromScene(): void;
  34281. /**
  34282. * Disposes all the assets in the container
  34283. */
  34284. dispose(): void;
  34285. private _moveAssets;
  34286. /**
  34287. * Removes all the assets contained in the scene and adds them to the container.
  34288. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34289. */
  34290. moveAllFromScene(keepAssets?: KeepAssets): void;
  34291. /**
  34292. * 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.
  34293. * @returns the root mesh
  34294. */
  34295. createRootMesh(): Mesh;
  34296. }
  34297. }
  34298. declare module "babylonjs/abstractScene" {
  34299. import { Scene } from "babylonjs/scene";
  34300. import { Nullable } from "babylonjs/types";
  34301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34303. import { Geometry } from "babylonjs/Meshes/geometry";
  34304. import { Skeleton } from "babylonjs/Bones/skeleton";
  34305. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34306. import { AssetContainer } from "babylonjs/assetContainer";
  34307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34308. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34309. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34310. import { Material } from "babylonjs/Materials/material";
  34311. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34312. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34313. import { Camera } from "babylonjs/Cameras/camera";
  34314. import { Light } from "babylonjs/Lights/light";
  34315. import { Node } from "babylonjs/node";
  34316. import { Animation } from "babylonjs/Animations/animation";
  34317. /**
  34318. * Defines how the parser contract is defined.
  34319. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34320. */
  34321. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34322. /**
  34323. * Defines how the individual parser contract is defined.
  34324. * These parser can parse an individual asset
  34325. */
  34326. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34327. /**
  34328. * Base class of the scene acting as a container for the different elements composing a scene.
  34329. * This class is dynamically extended by the different components of the scene increasing
  34330. * flexibility and reducing coupling
  34331. */
  34332. export abstract class AbstractScene {
  34333. /**
  34334. * Stores the list of available parsers in the application.
  34335. */
  34336. private static _BabylonFileParsers;
  34337. /**
  34338. * Stores the list of available individual parsers in the application.
  34339. */
  34340. private static _IndividualBabylonFileParsers;
  34341. /**
  34342. * Adds a parser in the list of available ones
  34343. * @param name Defines the name of the parser
  34344. * @param parser Defines the parser to add
  34345. */
  34346. static AddParser(name: string, parser: BabylonFileParser): void;
  34347. /**
  34348. * Gets a general parser from the list of avaialble ones
  34349. * @param name Defines the name of the parser
  34350. * @returns the requested parser or null
  34351. */
  34352. static GetParser(name: string): Nullable<BabylonFileParser>;
  34353. /**
  34354. * Adds n individual parser in the list of available ones
  34355. * @param name Defines the name of the parser
  34356. * @param parser Defines the parser to add
  34357. */
  34358. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34359. /**
  34360. * Gets an individual parser from the list of avaialble ones
  34361. * @param name Defines the name of the parser
  34362. * @returns the requested parser or null
  34363. */
  34364. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34365. /**
  34366. * Parser json data and populate both a scene and its associated container object
  34367. * @param jsonData Defines the data to parse
  34368. * @param scene Defines the scene to parse the data for
  34369. * @param container Defines the container attached to the parsing sequence
  34370. * @param rootUrl Defines the root url of the data
  34371. */
  34372. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34373. /**
  34374. * Gets the list of root nodes (ie. nodes with no parent)
  34375. */
  34376. rootNodes: Node[];
  34377. /** All of the cameras added to this scene
  34378. * @see http://doc.babylonjs.com/babylon101/cameras
  34379. */
  34380. cameras: Camera[];
  34381. /**
  34382. * All of the lights added to this scene
  34383. * @see http://doc.babylonjs.com/babylon101/lights
  34384. */
  34385. lights: Light[];
  34386. /**
  34387. * All of the (abstract) meshes added to this scene
  34388. */
  34389. meshes: AbstractMesh[];
  34390. /**
  34391. * The list of skeletons added to the scene
  34392. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34393. */
  34394. skeletons: Skeleton[];
  34395. /**
  34396. * All of the particle systems added to this scene
  34397. * @see http://doc.babylonjs.com/babylon101/particles
  34398. */
  34399. particleSystems: IParticleSystem[];
  34400. /**
  34401. * Gets a list of Animations associated with the scene
  34402. */
  34403. animations: Animation[];
  34404. /**
  34405. * All of the animation groups added to this scene
  34406. * @see http://doc.babylonjs.com/how_to/group
  34407. */
  34408. animationGroups: AnimationGroup[];
  34409. /**
  34410. * All of the multi-materials added to this scene
  34411. * @see http://doc.babylonjs.com/how_to/multi_materials
  34412. */
  34413. multiMaterials: MultiMaterial[];
  34414. /**
  34415. * All of the materials added to this scene
  34416. * In the context of a Scene, it is not supposed to be modified manually.
  34417. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34418. * Note also that the order of the Material wihin the array is not significant and might change.
  34419. * @see http://doc.babylonjs.com/babylon101/materials
  34420. */
  34421. materials: Material[];
  34422. /**
  34423. * The list of morph target managers added to the scene
  34424. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34425. */
  34426. morphTargetManagers: MorphTargetManager[];
  34427. /**
  34428. * The list of geometries used in the scene.
  34429. */
  34430. geometries: Geometry[];
  34431. /**
  34432. * All of the tranform nodes added to this scene
  34433. * In the context of a Scene, it is not supposed to be modified manually.
  34434. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34435. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34436. * @see http://doc.babylonjs.com/how_to/transformnode
  34437. */
  34438. transformNodes: TransformNode[];
  34439. /**
  34440. * ActionManagers available on the scene.
  34441. */
  34442. actionManagers: AbstractActionManager[];
  34443. /**
  34444. * Textures to keep.
  34445. */
  34446. textures: BaseTexture[];
  34447. /**
  34448. * Environment texture for the scene
  34449. */
  34450. environmentTexture: Nullable<BaseTexture>;
  34451. }
  34452. }
  34453. declare module "babylonjs/Audio/sound" {
  34454. import { Observable } from "babylonjs/Misc/observable";
  34455. import { Vector3 } from "babylonjs/Maths/math";
  34456. import { Nullable } from "babylonjs/types";
  34457. import { Scene } from "babylonjs/scene";
  34458. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34459. /**
  34460. * Defines a sound that can be played in the application.
  34461. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34463. */
  34464. export class Sound {
  34465. /**
  34466. * The name of the sound in the scene.
  34467. */
  34468. name: string;
  34469. /**
  34470. * Does the sound autoplay once loaded.
  34471. */
  34472. autoplay: boolean;
  34473. /**
  34474. * Does the sound loop after it finishes playing once.
  34475. */
  34476. loop: boolean;
  34477. /**
  34478. * Does the sound use a custom attenuation curve to simulate the falloff
  34479. * happening when the source gets further away from the camera.
  34480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34481. */
  34482. useCustomAttenuation: boolean;
  34483. /**
  34484. * The sound track id this sound belongs to.
  34485. */
  34486. soundTrackId: number;
  34487. /**
  34488. * Is this sound currently played.
  34489. */
  34490. isPlaying: boolean;
  34491. /**
  34492. * Is this sound currently paused.
  34493. */
  34494. isPaused: boolean;
  34495. /**
  34496. * Does this sound enables spatial sound.
  34497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34498. */
  34499. spatialSound: boolean;
  34500. /**
  34501. * Define the reference distance the sound should be heard perfectly.
  34502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34503. */
  34504. refDistance: number;
  34505. /**
  34506. * Define the roll off factor of spatial sounds.
  34507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34508. */
  34509. rolloffFactor: number;
  34510. /**
  34511. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34513. */
  34514. maxDistance: number;
  34515. /**
  34516. * Define the distance attenuation model the sound will follow.
  34517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34518. */
  34519. distanceModel: string;
  34520. /**
  34521. * @hidden
  34522. * Back Compat
  34523. **/
  34524. onended: () => any;
  34525. /**
  34526. * Observable event when the current playing sound finishes.
  34527. */
  34528. onEndedObservable: Observable<Sound>;
  34529. private _panningModel;
  34530. private _playbackRate;
  34531. private _streaming;
  34532. private _startTime;
  34533. private _startOffset;
  34534. private _position;
  34535. /** @hidden */
  34536. _positionInEmitterSpace: boolean;
  34537. private _localDirection;
  34538. private _volume;
  34539. private _isReadyToPlay;
  34540. private _isDirectional;
  34541. private _readyToPlayCallback;
  34542. private _audioBuffer;
  34543. private _soundSource;
  34544. private _streamingSource;
  34545. private _soundPanner;
  34546. private _soundGain;
  34547. private _inputAudioNode;
  34548. private _outputAudioNode;
  34549. private _coneInnerAngle;
  34550. private _coneOuterAngle;
  34551. private _coneOuterGain;
  34552. private _scene;
  34553. private _connectedTransformNode;
  34554. private _customAttenuationFunction;
  34555. private _registerFunc;
  34556. private _isOutputConnected;
  34557. private _htmlAudioElement;
  34558. private _urlType;
  34559. /** @hidden */
  34560. static _SceneComponentInitialization: (scene: Scene) => void;
  34561. /**
  34562. * Create a sound and attach it to a scene
  34563. * @param name Name of your sound
  34564. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34565. * @param scene defines the scene the sound belongs to
  34566. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34567. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34568. */
  34569. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34570. /**
  34571. * Release the sound and its associated resources
  34572. */
  34573. dispose(): void;
  34574. /**
  34575. * Gets if the sounds is ready to be played or not.
  34576. * @returns true if ready, otherwise false
  34577. */
  34578. isReady(): boolean;
  34579. private _soundLoaded;
  34580. /**
  34581. * Sets the data of the sound from an audiobuffer
  34582. * @param audioBuffer The audioBuffer containing the data
  34583. */
  34584. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34585. /**
  34586. * Updates the current sounds options such as maxdistance, loop...
  34587. * @param options A JSON object containing values named as the object properties
  34588. */
  34589. updateOptions(options: any): void;
  34590. private _createSpatialParameters;
  34591. private _updateSpatialParameters;
  34592. /**
  34593. * Switch the panning model to HRTF:
  34594. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34596. */
  34597. switchPanningModelToHRTF(): void;
  34598. /**
  34599. * Switch the panning model to Equal Power:
  34600. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34602. */
  34603. switchPanningModelToEqualPower(): void;
  34604. private _switchPanningModel;
  34605. /**
  34606. * Connect this sound to a sound track audio node like gain...
  34607. * @param soundTrackAudioNode the sound track audio node to connect to
  34608. */
  34609. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34610. /**
  34611. * Transform this sound into a directional source
  34612. * @param coneInnerAngle Size of the inner cone in degree
  34613. * @param coneOuterAngle Size of the outer cone in degree
  34614. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34615. */
  34616. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34617. /**
  34618. * Gets or sets the inner angle for the directional cone.
  34619. */
  34620. /**
  34621. * Gets or sets the inner angle for the directional cone.
  34622. */
  34623. directionalConeInnerAngle: number;
  34624. /**
  34625. * Gets or sets the outer angle for the directional cone.
  34626. */
  34627. /**
  34628. * Gets or sets the outer angle for the directional cone.
  34629. */
  34630. directionalConeOuterAngle: number;
  34631. /**
  34632. * Sets the position of the emitter if spatial sound is enabled
  34633. * @param newPosition Defines the new posisiton
  34634. */
  34635. setPosition(newPosition: Vector3): void;
  34636. /**
  34637. * Sets the local direction of the emitter if spatial sound is enabled
  34638. * @param newLocalDirection Defines the new local direction
  34639. */
  34640. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34641. private _updateDirection;
  34642. /** @hidden */
  34643. updateDistanceFromListener(): void;
  34644. /**
  34645. * Sets a new custom attenuation function for the sound.
  34646. * @param callback Defines the function used for the attenuation
  34647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34648. */
  34649. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34650. /**
  34651. * Play the sound
  34652. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34653. * @param offset (optional) Start the sound setting it at a specific time
  34654. */
  34655. play(time?: number, offset?: number): void;
  34656. private _onended;
  34657. /**
  34658. * Stop the sound
  34659. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34660. */
  34661. stop(time?: number): void;
  34662. /**
  34663. * Put the sound in pause
  34664. */
  34665. pause(): void;
  34666. /**
  34667. * Sets a dedicated volume for this sounds
  34668. * @param newVolume Define the new volume of the sound
  34669. * @param time Define in how long the sound should be at this value
  34670. */
  34671. setVolume(newVolume: number, time?: number): void;
  34672. /**
  34673. * Set the sound play back rate
  34674. * @param newPlaybackRate Define the playback rate the sound should be played at
  34675. */
  34676. setPlaybackRate(newPlaybackRate: number): void;
  34677. /**
  34678. * Gets the volume of the sound.
  34679. * @returns the volume of the sound
  34680. */
  34681. getVolume(): number;
  34682. /**
  34683. * Attach the sound to a dedicated mesh
  34684. * @param transformNode The transform node to connect the sound with
  34685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34686. */
  34687. attachToMesh(transformNode: TransformNode): void;
  34688. /**
  34689. * Detach the sound from the previously attached mesh
  34690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34691. */
  34692. detachFromMesh(): void;
  34693. private _onRegisterAfterWorldMatrixUpdate;
  34694. /**
  34695. * Clone the current sound in the scene.
  34696. * @returns the new sound clone
  34697. */
  34698. clone(): Nullable<Sound>;
  34699. /**
  34700. * Gets the current underlying audio buffer containing the data
  34701. * @returns the audio buffer
  34702. */
  34703. getAudioBuffer(): Nullable<AudioBuffer>;
  34704. /**
  34705. * Serializes the Sound in a JSON representation
  34706. * @returns the JSON representation of the sound
  34707. */
  34708. serialize(): any;
  34709. /**
  34710. * Parse a JSON representation of a sound to innstantiate in a given scene
  34711. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34712. * @param scene Define the scene the new parsed sound should be created in
  34713. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34714. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34715. * @returns the newly parsed sound
  34716. */
  34717. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34718. }
  34719. }
  34720. declare module "babylonjs/Actions/directAudioActions" {
  34721. import { Action } from "babylonjs/Actions/action";
  34722. import { Condition } from "babylonjs/Actions/condition";
  34723. import { Sound } from "babylonjs/Audio/sound";
  34724. /**
  34725. * This defines an action helpful to play a defined sound on a triggered action.
  34726. */
  34727. export class PlaySoundAction extends Action {
  34728. private _sound;
  34729. /**
  34730. * Instantiate the action
  34731. * @param triggerOptions defines the trigger options
  34732. * @param sound defines the sound to play
  34733. * @param condition defines the trigger related conditions
  34734. */
  34735. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34736. /** @hidden */
  34737. _prepare(): void;
  34738. /**
  34739. * Execute the action and play the sound.
  34740. */
  34741. execute(): void;
  34742. /**
  34743. * Serializes the actions and its related information.
  34744. * @param parent defines the object to serialize in
  34745. * @returns the serialized object
  34746. */
  34747. serialize(parent: any): any;
  34748. }
  34749. /**
  34750. * This defines an action helpful to stop a defined sound on a triggered action.
  34751. */
  34752. export class StopSoundAction extends Action {
  34753. private _sound;
  34754. /**
  34755. * Instantiate the action
  34756. * @param triggerOptions defines the trigger options
  34757. * @param sound defines the sound to stop
  34758. * @param condition defines the trigger related conditions
  34759. */
  34760. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34761. /** @hidden */
  34762. _prepare(): void;
  34763. /**
  34764. * Execute the action and stop the sound.
  34765. */
  34766. execute(): void;
  34767. /**
  34768. * Serializes the actions and its related information.
  34769. * @param parent defines the object to serialize in
  34770. * @returns the serialized object
  34771. */
  34772. serialize(parent: any): any;
  34773. }
  34774. }
  34775. declare module "babylonjs/Actions/interpolateValueAction" {
  34776. import { Action } from "babylonjs/Actions/action";
  34777. import { Condition } from "babylonjs/Actions/condition";
  34778. import { Observable } from "babylonjs/Misc/observable";
  34779. /**
  34780. * This defines an action responsible to change the value of a property
  34781. * by interpolating between its current value and the newly set one once triggered.
  34782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34783. */
  34784. export class InterpolateValueAction extends Action {
  34785. /**
  34786. * Defines the path of the property where the value should be interpolated
  34787. */
  34788. propertyPath: string;
  34789. /**
  34790. * Defines the target value at the end of the interpolation.
  34791. */
  34792. value: any;
  34793. /**
  34794. * Defines the time it will take for the property to interpolate to the value.
  34795. */
  34796. duration: number;
  34797. /**
  34798. * Defines if the other scene animations should be stopped when the action has been triggered
  34799. */
  34800. stopOtherAnimations?: boolean;
  34801. /**
  34802. * Defines a callback raised once the interpolation animation has been done.
  34803. */
  34804. onInterpolationDone?: () => void;
  34805. /**
  34806. * Observable triggered once the interpolation animation has been done.
  34807. */
  34808. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34809. private _target;
  34810. private _effectiveTarget;
  34811. private _property;
  34812. /**
  34813. * Instantiate the action
  34814. * @param triggerOptions defines the trigger options
  34815. * @param target defines the object containing the value to interpolate
  34816. * @param propertyPath defines the path to the property in the target object
  34817. * @param value defines the target value at the end of the interpolation
  34818. * @param duration deines the time it will take for the property to interpolate to the value.
  34819. * @param condition defines the trigger related conditions
  34820. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34821. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34822. */
  34823. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34824. /** @hidden */
  34825. _prepare(): void;
  34826. /**
  34827. * Execute the action starts the value interpolation.
  34828. */
  34829. execute(): void;
  34830. /**
  34831. * Serializes the actions and its related information.
  34832. * @param parent defines the object to serialize in
  34833. * @returns the serialized object
  34834. */
  34835. serialize(parent: any): any;
  34836. }
  34837. }
  34838. declare module "babylonjs/Actions/index" {
  34839. export * from "babylonjs/Actions/action";
  34840. export * from "babylonjs/Actions/actionEvent";
  34841. export * from "babylonjs/Actions/actionManager";
  34842. export * from "babylonjs/Actions/condition";
  34843. export * from "babylonjs/Actions/directActions";
  34844. export * from "babylonjs/Actions/directAudioActions";
  34845. export * from "babylonjs/Actions/interpolateValueAction";
  34846. }
  34847. declare module "babylonjs/Animations/index" {
  34848. export * from "babylonjs/Animations/animatable";
  34849. export * from "babylonjs/Animations/animation";
  34850. export * from "babylonjs/Animations/animationGroup";
  34851. export * from "babylonjs/Animations/animationPropertiesOverride";
  34852. export * from "babylonjs/Animations/easing";
  34853. export * from "babylonjs/Animations/runtimeAnimation";
  34854. export * from "babylonjs/Animations/animationEvent";
  34855. export * from "babylonjs/Animations/animationGroup";
  34856. export * from "babylonjs/Animations/animationKey";
  34857. export * from "babylonjs/Animations/animationRange";
  34858. }
  34859. declare module "babylonjs/Audio/soundTrack" {
  34860. import { Sound } from "babylonjs/Audio/sound";
  34861. import { Analyser } from "babylonjs/Audio/analyser";
  34862. import { Scene } from "babylonjs/scene";
  34863. /**
  34864. * Options allowed during the creation of a sound track.
  34865. */
  34866. export interface ISoundTrackOptions {
  34867. /**
  34868. * The volume the sound track should take during creation
  34869. */
  34870. volume?: number;
  34871. /**
  34872. * Define if the sound track is the main sound track of the scene
  34873. */
  34874. mainTrack?: boolean;
  34875. }
  34876. /**
  34877. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34878. * It will be also used in a future release to apply effects on a specific track.
  34879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34880. */
  34881. export class SoundTrack {
  34882. /**
  34883. * The unique identifier of the sound track in the scene.
  34884. */
  34885. id: number;
  34886. /**
  34887. * The list of sounds included in the sound track.
  34888. */
  34889. soundCollection: Array<Sound>;
  34890. private _outputAudioNode;
  34891. private _scene;
  34892. private _isMainTrack;
  34893. private _connectedAnalyser;
  34894. private _options;
  34895. private _isInitialized;
  34896. /**
  34897. * Creates a new sound track.
  34898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34899. * @param scene Define the scene the sound track belongs to
  34900. * @param options
  34901. */
  34902. constructor(scene: Scene, options?: ISoundTrackOptions);
  34903. private _initializeSoundTrackAudioGraph;
  34904. /**
  34905. * Release the sound track and its associated resources
  34906. */
  34907. dispose(): void;
  34908. /**
  34909. * Adds a sound to this sound track
  34910. * @param sound define the cound to add
  34911. * @ignoreNaming
  34912. */
  34913. AddSound(sound: Sound): void;
  34914. /**
  34915. * Removes a sound to this sound track
  34916. * @param sound define the cound to remove
  34917. * @ignoreNaming
  34918. */
  34919. RemoveSound(sound: Sound): void;
  34920. /**
  34921. * Set a global volume for the full sound track.
  34922. * @param newVolume Define the new volume of the sound track
  34923. */
  34924. setVolume(newVolume: number): void;
  34925. /**
  34926. * Switch the panning model to HRTF:
  34927. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34929. */
  34930. switchPanningModelToHRTF(): void;
  34931. /**
  34932. * Switch the panning model to Equal Power:
  34933. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34935. */
  34936. switchPanningModelToEqualPower(): void;
  34937. /**
  34938. * Connect the sound track to an audio analyser allowing some amazing
  34939. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34941. * @param analyser The analyser to connect to the engine
  34942. */
  34943. connectToAnalyser(analyser: Analyser): void;
  34944. }
  34945. }
  34946. declare module "babylonjs/Audio/audioSceneComponent" {
  34947. import { Sound } from "babylonjs/Audio/sound";
  34948. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34949. import { Nullable } from "babylonjs/types";
  34950. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34951. import { Scene } from "babylonjs/scene";
  34952. import { AbstractScene } from "babylonjs/abstractScene";
  34953. module "babylonjs/abstractScene" {
  34954. interface AbstractScene {
  34955. /**
  34956. * The list of sounds used in the scene.
  34957. */
  34958. sounds: Nullable<Array<Sound>>;
  34959. }
  34960. }
  34961. module "babylonjs/scene" {
  34962. interface Scene {
  34963. /**
  34964. * @hidden
  34965. * Backing field
  34966. */
  34967. _mainSoundTrack: SoundTrack;
  34968. /**
  34969. * The main sound track played by the scene.
  34970. * It cotains your primary collection of sounds.
  34971. */
  34972. mainSoundTrack: SoundTrack;
  34973. /**
  34974. * The list of sound tracks added to the scene
  34975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34976. */
  34977. soundTracks: Nullable<Array<SoundTrack>>;
  34978. /**
  34979. * Gets a sound using a given name
  34980. * @param name defines the name to search for
  34981. * @return the found sound or null if not found at all.
  34982. */
  34983. getSoundByName(name: string): Nullable<Sound>;
  34984. /**
  34985. * Gets or sets if audio support is enabled
  34986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34987. */
  34988. audioEnabled: boolean;
  34989. /**
  34990. * Gets or sets if audio will be output to headphones
  34991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34992. */
  34993. headphone: boolean;
  34994. }
  34995. }
  34996. /**
  34997. * Defines the sound scene component responsible to manage any sounds
  34998. * in a given scene.
  34999. */
  35000. export class AudioSceneComponent implements ISceneSerializableComponent {
  35001. /**
  35002. * The component name helpfull to identify the component in the list of scene components.
  35003. */
  35004. readonly name: string;
  35005. /**
  35006. * The scene the component belongs to.
  35007. */
  35008. scene: Scene;
  35009. private _audioEnabled;
  35010. /**
  35011. * Gets whether audio is enabled or not.
  35012. * Please use related enable/disable method to switch state.
  35013. */
  35014. readonly audioEnabled: boolean;
  35015. private _headphone;
  35016. /**
  35017. * Gets whether audio is outputing to headphone or not.
  35018. * Please use the according Switch methods to change output.
  35019. */
  35020. readonly headphone: boolean;
  35021. /**
  35022. * Creates a new instance of the component for the given scene
  35023. * @param scene Defines the scene to register the component in
  35024. */
  35025. constructor(scene: Scene);
  35026. /**
  35027. * Registers the component in a given scene
  35028. */
  35029. register(): void;
  35030. /**
  35031. * Rebuilds the elements related to this component in case of
  35032. * context lost for instance.
  35033. */
  35034. rebuild(): void;
  35035. /**
  35036. * Serializes the component data to the specified json object
  35037. * @param serializationObject The object to serialize to
  35038. */
  35039. serialize(serializationObject: any): void;
  35040. /**
  35041. * Adds all the element from the container to the scene
  35042. * @param container the container holding the elements
  35043. */
  35044. addFromContainer(container: AbstractScene): void;
  35045. /**
  35046. * Removes all the elements in the container from the scene
  35047. * @param container contains the elements to remove
  35048. * @param dispose if the removed element should be disposed (default: false)
  35049. */
  35050. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35051. /**
  35052. * Disposes the component and the associated ressources.
  35053. */
  35054. dispose(): void;
  35055. /**
  35056. * Disables audio in the associated scene.
  35057. */
  35058. disableAudio(): void;
  35059. /**
  35060. * Enables audio in the associated scene.
  35061. */
  35062. enableAudio(): void;
  35063. /**
  35064. * Switch audio to headphone output.
  35065. */
  35066. switchAudioModeForHeadphones(): void;
  35067. /**
  35068. * Switch audio to normal speakers.
  35069. */
  35070. switchAudioModeForNormalSpeakers(): void;
  35071. private _afterRender;
  35072. }
  35073. }
  35074. declare module "babylonjs/Audio/weightedsound" {
  35075. import { Sound } from "babylonjs/Audio/sound";
  35076. /**
  35077. * Wraps one or more Sound objects and selects one with random weight for playback.
  35078. */
  35079. export class WeightedSound {
  35080. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35081. loop: boolean;
  35082. private _coneInnerAngle;
  35083. private _coneOuterAngle;
  35084. private _volume;
  35085. /** A Sound is currently playing. */
  35086. isPlaying: boolean;
  35087. /** A Sound is currently paused. */
  35088. isPaused: boolean;
  35089. private _sounds;
  35090. private _weights;
  35091. private _currentIndex?;
  35092. /**
  35093. * Creates a new WeightedSound from the list of sounds given.
  35094. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35095. * @param sounds Array of Sounds that will be selected from.
  35096. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35097. */
  35098. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35099. /**
  35100. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35101. */
  35102. /**
  35103. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35104. */
  35105. directionalConeInnerAngle: number;
  35106. /**
  35107. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35108. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35109. */
  35110. /**
  35111. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35112. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35113. */
  35114. directionalConeOuterAngle: number;
  35115. /**
  35116. * Playback volume.
  35117. */
  35118. /**
  35119. * Playback volume.
  35120. */
  35121. volume: number;
  35122. private _onended;
  35123. /**
  35124. * Suspend playback
  35125. */
  35126. pause(): void;
  35127. /**
  35128. * Stop playback
  35129. */
  35130. stop(): void;
  35131. /**
  35132. * Start playback.
  35133. * @param startOffset Position the clip head at a specific time in seconds.
  35134. */
  35135. play(startOffset?: number): void;
  35136. }
  35137. }
  35138. declare module "babylonjs/Audio/index" {
  35139. export * from "babylonjs/Audio/analyser";
  35140. export * from "babylonjs/Audio/audioEngine";
  35141. export * from "babylonjs/Audio/audioSceneComponent";
  35142. export * from "babylonjs/Audio/sound";
  35143. export * from "babylonjs/Audio/soundTrack";
  35144. export * from "babylonjs/Audio/weightedsound";
  35145. }
  35146. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35147. import { Behavior } from "babylonjs/Behaviors/behavior";
  35148. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35149. import { BackEase } from "babylonjs/Animations/easing";
  35150. /**
  35151. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35153. */
  35154. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35155. /**
  35156. * Gets the name of the behavior.
  35157. */
  35158. readonly name: string;
  35159. /**
  35160. * The easing function used by animations
  35161. */
  35162. static EasingFunction: BackEase;
  35163. /**
  35164. * The easing mode used by animations
  35165. */
  35166. static EasingMode: number;
  35167. /**
  35168. * The duration of the animation, in milliseconds
  35169. */
  35170. transitionDuration: number;
  35171. /**
  35172. * Length of the distance animated by the transition when lower radius is reached
  35173. */
  35174. lowerRadiusTransitionRange: number;
  35175. /**
  35176. * Length of the distance animated by the transition when upper radius is reached
  35177. */
  35178. upperRadiusTransitionRange: number;
  35179. private _autoTransitionRange;
  35180. /**
  35181. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35182. */
  35183. /**
  35184. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35185. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35186. */
  35187. autoTransitionRange: boolean;
  35188. private _attachedCamera;
  35189. private _onAfterCheckInputsObserver;
  35190. private _onMeshTargetChangedObserver;
  35191. /**
  35192. * Initializes the behavior.
  35193. */
  35194. init(): void;
  35195. /**
  35196. * Attaches the behavior to its arc rotate camera.
  35197. * @param camera Defines the camera to attach the behavior to
  35198. */
  35199. attach(camera: ArcRotateCamera): void;
  35200. /**
  35201. * Detaches the behavior from its current arc rotate camera.
  35202. */
  35203. detach(): void;
  35204. private _radiusIsAnimating;
  35205. private _radiusBounceTransition;
  35206. private _animatables;
  35207. private _cachedWheelPrecision;
  35208. /**
  35209. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35210. * @param radiusLimit The limit to check against.
  35211. * @return Bool to indicate if at limit.
  35212. */
  35213. private _isRadiusAtLimit;
  35214. /**
  35215. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35216. * @param radiusDelta The delta by which to animate to. Can be negative.
  35217. */
  35218. private _applyBoundRadiusAnimation;
  35219. /**
  35220. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35221. */
  35222. protected _clearAnimationLocks(): void;
  35223. /**
  35224. * Stops and removes all animations that have been applied to the camera
  35225. */
  35226. stopAllAnimations(): void;
  35227. }
  35228. }
  35229. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35230. import { Behavior } from "babylonjs/Behaviors/behavior";
  35231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35232. import { ExponentialEase } from "babylonjs/Animations/easing";
  35233. import { Nullable } from "babylonjs/types";
  35234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35235. import { Vector3 } from "babylonjs/Maths/math";
  35236. /**
  35237. * 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.
  35238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35239. */
  35240. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35241. /**
  35242. * Gets the name of the behavior.
  35243. */
  35244. readonly name: string;
  35245. private _mode;
  35246. private _radiusScale;
  35247. private _positionScale;
  35248. private _defaultElevation;
  35249. private _elevationReturnTime;
  35250. private _elevationReturnWaitTime;
  35251. private _zoomStopsAnimation;
  35252. private _framingTime;
  35253. /**
  35254. * The easing function used by animations
  35255. */
  35256. static EasingFunction: ExponentialEase;
  35257. /**
  35258. * The easing mode used by animations
  35259. */
  35260. static EasingMode: number;
  35261. /**
  35262. * Sets the current mode used by the behavior
  35263. */
  35264. /**
  35265. * Gets current mode used by the behavior.
  35266. */
  35267. mode: number;
  35268. /**
  35269. * Sets the scale applied to the radius (1 by default)
  35270. */
  35271. /**
  35272. * Gets the scale applied to the radius
  35273. */
  35274. radiusScale: number;
  35275. /**
  35276. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35277. */
  35278. /**
  35279. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35280. */
  35281. positionScale: number;
  35282. /**
  35283. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35284. * behaviour is triggered, in radians.
  35285. */
  35286. /**
  35287. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35288. * behaviour is triggered, in radians.
  35289. */
  35290. defaultElevation: number;
  35291. /**
  35292. * Sets the time (in milliseconds) taken to return to the default beta position.
  35293. * Negative value indicates camera should not return to default.
  35294. */
  35295. /**
  35296. * Gets the time (in milliseconds) taken to return to the default beta position.
  35297. * Negative value indicates camera should not return to default.
  35298. */
  35299. elevationReturnTime: number;
  35300. /**
  35301. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35302. */
  35303. /**
  35304. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35305. */
  35306. elevationReturnWaitTime: number;
  35307. /**
  35308. * Sets the flag that indicates if user zooming should stop animation.
  35309. */
  35310. /**
  35311. * Gets the flag that indicates if user zooming should stop animation.
  35312. */
  35313. zoomStopsAnimation: boolean;
  35314. /**
  35315. * Sets the transition time when framing the mesh, in milliseconds
  35316. */
  35317. /**
  35318. * Gets the transition time when framing the mesh, in milliseconds
  35319. */
  35320. framingTime: number;
  35321. /**
  35322. * Define if the behavior should automatically change the configured
  35323. * camera limits and sensibilities.
  35324. */
  35325. autoCorrectCameraLimitsAndSensibility: boolean;
  35326. private _onPrePointerObservableObserver;
  35327. private _onAfterCheckInputsObserver;
  35328. private _onMeshTargetChangedObserver;
  35329. private _attachedCamera;
  35330. private _isPointerDown;
  35331. private _lastInteractionTime;
  35332. /**
  35333. * Initializes the behavior.
  35334. */
  35335. init(): void;
  35336. /**
  35337. * Attaches the behavior to its arc rotate camera.
  35338. * @param camera Defines the camera to attach the behavior to
  35339. */
  35340. attach(camera: ArcRotateCamera): void;
  35341. /**
  35342. * Detaches the behavior from its current arc rotate camera.
  35343. */
  35344. detach(): void;
  35345. private _animatables;
  35346. private _betaIsAnimating;
  35347. private _betaTransition;
  35348. private _radiusTransition;
  35349. private _vectorTransition;
  35350. /**
  35351. * Targets the given mesh and updates zoom level accordingly.
  35352. * @param mesh The mesh to target.
  35353. * @param radius Optional. If a cached radius position already exists, overrides default.
  35354. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35355. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35356. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35357. */
  35358. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35359. /**
  35360. * Targets the given mesh with its children and updates zoom level accordingly.
  35361. * @param mesh The mesh to target.
  35362. * @param radius Optional. If a cached radius position already exists, overrides default.
  35363. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35364. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35365. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35366. */
  35367. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35368. /**
  35369. * Targets the given meshes with their children and updates zoom level accordingly.
  35370. * @param meshes The mesh to target.
  35371. * @param radius Optional. If a cached radius position already exists, overrides default.
  35372. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35373. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35374. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35375. */
  35376. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35377. /**
  35378. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35379. * @param minimumWorld Determines the smaller position of the bounding box extend
  35380. * @param maximumWorld Determines the bigger position of the bounding box extend
  35381. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35382. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35383. */
  35384. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35385. /**
  35386. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35387. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35388. * frustum width.
  35389. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35390. * to fully enclose the mesh in the viewing frustum.
  35391. */
  35392. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35393. /**
  35394. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35395. * is automatically returned to its default position (expected to be above ground plane).
  35396. */
  35397. private _maintainCameraAboveGround;
  35398. /**
  35399. * Returns the frustum slope based on the canvas ratio and camera FOV
  35400. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35401. */
  35402. private _getFrustumSlope;
  35403. /**
  35404. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35405. */
  35406. private _clearAnimationLocks;
  35407. /**
  35408. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35409. */
  35410. private _applyUserInteraction;
  35411. /**
  35412. * Stops and removes all animations that have been applied to the camera
  35413. */
  35414. stopAllAnimations(): void;
  35415. /**
  35416. * Gets a value indicating if the user is moving the camera
  35417. */
  35418. readonly isUserIsMoving: boolean;
  35419. /**
  35420. * The camera can move all the way towards the mesh.
  35421. */
  35422. static IgnoreBoundsSizeMode: number;
  35423. /**
  35424. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35425. */
  35426. static FitFrustumSidesMode: number;
  35427. }
  35428. }
  35429. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35430. import { Nullable } from "babylonjs/types";
  35431. import { Camera } from "babylonjs/Cameras/camera";
  35432. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35433. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35434. /**
  35435. * Base class for Camera Pointer Inputs.
  35436. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35437. * for example usage.
  35438. */
  35439. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35440. /**
  35441. * Defines the camera the input is attached to.
  35442. */
  35443. abstract camera: Camera;
  35444. /**
  35445. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35446. */
  35447. protected _altKey: boolean;
  35448. protected _ctrlKey: boolean;
  35449. protected _metaKey: boolean;
  35450. protected _shiftKey: boolean;
  35451. /**
  35452. * Which mouse buttons were pressed at time of last mouse event.
  35453. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35454. */
  35455. protected _buttonsPressed: number;
  35456. /**
  35457. * Defines the buttons associated with the input to handle camera move.
  35458. */
  35459. buttons: number[];
  35460. /**
  35461. * Attach the input controls to a specific dom element to get the input from.
  35462. * @param element Defines the element the controls should be listened from
  35463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35464. */
  35465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35466. /**
  35467. * Detach the current controls from the specified dom element.
  35468. * @param element Defines the element to stop listening the inputs from
  35469. */
  35470. detachControl(element: Nullable<HTMLElement>): void;
  35471. /**
  35472. * Gets the class name of the current input.
  35473. * @returns the class name
  35474. */
  35475. getClassName(): string;
  35476. /**
  35477. * Get the friendly name associated with the input class.
  35478. * @returns the input friendly name
  35479. */
  35480. getSimpleName(): string;
  35481. /**
  35482. * Called on pointer POINTERDOUBLETAP event.
  35483. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35484. */
  35485. protected onDoubleTap(type: string): void;
  35486. /**
  35487. * Called on pointer POINTERMOVE event if only a single touch is active.
  35488. * Override this method to provide functionality.
  35489. */
  35490. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35491. /**
  35492. * Called on pointer POINTERMOVE event if multiple touches are active.
  35493. * Override this method to provide functionality.
  35494. */
  35495. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35496. /**
  35497. * Called on JS contextmenu event.
  35498. * Override this method to provide functionality.
  35499. */
  35500. protected onContextMenu(evt: PointerEvent): void;
  35501. /**
  35502. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35503. * press.
  35504. * Override this method to provide functionality.
  35505. */
  35506. protected onButtonDown(evt: PointerEvent): void;
  35507. /**
  35508. * Called each time a new POINTERUP event occurs. Ie, for each button
  35509. * release.
  35510. * Override this method to provide functionality.
  35511. */
  35512. protected onButtonUp(evt: PointerEvent): void;
  35513. /**
  35514. * Called when window becomes inactive.
  35515. * Override this method to provide functionality.
  35516. */
  35517. protected onLostFocus(): void;
  35518. private _pointerInput;
  35519. private _observer;
  35520. private _onLostFocus;
  35521. private pointA;
  35522. private pointB;
  35523. }
  35524. }
  35525. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35526. import { Nullable } from "babylonjs/types";
  35527. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35528. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35529. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35530. /**
  35531. * Manage the pointers inputs to control an arc rotate camera.
  35532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35533. */
  35534. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35535. /**
  35536. * Defines the camera the input is attached to.
  35537. */
  35538. camera: ArcRotateCamera;
  35539. /**
  35540. * Gets the class name of the current input.
  35541. * @returns the class name
  35542. */
  35543. getClassName(): string;
  35544. /**
  35545. * Defines the buttons associated with the input to handle camera move.
  35546. */
  35547. buttons: number[];
  35548. /**
  35549. * Defines the pointer angular sensibility along the X axis or how fast is
  35550. * the camera rotating.
  35551. */
  35552. angularSensibilityX: number;
  35553. /**
  35554. * Defines the pointer angular sensibility along the Y axis or how fast is
  35555. * the camera rotating.
  35556. */
  35557. angularSensibilityY: number;
  35558. /**
  35559. * Defines the pointer pinch precision or how fast is the camera zooming.
  35560. */
  35561. pinchPrecision: number;
  35562. /**
  35563. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35564. * from 0.
  35565. * It defines the percentage of current camera.radius to use as delta when
  35566. * pinch zoom is used.
  35567. */
  35568. pinchDeltaPercentage: number;
  35569. /**
  35570. * Defines the pointer panning sensibility or how fast is the camera moving.
  35571. */
  35572. panningSensibility: number;
  35573. /**
  35574. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35575. */
  35576. multiTouchPanning: boolean;
  35577. /**
  35578. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35579. * zoom (pinch) through multitouch.
  35580. */
  35581. multiTouchPanAndZoom: boolean;
  35582. /**
  35583. * Revers pinch action direction.
  35584. */
  35585. pinchInwards: boolean;
  35586. private _isPanClick;
  35587. private _twoFingerActivityCount;
  35588. private _isPinching;
  35589. /**
  35590. * Called on pointer POINTERMOVE event if only a single touch is active.
  35591. */
  35592. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35593. /**
  35594. * Called on pointer POINTERDOUBLETAP event.
  35595. */
  35596. protected onDoubleTap(type: string): void;
  35597. /**
  35598. * Called on pointer POINTERMOVE event if multiple touches are active.
  35599. */
  35600. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35601. /**
  35602. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35603. * press.
  35604. */
  35605. protected onButtonDown(evt: PointerEvent): void;
  35606. /**
  35607. * Called each time a new POINTERUP event occurs. Ie, for each button
  35608. * release.
  35609. */
  35610. protected onButtonUp(evt: PointerEvent): void;
  35611. /**
  35612. * Called when window becomes inactive.
  35613. */
  35614. protected onLostFocus(): void;
  35615. }
  35616. }
  35617. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35618. import { Nullable } from "babylonjs/types";
  35619. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35620. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35621. /**
  35622. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35624. */
  35625. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35626. /**
  35627. * Defines the camera the input is attached to.
  35628. */
  35629. camera: ArcRotateCamera;
  35630. /**
  35631. * Defines the list of key codes associated with the up action (increase alpha)
  35632. */
  35633. keysUp: number[];
  35634. /**
  35635. * Defines the list of key codes associated with the down action (decrease alpha)
  35636. */
  35637. keysDown: number[];
  35638. /**
  35639. * Defines the list of key codes associated with the left action (increase beta)
  35640. */
  35641. keysLeft: number[];
  35642. /**
  35643. * Defines the list of key codes associated with the right action (decrease beta)
  35644. */
  35645. keysRight: number[];
  35646. /**
  35647. * Defines the list of key codes associated with the reset action.
  35648. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35649. */
  35650. keysReset: number[];
  35651. /**
  35652. * Defines the panning sensibility of the inputs.
  35653. * (How fast is the camera paning)
  35654. */
  35655. panningSensibility: number;
  35656. /**
  35657. * Defines the zooming sensibility of the inputs.
  35658. * (How fast is the camera zooming)
  35659. */
  35660. zoomingSensibility: number;
  35661. /**
  35662. * Defines wether maintaining the alt key down switch the movement mode from
  35663. * orientation to zoom.
  35664. */
  35665. useAltToZoom: boolean;
  35666. /**
  35667. * Rotation speed of the camera
  35668. */
  35669. angularSpeed: number;
  35670. private _keys;
  35671. private _ctrlPressed;
  35672. private _altPressed;
  35673. private _onCanvasBlurObserver;
  35674. private _onKeyboardObserver;
  35675. private _engine;
  35676. private _scene;
  35677. /**
  35678. * Attach the input controls to a specific dom element to get the input from.
  35679. * @param element Defines the element the controls should be listened from
  35680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35681. */
  35682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35683. /**
  35684. * Detach the current controls from the specified dom element.
  35685. * @param element Defines the element to stop listening the inputs from
  35686. */
  35687. detachControl(element: Nullable<HTMLElement>): void;
  35688. /**
  35689. * Update the current camera state depending on the inputs that have been used this frame.
  35690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35691. */
  35692. checkInputs(): void;
  35693. /**
  35694. * Gets the class name of the current intput.
  35695. * @returns the class name
  35696. */
  35697. getClassName(): string;
  35698. /**
  35699. * Get the friendly name associated with the input class.
  35700. * @returns the input friendly name
  35701. */
  35702. getSimpleName(): string;
  35703. }
  35704. }
  35705. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35706. import { Nullable } from "babylonjs/types";
  35707. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35708. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35709. /**
  35710. * Manage the mouse wheel inputs to control an arc rotate camera.
  35711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35712. */
  35713. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35714. /**
  35715. * Defines the camera the input is attached to.
  35716. */
  35717. camera: ArcRotateCamera;
  35718. /**
  35719. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35720. */
  35721. wheelPrecision: number;
  35722. /**
  35723. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35724. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35725. */
  35726. wheelDeltaPercentage: number;
  35727. private _wheel;
  35728. private _observer;
  35729. /**
  35730. * Attach the input controls to a specific dom element to get the input from.
  35731. * @param element Defines the element the controls should be listened from
  35732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35733. */
  35734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35735. /**
  35736. * Detach the current controls from the specified dom element.
  35737. * @param element Defines the element to stop listening the inputs from
  35738. */
  35739. detachControl(element: Nullable<HTMLElement>): void;
  35740. /**
  35741. * Gets the class name of the current intput.
  35742. * @returns the class name
  35743. */
  35744. getClassName(): string;
  35745. /**
  35746. * Get the friendly name associated with the input class.
  35747. * @returns the input friendly name
  35748. */
  35749. getSimpleName(): string;
  35750. }
  35751. }
  35752. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35753. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35754. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35755. /**
  35756. * Default Inputs manager for the ArcRotateCamera.
  35757. * It groups all the default supported inputs for ease of use.
  35758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35759. */
  35760. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35761. /**
  35762. * Instantiates a new ArcRotateCameraInputsManager.
  35763. * @param camera Defines the camera the inputs belong to
  35764. */
  35765. constructor(camera: ArcRotateCamera);
  35766. /**
  35767. * Add mouse wheel input support to the input manager.
  35768. * @returns the current input manager
  35769. */
  35770. addMouseWheel(): ArcRotateCameraInputsManager;
  35771. /**
  35772. * Add pointers input support to the input manager.
  35773. * @returns the current input manager
  35774. */
  35775. addPointers(): ArcRotateCameraInputsManager;
  35776. /**
  35777. * Add keyboard input support to the input manager.
  35778. * @returns the current input manager
  35779. */
  35780. addKeyboard(): ArcRotateCameraInputsManager;
  35781. }
  35782. }
  35783. declare module "babylonjs/Cameras/arcRotateCamera" {
  35784. import { Observable } from "babylonjs/Misc/observable";
  35785. import { Nullable } from "babylonjs/types";
  35786. import { Scene } from "babylonjs/scene";
  35787. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35789. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35790. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35791. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35792. import { Camera } from "babylonjs/Cameras/camera";
  35793. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35794. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35795. import { Collider } from "babylonjs/Collisions/collider";
  35796. /**
  35797. * This represents an orbital type of camera.
  35798. *
  35799. * 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.
  35800. * 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.
  35801. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35802. */
  35803. export class ArcRotateCamera extends TargetCamera {
  35804. /**
  35805. * Defines the rotation angle of the camera along the longitudinal axis.
  35806. */
  35807. alpha: number;
  35808. /**
  35809. * Defines the rotation angle of the camera along the latitudinal axis.
  35810. */
  35811. beta: number;
  35812. /**
  35813. * Defines the radius of the camera from it s target point.
  35814. */
  35815. radius: number;
  35816. protected _target: Vector3;
  35817. protected _targetHost: Nullable<AbstractMesh>;
  35818. /**
  35819. * Defines the target point of the camera.
  35820. * The camera looks towards it form the radius distance.
  35821. */
  35822. target: Vector3;
  35823. /**
  35824. * Define the current local position of the camera in the scene
  35825. */
  35826. position: Vector3;
  35827. /**
  35828. * Current inertia value on the longitudinal axis.
  35829. * The bigger this number the longer it will take for the camera to stop.
  35830. */
  35831. inertialAlphaOffset: number;
  35832. /**
  35833. * Current inertia value on the latitudinal axis.
  35834. * The bigger this number the longer it will take for the camera to stop.
  35835. */
  35836. inertialBetaOffset: number;
  35837. /**
  35838. * Current inertia value on the radius axis.
  35839. * The bigger this number the longer it will take for the camera to stop.
  35840. */
  35841. inertialRadiusOffset: number;
  35842. /**
  35843. * Minimum allowed angle on the longitudinal axis.
  35844. * This can help limiting how the Camera is able to move in the scene.
  35845. */
  35846. lowerAlphaLimit: Nullable<number>;
  35847. /**
  35848. * Maximum allowed angle on the longitudinal axis.
  35849. * This can help limiting how the Camera is able to move in the scene.
  35850. */
  35851. upperAlphaLimit: Nullable<number>;
  35852. /**
  35853. * Minimum allowed angle on the latitudinal axis.
  35854. * This can help limiting how the Camera is able to move in the scene.
  35855. */
  35856. lowerBetaLimit: number;
  35857. /**
  35858. * Maximum allowed angle on the latitudinal axis.
  35859. * This can help limiting how the Camera is able to move in the scene.
  35860. */
  35861. upperBetaLimit: number;
  35862. /**
  35863. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35864. * This can help limiting how the Camera is able to move in the scene.
  35865. */
  35866. lowerRadiusLimit: Nullable<number>;
  35867. /**
  35868. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35869. * This can help limiting how the Camera is able to move in the scene.
  35870. */
  35871. upperRadiusLimit: Nullable<number>;
  35872. /**
  35873. * Defines the current inertia value used during panning of the camera along the X axis.
  35874. */
  35875. inertialPanningX: number;
  35876. /**
  35877. * Defines the current inertia value used during panning of the camera along the Y axis.
  35878. */
  35879. inertialPanningY: number;
  35880. /**
  35881. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35882. * Basically if your fingers moves away from more than this distance you will be considered
  35883. * in pinch mode.
  35884. */
  35885. pinchToPanMaxDistance: number;
  35886. /**
  35887. * Defines the maximum distance the camera can pan.
  35888. * This could help keeping the cammera always in your scene.
  35889. */
  35890. panningDistanceLimit: Nullable<number>;
  35891. /**
  35892. * Defines the target of the camera before paning.
  35893. */
  35894. panningOriginTarget: Vector3;
  35895. /**
  35896. * Defines the value of the inertia used during panning.
  35897. * 0 would mean stop inertia and one would mean no decelleration at all.
  35898. */
  35899. panningInertia: number;
  35900. /**
  35901. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35902. */
  35903. angularSensibilityX: number;
  35904. /**
  35905. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35906. */
  35907. angularSensibilityY: number;
  35908. /**
  35909. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35910. */
  35911. pinchPrecision: number;
  35912. /**
  35913. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35914. * It will be used instead of pinchDeltaPrecision if different from 0.
  35915. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35916. */
  35917. pinchDeltaPercentage: number;
  35918. /**
  35919. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35920. */
  35921. panningSensibility: number;
  35922. /**
  35923. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35924. */
  35925. keysUp: number[];
  35926. /**
  35927. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35928. */
  35929. keysDown: number[];
  35930. /**
  35931. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35932. */
  35933. keysLeft: number[];
  35934. /**
  35935. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35936. */
  35937. keysRight: number[];
  35938. /**
  35939. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35940. */
  35941. wheelPrecision: number;
  35942. /**
  35943. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35944. * It will be used instead of pinchDeltaPrecision if different from 0.
  35945. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35946. */
  35947. wheelDeltaPercentage: number;
  35948. /**
  35949. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35950. */
  35951. zoomOnFactor: number;
  35952. /**
  35953. * Defines a screen offset for the camera position.
  35954. */
  35955. targetScreenOffset: Vector2;
  35956. /**
  35957. * Allows the camera to be completely reversed.
  35958. * If false the camera can not arrive upside down.
  35959. */
  35960. allowUpsideDown: boolean;
  35961. /**
  35962. * Define if double tap/click is used to restore the previously saved state of the camera.
  35963. */
  35964. useInputToRestoreState: boolean;
  35965. /** @hidden */
  35966. _viewMatrix: Matrix;
  35967. /** @hidden */
  35968. _useCtrlForPanning: boolean;
  35969. /** @hidden */
  35970. _panningMouseButton: number;
  35971. /**
  35972. * Defines the input associated to the camera.
  35973. */
  35974. inputs: ArcRotateCameraInputsManager;
  35975. /** @hidden */
  35976. _reset: () => void;
  35977. /**
  35978. * Defines the allowed panning axis.
  35979. */
  35980. panningAxis: Vector3;
  35981. protected _localDirection: Vector3;
  35982. protected _transformedDirection: Vector3;
  35983. private _bouncingBehavior;
  35984. /**
  35985. * Gets the bouncing behavior of the camera if it has been enabled.
  35986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35987. */
  35988. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35989. /**
  35990. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35992. */
  35993. useBouncingBehavior: boolean;
  35994. private _framingBehavior;
  35995. /**
  35996. * Gets the framing behavior of the camera if it has been enabled.
  35997. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35998. */
  35999. readonly framingBehavior: Nullable<FramingBehavior>;
  36000. /**
  36001. * Defines if the framing behavior of the camera is enabled on the camera.
  36002. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36003. */
  36004. useFramingBehavior: boolean;
  36005. private _autoRotationBehavior;
  36006. /**
  36007. * Gets the auto rotation behavior of the camera if it has been enabled.
  36008. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36009. */
  36010. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36011. /**
  36012. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36014. */
  36015. useAutoRotationBehavior: boolean;
  36016. /**
  36017. * Observable triggered when the mesh target has been changed on the camera.
  36018. */
  36019. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36020. /**
  36021. * Event raised when the camera is colliding with a mesh.
  36022. */
  36023. onCollide: (collidedMesh: AbstractMesh) => void;
  36024. /**
  36025. * Defines whether the camera should check collision with the objects oh the scene.
  36026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36027. */
  36028. checkCollisions: boolean;
  36029. /**
  36030. * Defines the collision radius of the camera.
  36031. * This simulates a sphere around the camera.
  36032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36033. */
  36034. collisionRadius: Vector3;
  36035. protected _collider: Collider;
  36036. protected _previousPosition: Vector3;
  36037. protected _collisionVelocity: Vector3;
  36038. protected _newPosition: Vector3;
  36039. protected _previousAlpha: number;
  36040. protected _previousBeta: number;
  36041. protected _previousRadius: number;
  36042. protected _collisionTriggered: boolean;
  36043. protected _targetBoundingCenter: Nullable<Vector3>;
  36044. private _computationVector;
  36045. private _tempAxisVector;
  36046. private _tempAxisRotationMatrix;
  36047. /**
  36048. * Instantiates a new ArcRotateCamera in a given scene
  36049. * @param name Defines the name of the camera
  36050. * @param alpha Defines the camera rotation along the logitudinal axis
  36051. * @param beta Defines the camera rotation along the latitudinal axis
  36052. * @param radius Defines the camera distance from its target
  36053. * @param target Defines the camera target
  36054. * @param scene Defines the scene the camera belongs to
  36055. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36056. */
  36057. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36058. /** @hidden */
  36059. _initCache(): void;
  36060. /** @hidden */
  36061. _updateCache(ignoreParentClass?: boolean): void;
  36062. protected _getTargetPosition(): Vector3;
  36063. private _storedAlpha;
  36064. private _storedBeta;
  36065. private _storedRadius;
  36066. private _storedTarget;
  36067. /**
  36068. * Stores the current state of the camera (alpha, beta, radius and target)
  36069. * @returns the camera itself
  36070. */
  36071. storeState(): Camera;
  36072. /**
  36073. * @hidden
  36074. * Restored camera state. You must call storeState() first
  36075. */
  36076. _restoreStateValues(): boolean;
  36077. /** @hidden */
  36078. _isSynchronizedViewMatrix(): boolean;
  36079. /**
  36080. * Attached controls to the current camera.
  36081. * @param element Defines the element the controls should be listened from
  36082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36083. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36084. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36085. */
  36086. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36087. /**
  36088. * Detach the current controls from the camera.
  36089. * The camera will stop reacting to inputs.
  36090. * @param element Defines the element to stop listening the inputs from
  36091. */
  36092. detachControl(element: HTMLElement): void;
  36093. /** @hidden */
  36094. _checkInputs(): void;
  36095. protected _checkLimits(): void;
  36096. /**
  36097. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36098. */
  36099. rebuildAnglesAndRadius(): void;
  36100. /**
  36101. * Use a position to define the current camera related information like aplha, beta and radius
  36102. * @param position Defines the position to set the camera at
  36103. */
  36104. setPosition(position: Vector3): void;
  36105. /**
  36106. * Defines the target the camera should look at.
  36107. * This will automatically adapt alpha beta and radius to fit within the new target.
  36108. * @param target Defines the new target as a Vector or a mesh
  36109. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36110. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36111. */
  36112. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36113. /** @hidden */
  36114. _getViewMatrix(): Matrix;
  36115. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36116. /**
  36117. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36118. * @param meshes Defines the mesh to zoom on
  36119. * @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)
  36120. */
  36121. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36122. /**
  36123. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36124. * The target will be changed but the radius
  36125. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36126. * @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)
  36127. */
  36128. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36129. min: Vector3;
  36130. max: Vector3;
  36131. distance: number;
  36132. }, doNotUpdateMaxZ?: boolean): void;
  36133. /**
  36134. * @override
  36135. * Override Camera.createRigCamera
  36136. */
  36137. createRigCamera(name: string, cameraIndex: number): Camera;
  36138. /**
  36139. * @hidden
  36140. * @override
  36141. * Override Camera._updateRigCameras
  36142. */
  36143. _updateRigCameras(): void;
  36144. /**
  36145. * Destroy the camera and release the current resources hold by it.
  36146. */
  36147. dispose(): void;
  36148. /**
  36149. * Gets the current object class name.
  36150. * @return the class name
  36151. */
  36152. getClassName(): string;
  36153. }
  36154. }
  36155. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36156. import { Behavior } from "babylonjs/Behaviors/behavior";
  36157. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36158. /**
  36159. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36160. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36161. */
  36162. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36163. /**
  36164. * Gets the name of the behavior.
  36165. */
  36166. readonly name: string;
  36167. private _zoomStopsAnimation;
  36168. private _idleRotationSpeed;
  36169. private _idleRotationWaitTime;
  36170. private _idleRotationSpinupTime;
  36171. /**
  36172. * Sets the flag that indicates if user zooming should stop animation.
  36173. */
  36174. /**
  36175. * Gets the flag that indicates if user zooming should stop animation.
  36176. */
  36177. zoomStopsAnimation: boolean;
  36178. /**
  36179. * Sets the default speed at which the camera rotates around the model.
  36180. */
  36181. /**
  36182. * Gets the default speed at which the camera rotates around the model.
  36183. */
  36184. idleRotationSpeed: number;
  36185. /**
  36186. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36187. */
  36188. /**
  36189. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36190. */
  36191. idleRotationWaitTime: number;
  36192. /**
  36193. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36194. */
  36195. /**
  36196. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36197. */
  36198. idleRotationSpinupTime: number;
  36199. /**
  36200. * Gets a value indicating if the camera is currently rotating because of this behavior
  36201. */
  36202. readonly rotationInProgress: boolean;
  36203. private _onPrePointerObservableObserver;
  36204. private _onAfterCheckInputsObserver;
  36205. private _attachedCamera;
  36206. private _isPointerDown;
  36207. private _lastFrameTime;
  36208. private _lastInteractionTime;
  36209. private _cameraRotationSpeed;
  36210. /**
  36211. * Initializes the behavior.
  36212. */
  36213. init(): void;
  36214. /**
  36215. * Attaches the behavior to its arc rotate camera.
  36216. * @param camera Defines the camera to attach the behavior to
  36217. */
  36218. attach(camera: ArcRotateCamera): void;
  36219. /**
  36220. * Detaches the behavior from its current arc rotate camera.
  36221. */
  36222. detach(): void;
  36223. /**
  36224. * Returns true if user is scrolling.
  36225. * @return true if user is scrolling.
  36226. */
  36227. private _userIsZooming;
  36228. private _lastFrameRadius;
  36229. private _shouldAnimationStopForInteraction;
  36230. /**
  36231. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36232. */
  36233. private _applyUserInteraction;
  36234. private _userIsMoving;
  36235. }
  36236. }
  36237. declare module "babylonjs/Behaviors/Cameras/index" {
  36238. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36239. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36240. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36241. }
  36242. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36243. import { Mesh } from "babylonjs/Meshes/mesh";
  36244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36245. import { Behavior } from "babylonjs/Behaviors/behavior";
  36246. /**
  36247. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36248. */
  36249. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36250. private ui;
  36251. /**
  36252. * The name of the behavior
  36253. */
  36254. name: string;
  36255. /**
  36256. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36257. */
  36258. distanceAwayFromFace: number;
  36259. /**
  36260. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36261. */
  36262. distanceAwayFromBottomOfFace: number;
  36263. private _faceVectors;
  36264. private _target;
  36265. private _scene;
  36266. private _onRenderObserver;
  36267. private _tmpMatrix;
  36268. private _tmpVector;
  36269. /**
  36270. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36271. * @param ui The transform node that should be attched to the mesh
  36272. */
  36273. constructor(ui: TransformNode);
  36274. /**
  36275. * Initializes the behavior
  36276. */
  36277. init(): void;
  36278. private _closestFace;
  36279. private _zeroVector;
  36280. private _lookAtTmpMatrix;
  36281. private _lookAtToRef;
  36282. /**
  36283. * Attaches the AttachToBoxBehavior to the passed in mesh
  36284. * @param target The mesh that the specified node will be attached to
  36285. */
  36286. attach(target: Mesh): void;
  36287. /**
  36288. * Detaches the behavior from the mesh
  36289. */
  36290. detach(): void;
  36291. }
  36292. }
  36293. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36294. import { Behavior } from "babylonjs/Behaviors/behavior";
  36295. import { Mesh } from "babylonjs/Meshes/mesh";
  36296. /**
  36297. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36298. */
  36299. export class FadeInOutBehavior implements Behavior<Mesh> {
  36300. /**
  36301. * Time in milliseconds to delay before fading in (Default: 0)
  36302. */
  36303. delay: number;
  36304. /**
  36305. * Time in milliseconds for the mesh to fade in (Default: 300)
  36306. */
  36307. fadeInTime: number;
  36308. private _millisecondsPerFrame;
  36309. private _hovered;
  36310. private _hoverValue;
  36311. private _ownerNode;
  36312. /**
  36313. * Instatiates the FadeInOutBehavior
  36314. */
  36315. constructor();
  36316. /**
  36317. * The name of the behavior
  36318. */
  36319. readonly name: string;
  36320. /**
  36321. * Initializes the behavior
  36322. */
  36323. init(): void;
  36324. /**
  36325. * Attaches the fade behavior on the passed in mesh
  36326. * @param ownerNode The mesh that will be faded in/out once attached
  36327. */
  36328. attach(ownerNode: Mesh): void;
  36329. /**
  36330. * Detaches the behavior from the mesh
  36331. */
  36332. detach(): void;
  36333. /**
  36334. * Triggers the mesh to begin fading in or out
  36335. * @param value if the object should fade in or out (true to fade in)
  36336. */
  36337. fadeIn(value: boolean): void;
  36338. private _update;
  36339. private _setAllVisibility;
  36340. }
  36341. }
  36342. declare module "babylonjs/Misc/pivotTools" {
  36343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36344. /**
  36345. * Class containing a set of static utilities functions for managing Pivots
  36346. * @hidden
  36347. */
  36348. export class PivotTools {
  36349. private static _PivotCached;
  36350. private static _OldPivotPoint;
  36351. private static _PivotTranslation;
  36352. private static _PivotTmpVector;
  36353. /** @hidden */
  36354. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36355. /** @hidden */
  36356. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36357. }
  36358. }
  36359. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36360. import { Scene } from "babylonjs/scene";
  36361. import { Vector4, Plane } from "babylonjs/Maths/math";
  36362. import { Mesh } from "babylonjs/Meshes/mesh";
  36363. /**
  36364. * Class containing static functions to help procedurally build meshes
  36365. */
  36366. export class PlaneBuilder {
  36367. /**
  36368. * Creates a plane mesh
  36369. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36370. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36371. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36375. * @param name defines the name of the mesh
  36376. * @param options defines the options used to create the mesh
  36377. * @param scene defines the hosting scene
  36378. * @returns the plane mesh
  36379. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36380. */
  36381. static CreatePlane(name: string, options: {
  36382. size?: number;
  36383. width?: number;
  36384. height?: number;
  36385. sideOrientation?: number;
  36386. frontUVs?: Vector4;
  36387. backUVs?: Vector4;
  36388. updatable?: boolean;
  36389. sourcePlane?: Plane;
  36390. }, scene: Scene): Mesh;
  36391. }
  36392. }
  36393. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36394. import { Behavior } from "babylonjs/Behaviors/behavior";
  36395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36396. import { Observable } from "babylonjs/Misc/observable";
  36397. import { Vector3 } from "babylonjs/Maths/math";
  36398. import { Ray } from "babylonjs/Culling/ray";
  36399. import "babylonjs/Meshes/Builders/planeBuilder";
  36400. /**
  36401. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36402. */
  36403. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36404. private static _AnyMouseID;
  36405. private _attachedNode;
  36406. private _dragPlane;
  36407. private _scene;
  36408. private _pointerObserver;
  36409. private _beforeRenderObserver;
  36410. private static _planeScene;
  36411. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36412. /**
  36413. * 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)
  36414. */
  36415. maxDragAngle: number;
  36416. /**
  36417. * @hidden
  36418. */
  36419. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36420. /**
  36421. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36422. */
  36423. currentDraggingPointerID: number;
  36424. /**
  36425. * The last position where the pointer hit the drag plane in world space
  36426. */
  36427. lastDragPosition: Vector3;
  36428. /**
  36429. * If the behavior is currently in a dragging state
  36430. */
  36431. dragging: boolean;
  36432. /**
  36433. * 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)
  36434. */
  36435. dragDeltaRatio: number;
  36436. /**
  36437. * If the drag plane orientation should be updated during the dragging (Default: true)
  36438. */
  36439. updateDragPlane: boolean;
  36440. private _debugMode;
  36441. private _moving;
  36442. /**
  36443. * Fires each time the attached mesh is dragged with the pointer
  36444. * * delta between last drag position and current drag position in world space
  36445. * * dragDistance along the drag axis
  36446. * * dragPlaneNormal normal of the current drag plane used during the drag
  36447. * * dragPlanePoint in world space where the drag intersects the drag plane
  36448. */
  36449. onDragObservable: Observable<{
  36450. delta: Vector3;
  36451. dragPlanePoint: Vector3;
  36452. dragPlaneNormal: Vector3;
  36453. dragDistance: number;
  36454. pointerId: number;
  36455. }>;
  36456. /**
  36457. * Fires each time a drag begins (eg. mouse down on mesh)
  36458. */
  36459. onDragStartObservable: Observable<{
  36460. dragPlanePoint: Vector3;
  36461. pointerId: number;
  36462. }>;
  36463. /**
  36464. * Fires each time a drag ends (eg. mouse release after drag)
  36465. */
  36466. onDragEndObservable: Observable<{
  36467. dragPlanePoint: Vector3;
  36468. pointerId: number;
  36469. }>;
  36470. /**
  36471. * If the attached mesh should be moved when dragged
  36472. */
  36473. moveAttached: boolean;
  36474. /**
  36475. * If the drag behavior will react to drag events (Default: true)
  36476. */
  36477. enabled: boolean;
  36478. /**
  36479. * If camera controls should be detached during the drag
  36480. */
  36481. detachCameraControls: boolean;
  36482. /**
  36483. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36484. */
  36485. useObjectOrienationForDragging: boolean;
  36486. private _options;
  36487. /**
  36488. * Creates a pointer drag behavior that can be attached to a mesh
  36489. * @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)
  36490. */
  36491. constructor(options?: {
  36492. dragAxis?: Vector3;
  36493. dragPlaneNormal?: Vector3;
  36494. });
  36495. /**
  36496. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36497. */
  36498. validateDrag: (targetPosition: Vector3) => boolean;
  36499. /**
  36500. * The name of the behavior
  36501. */
  36502. readonly name: string;
  36503. /**
  36504. * Initializes the behavior
  36505. */
  36506. init(): void;
  36507. private _tmpVector;
  36508. private _alternatePickedPoint;
  36509. private _worldDragAxis;
  36510. private _targetPosition;
  36511. private _attachedElement;
  36512. /**
  36513. * Attaches the drag behavior the passed in mesh
  36514. * @param ownerNode The mesh that will be dragged around once attached
  36515. */
  36516. attach(ownerNode: AbstractMesh): void;
  36517. /**
  36518. * Force relase the drag action by code.
  36519. */
  36520. releaseDrag(): void;
  36521. private _startDragRay;
  36522. private _lastPointerRay;
  36523. /**
  36524. * Simulates the start of a pointer drag event on the behavior
  36525. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36526. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36527. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36528. */
  36529. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36530. private _startDrag;
  36531. private _dragDelta;
  36532. private _moveDrag;
  36533. private _pickWithRayOnDragPlane;
  36534. private _pointA;
  36535. private _pointB;
  36536. private _pointC;
  36537. private _lineA;
  36538. private _lineB;
  36539. private _localAxis;
  36540. private _lookAt;
  36541. private _updateDragPlanePosition;
  36542. /**
  36543. * Detaches the behavior from the mesh
  36544. */
  36545. detach(): void;
  36546. }
  36547. }
  36548. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36549. import { Mesh } from "babylonjs/Meshes/mesh";
  36550. import { Behavior } from "babylonjs/Behaviors/behavior";
  36551. /**
  36552. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36553. */
  36554. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36555. private _dragBehaviorA;
  36556. private _dragBehaviorB;
  36557. private _startDistance;
  36558. private _initialScale;
  36559. private _targetScale;
  36560. private _ownerNode;
  36561. private _sceneRenderObserver;
  36562. /**
  36563. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36564. */
  36565. constructor();
  36566. /**
  36567. * The name of the behavior
  36568. */
  36569. readonly name: string;
  36570. /**
  36571. * Initializes the behavior
  36572. */
  36573. init(): void;
  36574. private _getCurrentDistance;
  36575. /**
  36576. * Attaches the scale behavior the passed in mesh
  36577. * @param ownerNode The mesh that will be scaled around once attached
  36578. */
  36579. attach(ownerNode: Mesh): void;
  36580. /**
  36581. * Detaches the behavior from the mesh
  36582. */
  36583. detach(): void;
  36584. }
  36585. }
  36586. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36587. import { Behavior } from "babylonjs/Behaviors/behavior";
  36588. import { Mesh } from "babylonjs/Meshes/mesh";
  36589. import { Observable } from "babylonjs/Misc/observable";
  36590. /**
  36591. * 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
  36592. */
  36593. export class SixDofDragBehavior implements Behavior<Mesh> {
  36594. private static _virtualScene;
  36595. private _ownerNode;
  36596. private _sceneRenderObserver;
  36597. private _scene;
  36598. private _targetPosition;
  36599. private _virtualOriginMesh;
  36600. private _virtualDragMesh;
  36601. private _pointerObserver;
  36602. private _moving;
  36603. private _startingOrientation;
  36604. /**
  36605. * 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)
  36606. */
  36607. private zDragFactor;
  36608. /**
  36609. * If the object should rotate to face the drag origin
  36610. */
  36611. rotateDraggedObject: boolean;
  36612. /**
  36613. * If the behavior is currently in a dragging state
  36614. */
  36615. dragging: boolean;
  36616. /**
  36617. * 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)
  36618. */
  36619. dragDeltaRatio: number;
  36620. /**
  36621. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36622. */
  36623. currentDraggingPointerID: number;
  36624. /**
  36625. * If camera controls should be detached during the drag
  36626. */
  36627. detachCameraControls: boolean;
  36628. /**
  36629. * Fires each time a drag starts
  36630. */
  36631. onDragStartObservable: Observable<{}>;
  36632. /**
  36633. * Fires each time a drag ends (eg. mouse release after drag)
  36634. */
  36635. onDragEndObservable: Observable<{}>;
  36636. /**
  36637. * 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
  36638. */
  36639. constructor();
  36640. /**
  36641. * The name of the behavior
  36642. */
  36643. readonly name: string;
  36644. /**
  36645. * Initializes the behavior
  36646. */
  36647. init(): void;
  36648. /**
  36649. * Attaches the scale behavior the passed in mesh
  36650. * @param ownerNode The mesh that will be scaled around once attached
  36651. */
  36652. attach(ownerNode: Mesh): void;
  36653. /**
  36654. * Detaches the behavior from the mesh
  36655. */
  36656. detach(): void;
  36657. }
  36658. }
  36659. declare module "babylonjs/Behaviors/Meshes/index" {
  36660. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36661. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36662. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36663. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36664. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36665. }
  36666. declare module "babylonjs/Behaviors/index" {
  36667. export * from "babylonjs/Behaviors/behavior";
  36668. export * from "babylonjs/Behaviors/Cameras/index";
  36669. export * from "babylonjs/Behaviors/Meshes/index";
  36670. }
  36671. declare module "babylonjs/Bones/boneIKController" {
  36672. import { Bone } from "babylonjs/Bones/bone";
  36673. import { Vector3 } from "babylonjs/Maths/math";
  36674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36675. import { Nullable } from "babylonjs/types";
  36676. /**
  36677. * Class used to apply inverse kinematics to bones
  36678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36679. */
  36680. export class BoneIKController {
  36681. private static _tmpVecs;
  36682. private static _tmpQuat;
  36683. private static _tmpMats;
  36684. /**
  36685. * Gets or sets the target mesh
  36686. */
  36687. targetMesh: AbstractMesh;
  36688. /** Gets or sets the mesh used as pole */
  36689. poleTargetMesh: AbstractMesh;
  36690. /**
  36691. * Gets or sets the bone used as pole
  36692. */
  36693. poleTargetBone: Nullable<Bone>;
  36694. /**
  36695. * Gets or sets the target position
  36696. */
  36697. targetPosition: Vector3;
  36698. /**
  36699. * Gets or sets the pole target position
  36700. */
  36701. poleTargetPosition: Vector3;
  36702. /**
  36703. * Gets or sets the pole target local offset
  36704. */
  36705. poleTargetLocalOffset: Vector3;
  36706. /**
  36707. * Gets or sets the pole angle
  36708. */
  36709. poleAngle: number;
  36710. /**
  36711. * Gets or sets the mesh associated with the controller
  36712. */
  36713. mesh: AbstractMesh;
  36714. /**
  36715. * 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)
  36716. */
  36717. slerpAmount: number;
  36718. private _bone1Quat;
  36719. private _bone1Mat;
  36720. private _bone2Ang;
  36721. private _bone1;
  36722. private _bone2;
  36723. private _bone1Length;
  36724. private _bone2Length;
  36725. private _maxAngle;
  36726. private _maxReach;
  36727. private _rightHandedSystem;
  36728. private _bendAxis;
  36729. private _slerping;
  36730. private _adjustRoll;
  36731. /**
  36732. * Gets or sets maximum allowed angle
  36733. */
  36734. maxAngle: number;
  36735. /**
  36736. * Creates a new BoneIKController
  36737. * @param mesh defines the mesh to control
  36738. * @param bone defines the bone to control
  36739. * @param options defines options to set up the controller
  36740. */
  36741. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36742. targetMesh?: AbstractMesh;
  36743. poleTargetMesh?: AbstractMesh;
  36744. poleTargetBone?: Bone;
  36745. poleTargetLocalOffset?: Vector3;
  36746. poleAngle?: number;
  36747. bendAxis?: Vector3;
  36748. maxAngle?: number;
  36749. slerpAmount?: number;
  36750. });
  36751. private _setMaxAngle;
  36752. /**
  36753. * Force the controller to update the bones
  36754. */
  36755. update(): void;
  36756. }
  36757. }
  36758. declare module "babylonjs/Bones/boneLookController" {
  36759. import { Vector3, Space } from "babylonjs/Maths/math";
  36760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36761. import { Bone } from "babylonjs/Bones/bone";
  36762. /**
  36763. * Class used to make a bone look toward a point in space
  36764. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36765. */
  36766. export class BoneLookController {
  36767. private static _tmpVecs;
  36768. private static _tmpQuat;
  36769. private static _tmpMats;
  36770. /**
  36771. * The target Vector3 that the bone will look at
  36772. */
  36773. target: Vector3;
  36774. /**
  36775. * The mesh that the bone is attached to
  36776. */
  36777. mesh: AbstractMesh;
  36778. /**
  36779. * The bone that will be looking to the target
  36780. */
  36781. bone: Bone;
  36782. /**
  36783. * The up axis of the coordinate system that is used when the bone is rotated
  36784. */
  36785. upAxis: Vector3;
  36786. /**
  36787. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36788. */
  36789. upAxisSpace: Space;
  36790. /**
  36791. * Used to make an adjustment to the yaw of the bone
  36792. */
  36793. adjustYaw: number;
  36794. /**
  36795. * Used to make an adjustment to the pitch of the bone
  36796. */
  36797. adjustPitch: number;
  36798. /**
  36799. * Used to make an adjustment to the roll of the bone
  36800. */
  36801. adjustRoll: number;
  36802. /**
  36803. * 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)
  36804. */
  36805. slerpAmount: number;
  36806. private _minYaw;
  36807. private _maxYaw;
  36808. private _minPitch;
  36809. private _maxPitch;
  36810. private _minYawSin;
  36811. private _minYawCos;
  36812. private _maxYawSin;
  36813. private _maxYawCos;
  36814. private _midYawConstraint;
  36815. private _minPitchTan;
  36816. private _maxPitchTan;
  36817. private _boneQuat;
  36818. private _slerping;
  36819. private _transformYawPitch;
  36820. private _transformYawPitchInv;
  36821. private _firstFrameSkipped;
  36822. private _yawRange;
  36823. private _fowardAxis;
  36824. /**
  36825. * Gets or sets the minimum yaw angle that the bone can look to
  36826. */
  36827. minYaw: number;
  36828. /**
  36829. * Gets or sets the maximum yaw angle that the bone can look to
  36830. */
  36831. maxYaw: number;
  36832. /**
  36833. * Gets or sets the minimum pitch angle that the bone can look to
  36834. */
  36835. minPitch: number;
  36836. /**
  36837. * Gets or sets the maximum pitch angle that the bone can look to
  36838. */
  36839. maxPitch: number;
  36840. /**
  36841. * Create a BoneLookController
  36842. * @param mesh the mesh that the bone belongs to
  36843. * @param bone the bone that will be looking to the target
  36844. * @param target the target Vector3 to look at
  36845. * @param options optional settings:
  36846. * * maxYaw: the maximum angle the bone will yaw to
  36847. * * minYaw: the minimum angle the bone will yaw to
  36848. * * maxPitch: the maximum angle the bone will pitch to
  36849. * * minPitch: the minimum angle the bone will yaw to
  36850. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36851. * * upAxis: the up axis of the coordinate system
  36852. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36853. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36854. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36855. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36856. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36857. * * adjustRoll: used to make an adjustment to the roll of the bone
  36858. **/
  36859. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36860. maxYaw?: number;
  36861. minYaw?: number;
  36862. maxPitch?: number;
  36863. minPitch?: number;
  36864. slerpAmount?: number;
  36865. upAxis?: Vector3;
  36866. upAxisSpace?: Space;
  36867. yawAxis?: Vector3;
  36868. pitchAxis?: Vector3;
  36869. adjustYaw?: number;
  36870. adjustPitch?: number;
  36871. adjustRoll?: number;
  36872. });
  36873. /**
  36874. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36875. */
  36876. update(): void;
  36877. private _getAngleDiff;
  36878. private _getAngleBetween;
  36879. private _isAngleBetween;
  36880. }
  36881. }
  36882. declare module "babylonjs/Bones/index" {
  36883. export * from "babylonjs/Bones/bone";
  36884. export * from "babylonjs/Bones/boneIKController";
  36885. export * from "babylonjs/Bones/boneLookController";
  36886. export * from "babylonjs/Bones/skeleton";
  36887. }
  36888. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36889. import { Nullable } from "babylonjs/types";
  36890. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36892. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36893. /**
  36894. * Manage the gamepad inputs to control an arc rotate camera.
  36895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36896. */
  36897. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36898. /**
  36899. * Defines the camera the input is attached to.
  36900. */
  36901. camera: ArcRotateCamera;
  36902. /**
  36903. * Defines the gamepad the input is gathering event from.
  36904. */
  36905. gamepad: Nullable<Gamepad>;
  36906. /**
  36907. * Defines the gamepad rotation sensiblity.
  36908. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36909. */
  36910. gamepadRotationSensibility: number;
  36911. /**
  36912. * Defines the gamepad move sensiblity.
  36913. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36914. */
  36915. gamepadMoveSensibility: number;
  36916. private _onGamepadConnectedObserver;
  36917. private _onGamepadDisconnectedObserver;
  36918. /**
  36919. * Attach the input controls to a specific dom element to get the input from.
  36920. * @param element Defines the element the controls should be listened from
  36921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36922. */
  36923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36924. /**
  36925. * Detach the current controls from the specified dom element.
  36926. * @param element Defines the element to stop listening the inputs from
  36927. */
  36928. detachControl(element: Nullable<HTMLElement>): void;
  36929. /**
  36930. * Update the current camera state depending on the inputs that have been used this frame.
  36931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36932. */
  36933. checkInputs(): void;
  36934. /**
  36935. * Gets the class name of the current intput.
  36936. * @returns the class name
  36937. */
  36938. getClassName(): string;
  36939. /**
  36940. * Get the friendly name associated with the input class.
  36941. * @returns the input friendly name
  36942. */
  36943. getSimpleName(): string;
  36944. }
  36945. }
  36946. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36947. import { Nullable } from "babylonjs/types";
  36948. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36949. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36950. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36951. interface ArcRotateCameraInputsManager {
  36952. /**
  36953. * Add orientation input support to the input manager.
  36954. * @returns the current input manager
  36955. */
  36956. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36957. }
  36958. }
  36959. /**
  36960. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36962. */
  36963. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36964. /**
  36965. * Defines the camera the input is attached to.
  36966. */
  36967. camera: ArcRotateCamera;
  36968. /**
  36969. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36970. */
  36971. alphaCorrection: number;
  36972. /**
  36973. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36974. */
  36975. gammaCorrection: number;
  36976. private _alpha;
  36977. private _gamma;
  36978. private _dirty;
  36979. private _deviceOrientationHandler;
  36980. /**
  36981. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36982. */
  36983. constructor();
  36984. /**
  36985. * Attach the input controls to a specific dom element to get the input from.
  36986. * @param element Defines the element the controls should be listened from
  36987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36988. */
  36989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36990. /** @hidden */
  36991. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36992. /**
  36993. * Update the current camera state depending on the inputs that have been used this frame.
  36994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36995. */
  36996. checkInputs(): void;
  36997. /**
  36998. * Detach the current controls from the specified dom element.
  36999. * @param element Defines the element to stop listening the inputs from
  37000. */
  37001. detachControl(element: Nullable<HTMLElement>): void;
  37002. /**
  37003. * Gets the class name of the current intput.
  37004. * @returns the class name
  37005. */
  37006. getClassName(): string;
  37007. /**
  37008. * Get the friendly name associated with the input class.
  37009. * @returns the input friendly name
  37010. */
  37011. getSimpleName(): string;
  37012. }
  37013. }
  37014. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37015. import { Nullable } from "babylonjs/types";
  37016. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37017. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37018. /**
  37019. * Listen to mouse events to control the camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: FlyCamera;
  37027. /**
  37028. * Defines if touch is enabled. (Default is true.)
  37029. */
  37030. touchEnabled: boolean;
  37031. /**
  37032. * Defines the buttons associated with the input to handle camera rotation.
  37033. */
  37034. buttons: number[];
  37035. /**
  37036. * Assign buttons for Yaw control.
  37037. */
  37038. buttonsYaw: number[];
  37039. /**
  37040. * Assign buttons for Pitch control.
  37041. */
  37042. buttonsPitch: number[];
  37043. /**
  37044. * Assign buttons for Roll control.
  37045. */
  37046. buttonsRoll: number[];
  37047. /**
  37048. * Detect if any button is being pressed while mouse is moved.
  37049. * -1 = Mouse locked.
  37050. * 0 = Left button.
  37051. * 1 = Middle Button.
  37052. * 2 = Right Button.
  37053. */
  37054. activeButton: number;
  37055. /**
  37056. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37057. * Higher values reduce its sensitivity.
  37058. */
  37059. angularSensibility: number;
  37060. private _mousemoveCallback;
  37061. private _observer;
  37062. private _rollObserver;
  37063. private previousPosition;
  37064. private noPreventDefault;
  37065. private element;
  37066. /**
  37067. * Listen to mouse events to control the camera.
  37068. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37070. */
  37071. constructor(touchEnabled?: boolean);
  37072. /**
  37073. * Attach the mouse control to the HTML DOM element.
  37074. * @param element Defines the element that listens to the input events.
  37075. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37076. */
  37077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37078. /**
  37079. * Detach the current controls from the specified dom element.
  37080. * @param element Defines the element to stop listening the inputs from
  37081. */
  37082. detachControl(element: Nullable<HTMLElement>): void;
  37083. /**
  37084. * Gets the class name of the current input.
  37085. * @returns the class name.
  37086. */
  37087. getClassName(): string;
  37088. /**
  37089. * Get the friendly name associated with the input class.
  37090. * @returns the input's friendly name.
  37091. */
  37092. getSimpleName(): string;
  37093. private _pointerInput;
  37094. private _onMouseMove;
  37095. /**
  37096. * Rotate camera by mouse offset.
  37097. */
  37098. private rotateCamera;
  37099. }
  37100. }
  37101. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37102. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37103. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37104. /**
  37105. * Default Inputs manager for the FlyCamera.
  37106. * It groups all the default supported inputs for ease of use.
  37107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37108. */
  37109. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37110. /**
  37111. * Instantiates a new FlyCameraInputsManager.
  37112. * @param camera Defines the camera the inputs belong to.
  37113. */
  37114. constructor(camera: FlyCamera);
  37115. /**
  37116. * Add keyboard input support to the input manager.
  37117. * @returns the new FlyCameraKeyboardMoveInput().
  37118. */
  37119. addKeyboard(): FlyCameraInputsManager;
  37120. /**
  37121. * Add mouse input support to the input manager.
  37122. * @param touchEnabled Enable touch screen support.
  37123. * @returns the new FlyCameraMouseInput().
  37124. */
  37125. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37126. }
  37127. }
  37128. declare module "babylonjs/Cameras/flyCamera" {
  37129. import { Scene } from "babylonjs/scene";
  37130. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37132. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37133. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37134. /**
  37135. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37136. * such as in a 3D Space Shooter or a Flight Simulator.
  37137. */
  37138. export class FlyCamera extends TargetCamera {
  37139. /**
  37140. * Define the collision ellipsoid of the camera.
  37141. * This is helpful for simulating a camera body, like a player's body.
  37142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37143. */
  37144. ellipsoid: Vector3;
  37145. /**
  37146. * Define an offset for the position of the ellipsoid around the camera.
  37147. * This can be helpful if the camera is attached away from the player's body center,
  37148. * such as at its head.
  37149. */
  37150. ellipsoidOffset: Vector3;
  37151. /**
  37152. * Enable or disable collisions of the camera with the rest of the scene objects.
  37153. */
  37154. checkCollisions: boolean;
  37155. /**
  37156. * Enable or disable gravity on the camera.
  37157. */
  37158. applyGravity: boolean;
  37159. /**
  37160. * Define the current direction the camera is moving to.
  37161. */
  37162. cameraDirection: Vector3;
  37163. /**
  37164. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37165. * This overrides and empties cameraRotation.
  37166. */
  37167. rotationQuaternion: Quaternion;
  37168. /**
  37169. * Track Roll to maintain the wanted Rolling when looking around.
  37170. */
  37171. _trackRoll: number;
  37172. /**
  37173. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37174. */
  37175. rollCorrect: number;
  37176. /**
  37177. * Mimic a banked turn, Rolling the camera when Yawing.
  37178. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37179. */
  37180. bankedTurn: boolean;
  37181. /**
  37182. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37183. */
  37184. bankedTurnLimit: number;
  37185. /**
  37186. * Value of 0 disables the banked Roll.
  37187. * Value of 1 is equal to the Yaw angle in radians.
  37188. */
  37189. bankedTurnMultiplier: number;
  37190. /**
  37191. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37192. */
  37193. inputs: FlyCameraInputsManager;
  37194. /**
  37195. * Gets the input sensibility for mouse input.
  37196. * Higher values reduce sensitivity.
  37197. */
  37198. /**
  37199. * Sets the input sensibility for a mouse input.
  37200. * Higher values reduce sensitivity.
  37201. */
  37202. angularSensibility: number;
  37203. /**
  37204. * Get the keys for camera movement forward.
  37205. */
  37206. /**
  37207. * Set the keys for camera movement forward.
  37208. */
  37209. keysForward: number[];
  37210. /**
  37211. * Get the keys for camera movement backward.
  37212. */
  37213. keysBackward: number[];
  37214. /**
  37215. * Get the keys for camera movement up.
  37216. */
  37217. /**
  37218. * Set the keys for camera movement up.
  37219. */
  37220. keysUp: number[];
  37221. /**
  37222. * Get the keys for camera movement down.
  37223. */
  37224. /**
  37225. * Set the keys for camera movement down.
  37226. */
  37227. keysDown: number[];
  37228. /**
  37229. * Get the keys for camera movement left.
  37230. */
  37231. /**
  37232. * Set the keys for camera movement left.
  37233. */
  37234. keysLeft: number[];
  37235. /**
  37236. * Set the keys for camera movement right.
  37237. */
  37238. /**
  37239. * Set the keys for camera movement right.
  37240. */
  37241. keysRight: number[];
  37242. /**
  37243. * Event raised when the camera collides with a mesh in the scene.
  37244. */
  37245. onCollide: (collidedMesh: AbstractMesh) => void;
  37246. private _collider;
  37247. private _needMoveForGravity;
  37248. private _oldPosition;
  37249. private _diffPosition;
  37250. private _newPosition;
  37251. /** @hidden */
  37252. _localDirection: Vector3;
  37253. /** @hidden */
  37254. _transformedDirection: Vector3;
  37255. /**
  37256. * Instantiates a FlyCamera.
  37257. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37258. * such as in a 3D Space Shooter or a Flight Simulator.
  37259. * @param name Define the name of the camera in the scene.
  37260. * @param position Define the starting position of the camera in the scene.
  37261. * @param scene Define the scene the camera belongs to.
  37262. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37263. */
  37264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37265. /**
  37266. * Attach a control to the HTML DOM element.
  37267. * @param element Defines the element that listens to the input events.
  37268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37269. */
  37270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37271. /**
  37272. * Detach a control from the HTML DOM element.
  37273. * The camera will stop reacting to that input.
  37274. * @param element Defines the element that listens to the input events.
  37275. */
  37276. detachControl(element: HTMLElement): void;
  37277. private _collisionMask;
  37278. /**
  37279. * Get the mask that the camera ignores in collision events.
  37280. */
  37281. /**
  37282. * Set the mask that the camera ignores in collision events.
  37283. */
  37284. collisionMask: number;
  37285. /** @hidden */
  37286. _collideWithWorld(displacement: Vector3): void;
  37287. /** @hidden */
  37288. private _onCollisionPositionChange;
  37289. /** @hidden */
  37290. _checkInputs(): void;
  37291. /** @hidden */
  37292. _decideIfNeedsToMove(): boolean;
  37293. /** @hidden */
  37294. _updatePosition(): void;
  37295. /**
  37296. * Restore the Roll to its target value at the rate specified.
  37297. * @param rate - Higher means slower restoring.
  37298. * @hidden
  37299. */
  37300. restoreRoll(rate: number): void;
  37301. /**
  37302. * Destroy the camera and release the current resources held by it.
  37303. */
  37304. dispose(): void;
  37305. /**
  37306. * Get the current object class name.
  37307. * @returns the class name.
  37308. */
  37309. getClassName(): string;
  37310. }
  37311. }
  37312. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37313. import { Nullable } from "babylonjs/types";
  37314. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37315. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37316. /**
  37317. * Listen to keyboard events to control the camera.
  37318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37319. */
  37320. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37321. /**
  37322. * Defines the camera the input is attached to.
  37323. */
  37324. camera: FlyCamera;
  37325. /**
  37326. * The list of keyboard keys used to control the forward move of the camera.
  37327. */
  37328. keysForward: number[];
  37329. /**
  37330. * The list of keyboard keys used to control the backward move of the camera.
  37331. */
  37332. keysBackward: number[];
  37333. /**
  37334. * The list of keyboard keys used to control the forward move of the camera.
  37335. */
  37336. keysUp: number[];
  37337. /**
  37338. * The list of keyboard keys used to control the backward move of the camera.
  37339. */
  37340. keysDown: number[];
  37341. /**
  37342. * The list of keyboard keys used to control the right strafe move of the camera.
  37343. */
  37344. keysRight: number[];
  37345. /**
  37346. * The list of keyboard keys used to control the left strafe move of the camera.
  37347. */
  37348. keysLeft: number[];
  37349. private _keys;
  37350. private _onCanvasBlurObserver;
  37351. private _onKeyboardObserver;
  37352. private _engine;
  37353. private _scene;
  37354. /**
  37355. * Attach the input controls to a specific dom element to get the input from.
  37356. * @param element Defines the element the controls should be listened from
  37357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37358. */
  37359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37360. /**
  37361. * Detach the current controls from the specified dom element.
  37362. * @param element Defines the element to stop listening the inputs from
  37363. */
  37364. detachControl(element: Nullable<HTMLElement>): void;
  37365. /**
  37366. * Gets the class name of the current intput.
  37367. * @returns the class name
  37368. */
  37369. getClassName(): string;
  37370. /** @hidden */
  37371. _onLostFocus(e: FocusEvent): void;
  37372. /**
  37373. * Get the friendly name associated with the input class.
  37374. * @returns the input friendly name
  37375. */
  37376. getSimpleName(): string;
  37377. /**
  37378. * Update the current camera state depending on the inputs that have been used this frame.
  37379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37380. */
  37381. checkInputs(): void;
  37382. }
  37383. }
  37384. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37385. import { Nullable } from "babylonjs/types";
  37386. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37387. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37388. /**
  37389. * Manage the mouse wheel inputs to control a follow camera.
  37390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37391. */
  37392. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37393. /**
  37394. * Defines the camera the input is attached to.
  37395. */
  37396. camera: FollowCamera;
  37397. /**
  37398. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37399. */
  37400. axisControlRadius: boolean;
  37401. /**
  37402. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37403. */
  37404. axisControlHeight: boolean;
  37405. /**
  37406. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37407. */
  37408. axisControlRotation: boolean;
  37409. /**
  37410. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37411. * relation to mouseWheel events.
  37412. */
  37413. wheelPrecision: number;
  37414. /**
  37415. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37416. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37417. */
  37418. wheelDeltaPercentage: number;
  37419. private _wheel;
  37420. private _observer;
  37421. /**
  37422. * Attach the input controls to a specific dom element to get the input from.
  37423. * @param element Defines the element the controls should be listened from
  37424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37425. */
  37426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37427. /**
  37428. * Detach the current controls from the specified dom element.
  37429. * @param element Defines the element to stop listening the inputs from
  37430. */
  37431. detachControl(element: Nullable<HTMLElement>): void;
  37432. /**
  37433. * Gets the class name of the current intput.
  37434. * @returns the class name
  37435. */
  37436. getClassName(): string;
  37437. /**
  37438. * Get the friendly name associated with the input class.
  37439. * @returns the input friendly name
  37440. */
  37441. getSimpleName(): string;
  37442. }
  37443. }
  37444. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37445. import { Nullable } from "babylonjs/types";
  37446. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37447. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37448. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37449. /**
  37450. * Manage the pointers inputs to control an follow camera.
  37451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37452. */
  37453. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37454. /**
  37455. * Defines the camera the input is attached to.
  37456. */
  37457. camera: FollowCamera;
  37458. /**
  37459. * Gets the class name of the current input.
  37460. * @returns the class name
  37461. */
  37462. getClassName(): string;
  37463. /**
  37464. * Defines the pointer angular sensibility along the X axis or how fast is
  37465. * the camera rotating.
  37466. * A negative number will reverse the axis direction.
  37467. */
  37468. angularSensibilityX: number;
  37469. /**
  37470. * Defines the pointer angular sensibility along the Y axis or how fast is
  37471. * the camera rotating.
  37472. * A negative number will reverse the axis direction.
  37473. */
  37474. angularSensibilityY: number;
  37475. /**
  37476. * Defines the pointer pinch precision or how fast is the camera zooming.
  37477. * A negative number will reverse the axis direction.
  37478. */
  37479. pinchPrecision: number;
  37480. /**
  37481. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37482. * from 0.
  37483. * It defines the percentage of current camera.radius to use as delta when
  37484. * pinch zoom is used.
  37485. */
  37486. pinchDeltaPercentage: number;
  37487. /**
  37488. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37489. */
  37490. axisXControlRadius: boolean;
  37491. /**
  37492. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37493. */
  37494. axisXControlHeight: boolean;
  37495. /**
  37496. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37497. */
  37498. axisXControlRotation: boolean;
  37499. /**
  37500. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37501. */
  37502. axisYControlRadius: boolean;
  37503. /**
  37504. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37505. */
  37506. axisYControlHeight: boolean;
  37507. /**
  37508. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37509. */
  37510. axisYControlRotation: boolean;
  37511. /**
  37512. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37513. */
  37514. axisPinchControlRadius: boolean;
  37515. /**
  37516. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37517. */
  37518. axisPinchControlHeight: boolean;
  37519. /**
  37520. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37521. */
  37522. axisPinchControlRotation: boolean;
  37523. /**
  37524. * Log error messages if basic misconfiguration has occurred.
  37525. */
  37526. warningEnable: boolean;
  37527. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37528. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37529. private _warningCounter;
  37530. private _warning;
  37531. }
  37532. }
  37533. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37534. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37535. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37536. /**
  37537. * Default Inputs manager for the FollowCamera.
  37538. * It groups all the default supported inputs for ease of use.
  37539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37540. */
  37541. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37542. /**
  37543. * Instantiates a new FollowCameraInputsManager.
  37544. * @param camera Defines the camera the inputs belong to
  37545. */
  37546. constructor(camera: FollowCamera);
  37547. /**
  37548. * Add keyboard input support to the input manager.
  37549. * @returns the current input manager
  37550. */
  37551. addKeyboard(): FollowCameraInputsManager;
  37552. /**
  37553. * Add mouse wheel input support to the input manager.
  37554. * @returns the current input manager
  37555. */
  37556. addMouseWheel(): FollowCameraInputsManager;
  37557. /**
  37558. * Add pointers input support to the input manager.
  37559. * @returns the current input manager
  37560. */
  37561. addPointers(): FollowCameraInputsManager;
  37562. /**
  37563. * Add orientation input support to the input manager.
  37564. * @returns the current input manager
  37565. */
  37566. addVRDeviceOrientation(): FollowCameraInputsManager;
  37567. }
  37568. }
  37569. declare module "babylonjs/Cameras/followCamera" {
  37570. import { Nullable } from "babylonjs/types";
  37571. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37572. import { Scene } from "babylonjs/scene";
  37573. import { Vector3 } from "babylonjs/Maths/math";
  37574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37575. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37576. /**
  37577. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37578. * an arc rotate version arcFollowCamera are available.
  37579. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37580. */
  37581. export class FollowCamera extends TargetCamera {
  37582. /**
  37583. * Distance the follow camera should follow an object at
  37584. */
  37585. radius: number;
  37586. /**
  37587. * Minimum allowed distance of the camera to the axis of rotation
  37588. * (The camera can not get closer).
  37589. * This can help limiting how the Camera is able to move in the scene.
  37590. */
  37591. lowerRadiusLimit: Nullable<number>;
  37592. /**
  37593. * Maximum allowed distance of the camera to the axis of rotation
  37594. * (The camera can not get further).
  37595. * This can help limiting how the Camera is able to move in the scene.
  37596. */
  37597. upperRadiusLimit: Nullable<number>;
  37598. /**
  37599. * Define a rotation offset between the camera and the object it follows
  37600. */
  37601. rotationOffset: number;
  37602. /**
  37603. * Minimum allowed angle to camera position relative to target object.
  37604. * This can help limiting how the Camera is able to move in the scene.
  37605. */
  37606. lowerRotationOffsetLimit: Nullable<number>;
  37607. /**
  37608. * Maximum allowed angle to camera position relative to target object.
  37609. * This can help limiting how the Camera is able to move in the scene.
  37610. */
  37611. upperRotationOffsetLimit: Nullable<number>;
  37612. /**
  37613. * Define a height offset between the camera and the object it follows.
  37614. * It can help following an object from the top (like a car chaing a plane)
  37615. */
  37616. heightOffset: number;
  37617. /**
  37618. * Minimum allowed height of camera position relative to target object.
  37619. * This can help limiting how the Camera is able to move in the scene.
  37620. */
  37621. lowerHeightOffsetLimit: Nullable<number>;
  37622. /**
  37623. * Maximum allowed height of camera position relative to target object.
  37624. * This can help limiting how the Camera is able to move in the scene.
  37625. */
  37626. upperHeightOffsetLimit: Nullable<number>;
  37627. /**
  37628. * Define how fast the camera can accelerate to follow it s target.
  37629. */
  37630. cameraAcceleration: number;
  37631. /**
  37632. * Define the speed limit of the camera following an object.
  37633. */
  37634. maxCameraSpeed: number;
  37635. /**
  37636. * Define the target of the camera.
  37637. */
  37638. lockedTarget: Nullable<AbstractMesh>;
  37639. /**
  37640. * Defines the input associated with the camera.
  37641. */
  37642. inputs: FollowCameraInputsManager;
  37643. /**
  37644. * Instantiates the follow camera.
  37645. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37646. * @param name Define the name of the camera in the scene
  37647. * @param position Define the position of the camera
  37648. * @param scene Define the scene the camera belong to
  37649. * @param lockedTarget Define the target of the camera
  37650. */
  37651. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37652. private _follow;
  37653. /**
  37654. * Attached controls to the current camera.
  37655. * @param element Defines the element the controls should be listened from
  37656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37657. */
  37658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37659. /**
  37660. * Detach the current controls from the camera.
  37661. * The camera will stop reacting to inputs.
  37662. * @param element Defines the element to stop listening the inputs from
  37663. */
  37664. detachControl(element: HTMLElement): void;
  37665. /** @hidden */
  37666. _checkInputs(): void;
  37667. private _checkLimits;
  37668. /**
  37669. * Gets the camera class name.
  37670. * @returns the class name
  37671. */
  37672. getClassName(): string;
  37673. }
  37674. /**
  37675. * Arc Rotate version of the follow camera.
  37676. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37677. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37678. */
  37679. export class ArcFollowCamera extends TargetCamera {
  37680. /** The longitudinal angle of the camera */
  37681. alpha: number;
  37682. /** The latitudinal angle of the camera */
  37683. beta: number;
  37684. /** The radius of the camera from its target */
  37685. radius: number;
  37686. /** Define the camera target (the messh it should follow) */
  37687. target: Nullable<AbstractMesh>;
  37688. private _cartesianCoordinates;
  37689. /**
  37690. * Instantiates a new ArcFollowCamera
  37691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37692. * @param name Define the name of the camera
  37693. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37694. * @param beta Define the rotation angle of the camera around the elevation axis
  37695. * @param radius Define the radius of the camera from its target point
  37696. * @param target Define the target of the camera
  37697. * @param scene Define the scene the camera belongs to
  37698. */
  37699. constructor(name: string,
  37700. /** The longitudinal angle of the camera */
  37701. alpha: number,
  37702. /** The latitudinal angle of the camera */
  37703. beta: number,
  37704. /** The radius of the camera from its target */
  37705. radius: number,
  37706. /** Define the camera target (the messh it should follow) */
  37707. target: Nullable<AbstractMesh>, scene: Scene);
  37708. private _follow;
  37709. /** @hidden */
  37710. _checkInputs(): void;
  37711. /**
  37712. * Returns the class name of the object.
  37713. * It is mostly used internally for serialization purposes.
  37714. */
  37715. getClassName(): string;
  37716. }
  37717. }
  37718. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37719. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37720. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37721. import { Nullable } from "babylonjs/types";
  37722. /**
  37723. * Manage the keyboard inputs to control the movement of a follow camera.
  37724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37725. */
  37726. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37727. /**
  37728. * Defines the camera the input is attached to.
  37729. */
  37730. camera: FollowCamera;
  37731. /**
  37732. * Defines the list of key codes associated with the up action (increase heightOffset)
  37733. */
  37734. keysHeightOffsetIncr: number[];
  37735. /**
  37736. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37737. */
  37738. keysHeightOffsetDecr: number[];
  37739. /**
  37740. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37741. */
  37742. keysHeightOffsetModifierAlt: boolean;
  37743. /**
  37744. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37745. */
  37746. keysHeightOffsetModifierCtrl: boolean;
  37747. /**
  37748. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37749. */
  37750. keysHeightOffsetModifierShift: boolean;
  37751. /**
  37752. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37753. */
  37754. keysRotationOffsetIncr: number[];
  37755. /**
  37756. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37757. */
  37758. keysRotationOffsetDecr: number[];
  37759. /**
  37760. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37761. */
  37762. keysRotationOffsetModifierAlt: boolean;
  37763. /**
  37764. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37765. */
  37766. keysRotationOffsetModifierCtrl: boolean;
  37767. /**
  37768. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37769. */
  37770. keysRotationOffsetModifierShift: boolean;
  37771. /**
  37772. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37773. */
  37774. keysRadiusIncr: number[];
  37775. /**
  37776. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37777. */
  37778. keysRadiusDecr: number[];
  37779. /**
  37780. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37781. */
  37782. keysRadiusModifierAlt: boolean;
  37783. /**
  37784. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37785. */
  37786. keysRadiusModifierCtrl: boolean;
  37787. /**
  37788. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37789. */
  37790. keysRadiusModifierShift: boolean;
  37791. /**
  37792. * Defines the rate of change of heightOffset.
  37793. */
  37794. heightSensibility: number;
  37795. /**
  37796. * Defines the rate of change of rotationOffset.
  37797. */
  37798. rotationSensibility: number;
  37799. /**
  37800. * Defines the rate of change of radius.
  37801. */
  37802. radiusSensibility: number;
  37803. private _keys;
  37804. private _ctrlPressed;
  37805. private _altPressed;
  37806. private _shiftPressed;
  37807. private _onCanvasBlurObserver;
  37808. private _onKeyboardObserver;
  37809. private _engine;
  37810. private _scene;
  37811. /**
  37812. * Attach the input controls to a specific dom element to get the input from.
  37813. * @param element Defines the element the controls should be listened from
  37814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37815. */
  37816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37817. /**
  37818. * Detach the current controls from the specified dom element.
  37819. * @param element Defines the element to stop listening the inputs from
  37820. */
  37821. detachControl(element: Nullable<HTMLElement>): void;
  37822. /**
  37823. * Update the current camera state depending on the inputs that have been used this frame.
  37824. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37825. */
  37826. checkInputs(): void;
  37827. /**
  37828. * Gets the class name of the current input.
  37829. * @returns the class name
  37830. */
  37831. getClassName(): string;
  37832. /**
  37833. * Get the friendly name associated with the input class.
  37834. * @returns the input friendly name
  37835. */
  37836. getSimpleName(): string;
  37837. /**
  37838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37839. * allow modification of the heightOffset value.
  37840. */
  37841. private _modifierHeightOffset;
  37842. /**
  37843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37844. * allow modification of the rotationOffset value.
  37845. */
  37846. private _modifierRotationOffset;
  37847. /**
  37848. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37849. * allow modification of the radius value.
  37850. */
  37851. private _modifierRadius;
  37852. }
  37853. }
  37854. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37855. import { Nullable } from "babylonjs/types";
  37856. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37858. import { Observable } from "babylonjs/Misc/observable";
  37859. module "babylonjs/Cameras/freeCameraInputsManager" {
  37860. interface FreeCameraInputsManager {
  37861. /**
  37862. * @hidden
  37863. */
  37864. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37865. /**
  37866. * Add orientation input support to the input manager.
  37867. * @returns the current input manager
  37868. */
  37869. addDeviceOrientation(): FreeCameraInputsManager;
  37870. }
  37871. }
  37872. /**
  37873. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37874. * Screen rotation is taken into account.
  37875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37876. */
  37877. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37878. private _camera;
  37879. private _screenOrientationAngle;
  37880. private _constantTranform;
  37881. private _screenQuaternion;
  37882. private _alpha;
  37883. private _beta;
  37884. private _gamma;
  37885. /**
  37886. * @hidden
  37887. */
  37888. _onDeviceOrientationChangedObservable: Observable<void>;
  37889. /**
  37890. * Instantiates a new input
  37891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37892. */
  37893. constructor();
  37894. /**
  37895. * Define the camera controlled by the input.
  37896. */
  37897. camera: FreeCamera;
  37898. /**
  37899. * Attach the input controls to a specific dom element to get the input from.
  37900. * @param element Defines the element the controls should be listened from
  37901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37902. */
  37903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37904. private _orientationChanged;
  37905. private _deviceOrientation;
  37906. /**
  37907. * Detach the current controls from the specified dom element.
  37908. * @param element Defines the element to stop listening the inputs from
  37909. */
  37910. detachControl(element: Nullable<HTMLElement>): void;
  37911. /**
  37912. * Update the current camera state depending on the inputs that have been used this frame.
  37913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37914. */
  37915. checkInputs(): void;
  37916. /**
  37917. * Gets the class name of the current intput.
  37918. * @returns the class name
  37919. */
  37920. getClassName(): string;
  37921. /**
  37922. * Get the friendly name associated with the input class.
  37923. * @returns the input friendly name
  37924. */
  37925. getSimpleName(): string;
  37926. }
  37927. }
  37928. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37929. import { Nullable } from "babylonjs/types";
  37930. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37932. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37933. /**
  37934. * Manage the gamepad inputs to control a free camera.
  37935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37936. */
  37937. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37938. /**
  37939. * Define the camera the input is attached to.
  37940. */
  37941. camera: FreeCamera;
  37942. /**
  37943. * Define the Gamepad controlling the input
  37944. */
  37945. gamepad: Nullable<Gamepad>;
  37946. /**
  37947. * Defines the gamepad rotation sensiblity.
  37948. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37949. */
  37950. gamepadAngularSensibility: number;
  37951. /**
  37952. * Defines the gamepad move sensiblity.
  37953. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37954. */
  37955. gamepadMoveSensibility: number;
  37956. private _onGamepadConnectedObserver;
  37957. private _onGamepadDisconnectedObserver;
  37958. private _cameraTransform;
  37959. private _deltaTransform;
  37960. private _vector3;
  37961. private _vector2;
  37962. /**
  37963. * Attach the input controls to a specific dom element to get the input from.
  37964. * @param element Defines the element the controls should be listened from
  37965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37966. */
  37967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37968. /**
  37969. * Detach the current controls from the specified dom element.
  37970. * @param element Defines the element to stop listening the inputs from
  37971. */
  37972. detachControl(element: Nullable<HTMLElement>): void;
  37973. /**
  37974. * Update the current camera state depending on the inputs that have been used this frame.
  37975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37976. */
  37977. checkInputs(): void;
  37978. /**
  37979. * Gets the class name of the current intput.
  37980. * @returns the class name
  37981. */
  37982. getClassName(): string;
  37983. /**
  37984. * Get the friendly name associated with the input class.
  37985. * @returns the input friendly name
  37986. */
  37987. getSimpleName(): string;
  37988. }
  37989. }
  37990. declare module "babylonjs/Misc/virtualJoystick" {
  37991. import { Nullable } from "babylonjs/types";
  37992. import { Vector3 } from "babylonjs/Maths/math";
  37993. /**
  37994. * Defines the potential axis of a Joystick
  37995. */
  37996. export enum JoystickAxis {
  37997. /** X axis */
  37998. X = 0,
  37999. /** Y axis */
  38000. Y = 1,
  38001. /** Z axis */
  38002. Z = 2
  38003. }
  38004. /**
  38005. * Class used to define virtual joystick (used in touch mode)
  38006. */
  38007. export class VirtualJoystick {
  38008. /**
  38009. * Gets or sets a boolean indicating that left and right values must be inverted
  38010. */
  38011. reverseLeftRight: boolean;
  38012. /**
  38013. * Gets or sets a boolean indicating that up and down values must be inverted
  38014. */
  38015. reverseUpDown: boolean;
  38016. /**
  38017. * Gets the offset value for the position (ie. the change of the position value)
  38018. */
  38019. deltaPosition: Vector3;
  38020. /**
  38021. * Gets a boolean indicating if the virtual joystick was pressed
  38022. */
  38023. pressed: boolean;
  38024. /**
  38025. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38026. */
  38027. static Canvas: Nullable<HTMLCanvasElement>;
  38028. private static _globalJoystickIndex;
  38029. private static vjCanvasContext;
  38030. private static vjCanvasWidth;
  38031. private static vjCanvasHeight;
  38032. private static halfWidth;
  38033. private _action;
  38034. private _axisTargetedByLeftAndRight;
  38035. private _axisTargetedByUpAndDown;
  38036. private _joystickSensibility;
  38037. private _inversedSensibility;
  38038. private _joystickPointerID;
  38039. private _joystickColor;
  38040. private _joystickPointerPos;
  38041. private _joystickPreviousPointerPos;
  38042. private _joystickPointerStartPos;
  38043. private _deltaJoystickVector;
  38044. private _leftJoystick;
  38045. private _touches;
  38046. private _onPointerDownHandlerRef;
  38047. private _onPointerMoveHandlerRef;
  38048. private _onPointerUpHandlerRef;
  38049. private _onResize;
  38050. /**
  38051. * Creates a new virtual joystick
  38052. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38053. */
  38054. constructor(leftJoystick?: boolean);
  38055. /**
  38056. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38057. * @param newJoystickSensibility defines the new sensibility
  38058. */
  38059. setJoystickSensibility(newJoystickSensibility: number): void;
  38060. private _onPointerDown;
  38061. private _onPointerMove;
  38062. private _onPointerUp;
  38063. /**
  38064. * Change the color of the virtual joystick
  38065. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38066. */
  38067. setJoystickColor(newColor: string): void;
  38068. /**
  38069. * Defines a callback to call when the joystick is touched
  38070. * @param action defines the callback
  38071. */
  38072. setActionOnTouch(action: () => any): void;
  38073. /**
  38074. * Defines which axis you'd like to control for left & right
  38075. * @param axis defines the axis to use
  38076. */
  38077. setAxisForLeftRight(axis: JoystickAxis): void;
  38078. /**
  38079. * Defines which axis you'd like to control for up & down
  38080. * @param axis defines the axis to use
  38081. */
  38082. setAxisForUpDown(axis: JoystickAxis): void;
  38083. private _drawVirtualJoystick;
  38084. /**
  38085. * Release internal HTML canvas
  38086. */
  38087. releaseCanvas(): void;
  38088. }
  38089. }
  38090. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38091. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38092. import { Nullable } from "babylonjs/types";
  38093. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38095. module "babylonjs/Cameras/freeCameraInputsManager" {
  38096. interface FreeCameraInputsManager {
  38097. /**
  38098. * Add virtual joystick input support to the input manager.
  38099. * @returns the current input manager
  38100. */
  38101. addVirtualJoystick(): FreeCameraInputsManager;
  38102. }
  38103. }
  38104. /**
  38105. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38107. */
  38108. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38109. /**
  38110. * Defines the camera the input is attached to.
  38111. */
  38112. camera: FreeCamera;
  38113. private _leftjoystick;
  38114. private _rightjoystick;
  38115. /**
  38116. * Gets the left stick of the virtual joystick.
  38117. * @returns The virtual Joystick
  38118. */
  38119. getLeftJoystick(): VirtualJoystick;
  38120. /**
  38121. * Gets the right stick of the virtual joystick.
  38122. * @returns The virtual Joystick
  38123. */
  38124. getRightJoystick(): VirtualJoystick;
  38125. /**
  38126. * Update the current camera state depending on the inputs that have been used this frame.
  38127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38128. */
  38129. checkInputs(): void;
  38130. /**
  38131. * Attach the input controls to a specific dom element to get the input from.
  38132. * @param element Defines the element the controls should be listened from
  38133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38134. */
  38135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38136. /**
  38137. * Detach the current controls from the specified dom element.
  38138. * @param element Defines the element to stop listening the inputs from
  38139. */
  38140. detachControl(element: Nullable<HTMLElement>): void;
  38141. /**
  38142. * Gets the class name of the current intput.
  38143. * @returns the class name
  38144. */
  38145. getClassName(): string;
  38146. /**
  38147. * Get the friendly name associated with the input class.
  38148. * @returns the input friendly name
  38149. */
  38150. getSimpleName(): string;
  38151. }
  38152. }
  38153. declare module "babylonjs/Cameras/Inputs/index" {
  38154. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38155. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38156. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38157. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38158. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38159. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38160. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38161. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38162. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38163. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38164. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38165. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38166. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38167. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38168. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38169. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38170. }
  38171. declare module "babylonjs/Cameras/touchCamera" {
  38172. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38173. import { Scene } from "babylonjs/scene";
  38174. import { Vector3 } from "babylonjs/Maths/math";
  38175. /**
  38176. * This represents a FPS type of camera controlled by touch.
  38177. * This is like a universal camera minus the Gamepad controls.
  38178. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38179. */
  38180. export class TouchCamera extends FreeCamera {
  38181. /**
  38182. * Defines the touch sensibility for rotation.
  38183. * The higher the faster.
  38184. */
  38185. touchAngularSensibility: number;
  38186. /**
  38187. * Defines the touch sensibility for move.
  38188. * The higher the faster.
  38189. */
  38190. touchMoveSensibility: number;
  38191. /**
  38192. * Instantiates a new touch camera.
  38193. * This represents a FPS type of camera controlled by touch.
  38194. * This is like a universal camera minus the Gamepad controls.
  38195. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38196. * @param name Define the name of the camera in the scene
  38197. * @param position Define the start position of the camera in the scene
  38198. * @param scene Define the scene the camera belongs to
  38199. */
  38200. constructor(name: string, position: Vector3, scene: Scene);
  38201. /**
  38202. * Gets the current object class name.
  38203. * @return the class name
  38204. */
  38205. getClassName(): string;
  38206. /** @hidden */
  38207. _setupInputs(): void;
  38208. }
  38209. }
  38210. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38211. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38212. import { Scene } from "babylonjs/scene";
  38213. import { Vector3, Axis } from "babylonjs/Maths/math";
  38214. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38215. /**
  38216. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38217. * being tilted forward or back and left or right.
  38218. */
  38219. export class DeviceOrientationCamera extends FreeCamera {
  38220. private _initialQuaternion;
  38221. private _quaternionCache;
  38222. private _tmpDragQuaternion;
  38223. /**
  38224. * Creates a new device orientation camera
  38225. * @param name The name of the camera
  38226. * @param position The start position camera
  38227. * @param scene The scene the camera belongs to
  38228. */
  38229. constructor(name: string, position: Vector3, scene: Scene);
  38230. /**
  38231. * Disabled pointer input on first orientation sensor update (Default: true)
  38232. */
  38233. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38234. private _dragFactor;
  38235. /**
  38236. * Enabled turning on the y axis when the orientation sensor is active
  38237. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38238. */
  38239. enableHorizontalDragging(dragFactor?: number): void;
  38240. /**
  38241. * Gets the current instance class name ("DeviceOrientationCamera").
  38242. * This helps avoiding instanceof at run time.
  38243. * @returns the class name
  38244. */
  38245. getClassName(): string;
  38246. /**
  38247. * @hidden
  38248. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38249. */
  38250. _checkInputs(): void;
  38251. /**
  38252. * Reset the camera to its default orientation on the specified axis only.
  38253. * @param axis The axis to reset
  38254. */
  38255. resetToCurrentRotation(axis?: Axis): void;
  38256. }
  38257. }
  38258. declare module "babylonjs/Cameras/universalCamera" {
  38259. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38260. import { Scene } from "babylonjs/scene";
  38261. import { Vector3 } from "babylonjs/Maths/math";
  38262. /**
  38263. * 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,
  38264. * which still works and will still be found in many Playgrounds.
  38265. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38266. */
  38267. export class UniversalCamera extends TouchCamera {
  38268. /**
  38269. * Defines the gamepad rotation sensiblity.
  38270. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38271. */
  38272. gamepadAngularSensibility: number;
  38273. /**
  38274. * Defines the gamepad move sensiblity.
  38275. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38276. */
  38277. gamepadMoveSensibility: number;
  38278. /**
  38279. * 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,
  38280. * which still works and will still be found in many Playgrounds.
  38281. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38282. * @param name Define the name of the camera in the scene
  38283. * @param position Define the start position of the camera in the scene
  38284. * @param scene Define the scene the camera belongs to
  38285. */
  38286. constructor(name: string, position: Vector3, scene: Scene);
  38287. /**
  38288. * Gets the current object class name.
  38289. * @return the class name
  38290. */
  38291. getClassName(): string;
  38292. }
  38293. }
  38294. declare module "babylonjs/Cameras/gamepadCamera" {
  38295. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38296. import { Scene } from "babylonjs/scene";
  38297. import { Vector3 } from "babylonjs/Maths/math";
  38298. /**
  38299. * This represents a FPS type of camera. This is only here for back compat purpose.
  38300. * Please use the UniversalCamera instead as both are identical.
  38301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38302. */
  38303. export class GamepadCamera extends UniversalCamera {
  38304. /**
  38305. * Instantiates a new Gamepad Camera
  38306. * This represents a FPS type of camera. This is only here for back compat purpose.
  38307. * Please use the UniversalCamera instead as both are identical.
  38308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38309. * @param name Define the name of the camera in the scene
  38310. * @param position Define the start position of the camera in the scene
  38311. * @param scene Define the scene the camera belongs to
  38312. */
  38313. constructor(name: string, position: Vector3, scene: Scene);
  38314. /**
  38315. * Gets the current object class name.
  38316. * @return the class name
  38317. */
  38318. getClassName(): string;
  38319. }
  38320. }
  38321. declare module "babylonjs/Shaders/pass.fragment" {
  38322. /** @hidden */
  38323. export var passPixelShader: {
  38324. name: string;
  38325. shader: string;
  38326. };
  38327. }
  38328. declare module "babylonjs/Shaders/passCube.fragment" {
  38329. /** @hidden */
  38330. export var passCubePixelShader: {
  38331. name: string;
  38332. shader: string;
  38333. };
  38334. }
  38335. declare module "babylonjs/PostProcesses/passPostProcess" {
  38336. import { Nullable } from "babylonjs/types";
  38337. import { Camera } from "babylonjs/Cameras/camera";
  38338. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38339. import { Engine } from "babylonjs/Engines/engine";
  38340. import "babylonjs/Shaders/pass.fragment";
  38341. import "babylonjs/Shaders/passCube.fragment";
  38342. /**
  38343. * PassPostProcess which produces an output the same as it's input
  38344. */
  38345. export class PassPostProcess extends PostProcess {
  38346. /**
  38347. * Creates the PassPostProcess
  38348. * @param name The name of the effect.
  38349. * @param options The required width/height ratio to downsize to before computing the render pass.
  38350. * @param camera The camera to apply the render pass to.
  38351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38352. * @param engine The engine which the post process will be applied. (default: current engine)
  38353. * @param reusable If the post process can be reused on the same frame. (default: false)
  38354. * @param textureType The type of texture to be used when performing the post processing.
  38355. * @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)
  38356. */
  38357. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38358. }
  38359. /**
  38360. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38361. */
  38362. export class PassCubePostProcess extends PostProcess {
  38363. private _face;
  38364. /**
  38365. * Gets or sets the cube face to display.
  38366. * * 0 is +X
  38367. * * 1 is -X
  38368. * * 2 is +Y
  38369. * * 3 is -Y
  38370. * * 4 is +Z
  38371. * * 5 is -Z
  38372. */
  38373. face: number;
  38374. /**
  38375. * Creates the PassCubePostProcess
  38376. * @param name The name of the effect.
  38377. * @param options The required width/height ratio to downsize to before computing the render pass.
  38378. * @param camera The camera to apply the render pass to.
  38379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38380. * @param engine The engine which the post process will be applied. (default: current engine)
  38381. * @param reusable If the post process can be reused on the same frame. (default: false)
  38382. * @param textureType The type of texture to be used when performing the post processing.
  38383. * @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)
  38384. */
  38385. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38386. }
  38387. }
  38388. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38389. /** @hidden */
  38390. export var anaglyphPixelShader: {
  38391. name: string;
  38392. shader: string;
  38393. };
  38394. }
  38395. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38396. import { Engine } from "babylonjs/Engines/engine";
  38397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38398. import { Camera } from "babylonjs/Cameras/camera";
  38399. import "babylonjs/Shaders/anaglyph.fragment";
  38400. /**
  38401. * Postprocess used to generate anaglyphic rendering
  38402. */
  38403. export class AnaglyphPostProcess extends PostProcess {
  38404. private _passedProcess;
  38405. /**
  38406. * Creates a new AnaglyphPostProcess
  38407. * @param name defines postprocess name
  38408. * @param options defines creation options or target ratio scale
  38409. * @param rigCameras defines cameras using this postprocess
  38410. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38411. * @param engine defines hosting engine
  38412. * @param reusable defines if the postprocess will be reused multiple times per frame
  38413. */
  38414. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38415. }
  38416. }
  38417. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38418. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38419. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38420. import { Scene } from "babylonjs/scene";
  38421. import { Vector3 } from "babylonjs/Maths/math";
  38422. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38423. /**
  38424. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38425. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38426. */
  38427. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38428. /**
  38429. * Creates a new AnaglyphArcRotateCamera
  38430. * @param name defines camera name
  38431. * @param alpha defines alpha angle (in radians)
  38432. * @param beta defines beta angle (in radians)
  38433. * @param radius defines radius
  38434. * @param target defines camera target
  38435. * @param interaxialDistance defines distance between each color axis
  38436. * @param scene defines the hosting scene
  38437. */
  38438. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38439. /**
  38440. * Gets camera class name
  38441. * @returns AnaglyphArcRotateCamera
  38442. */
  38443. getClassName(): string;
  38444. }
  38445. }
  38446. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38447. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38448. import { Scene } from "babylonjs/scene";
  38449. import { Vector3 } from "babylonjs/Maths/math";
  38450. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38451. /**
  38452. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38454. */
  38455. export class AnaglyphFreeCamera extends FreeCamera {
  38456. /**
  38457. * Creates a new AnaglyphFreeCamera
  38458. * @param name defines camera name
  38459. * @param position defines initial position
  38460. * @param interaxialDistance defines distance between each color axis
  38461. * @param scene defines the hosting scene
  38462. */
  38463. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38464. /**
  38465. * Gets camera class name
  38466. * @returns AnaglyphFreeCamera
  38467. */
  38468. getClassName(): string;
  38469. }
  38470. }
  38471. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38472. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38473. import { Scene } from "babylonjs/scene";
  38474. import { Vector3 } from "babylonjs/Maths/math";
  38475. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38476. /**
  38477. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38479. */
  38480. export class AnaglyphGamepadCamera extends GamepadCamera {
  38481. /**
  38482. * Creates a new AnaglyphGamepadCamera
  38483. * @param name defines camera name
  38484. * @param position defines initial position
  38485. * @param interaxialDistance defines distance between each color axis
  38486. * @param scene defines the hosting scene
  38487. */
  38488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38489. /**
  38490. * Gets camera class name
  38491. * @returns AnaglyphGamepadCamera
  38492. */
  38493. getClassName(): string;
  38494. }
  38495. }
  38496. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38497. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38498. import { Scene } from "babylonjs/scene";
  38499. import { Vector3 } from "babylonjs/Maths/math";
  38500. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38501. /**
  38502. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38503. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38504. */
  38505. export class AnaglyphUniversalCamera extends UniversalCamera {
  38506. /**
  38507. * Creates a new AnaglyphUniversalCamera
  38508. * @param name defines camera name
  38509. * @param position defines initial position
  38510. * @param interaxialDistance defines distance between each color axis
  38511. * @param scene defines the hosting scene
  38512. */
  38513. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38514. /**
  38515. * Gets camera class name
  38516. * @returns AnaglyphUniversalCamera
  38517. */
  38518. getClassName(): string;
  38519. }
  38520. }
  38521. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38522. /** @hidden */
  38523. export var stereoscopicInterlacePixelShader: {
  38524. name: string;
  38525. shader: string;
  38526. };
  38527. }
  38528. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38529. import { Camera } from "babylonjs/Cameras/camera";
  38530. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38531. import { Engine } from "babylonjs/Engines/engine";
  38532. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38533. /**
  38534. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38535. */
  38536. export class StereoscopicInterlacePostProcess extends PostProcess {
  38537. private _stepSize;
  38538. private _passedProcess;
  38539. /**
  38540. * Initializes a StereoscopicInterlacePostProcess
  38541. * @param name The name of the effect.
  38542. * @param rigCameras The rig cameras to be appled to the post process
  38543. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38545. * @param engine The engine which the post process will be applied. (default: current engine)
  38546. * @param reusable If the post process can be reused on the same frame. (default: false)
  38547. */
  38548. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38549. }
  38550. }
  38551. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38552. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38553. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3 } from "babylonjs/Maths/math";
  38556. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38557. /**
  38558. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38559. * @see http://doc.babylonjs.com/features/cameras
  38560. */
  38561. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38562. /**
  38563. * Creates a new StereoscopicArcRotateCamera
  38564. * @param name defines camera name
  38565. * @param alpha defines alpha angle (in radians)
  38566. * @param beta defines beta angle (in radians)
  38567. * @param radius defines radius
  38568. * @param target defines camera target
  38569. * @param interaxialDistance defines distance between each color axis
  38570. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38571. * @param scene defines the hosting scene
  38572. */
  38573. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38574. /**
  38575. * Gets camera class name
  38576. * @returns StereoscopicArcRotateCamera
  38577. */
  38578. getClassName(): string;
  38579. }
  38580. }
  38581. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38582. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38583. import { Scene } from "babylonjs/scene";
  38584. import { Vector3 } from "babylonjs/Maths/math";
  38585. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38586. /**
  38587. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38588. * @see http://doc.babylonjs.com/features/cameras
  38589. */
  38590. export class StereoscopicFreeCamera extends FreeCamera {
  38591. /**
  38592. * Creates a new StereoscopicFreeCamera
  38593. * @param name defines camera name
  38594. * @param position defines initial position
  38595. * @param interaxialDistance defines distance between each color axis
  38596. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38597. * @param scene defines the hosting scene
  38598. */
  38599. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38600. /**
  38601. * Gets camera class name
  38602. * @returns StereoscopicFreeCamera
  38603. */
  38604. getClassName(): string;
  38605. }
  38606. }
  38607. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38608. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38609. import { Scene } from "babylonjs/scene";
  38610. import { Vector3 } from "babylonjs/Maths/math";
  38611. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38612. /**
  38613. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38614. * @see http://doc.babylonjs.com/features/cameras
  38615. */
  38616. export class StereoscopicGamepadCamera extends GamepadCamera {
  38617. /**
  38618. * Creates a new StereoscopicGamepadCamera
  38619. * @param name defines camera name
  38620. * @param position defines initial position
  38621. * @param interaxialDistance defines distance between each color axis
  38622. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38623. * @param scene defines the hosting scene
  38624. */
  38625. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38626. /**
  38627. * Gets camera class name
  38628. * @returns StereoscopicGamepadCamera
  38629. */
  38630. getClassName(): string;
  38631. }
  38632. }
  38633. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38634. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38635. import { Scene } from "babylonjs/scene";
  38636. import { Vector3 } from "babylonjs/Maths/math";
  38637. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38638. /**
  38639. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38640. * @see http://doc.babylonjs.com/features/cameras
  38641. */
  38642. export class StereoscopicUniversalCamera extends UniversalCamera {
  38643. /**
  38644. * Creates a new StereoscopicUniversalCamera
  38645. * @param name defines camera name
  38646. * @param position defines initial position
  38647. * @param interaxialDistance defines distance between each color axis
  38648. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38649. * @param scene defines the hosting scene
  38650. */
  38651. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38652. /**
  38653. * Gets camera class name
  38654. * @returns StereoscopicUniversalCamera
  38655. */
  38656. getClassName(): string;
  38657. }
  38658. }
  38659. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38660. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38661. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38662. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38663. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38664. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38665. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38666. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38667. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38668. }
  38669. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38670. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38671. import { Scene } from "babylonjs/scene";
  38672. import { Vector3 } from "babylonjs/Maths/math";
  38673. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38674. /**
  38675. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38676. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38677. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38678. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38679. */
  38680. export class VirtualJoysticksCamera extends FreeCamera {
  38681. /**
  38682. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38683. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38684. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38685. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38686. * @param name Define the name of the camera in the scene
  38687. * @param position Define the start position of the camera in the scene
  38688. * @param scene Define the scene the camera belongs to
  38689. */
  38690. constructor(name: string, position: Vector3, scene: Scene);
  38691. /**
  38692. * Gets the current object class name.
  38693. * @return the class name
  38694. */
  38695. getClassName(): string;
  38696. }
  38697. }
  38698. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38699. import { Matrix } from "babylonjs/Maths/math";
  38700. /**
  38701. * This represents all the required metrics to create a VR camera.
  38702. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38703. */
  38704. export class VRCameraMetrics {
  38705. /**
  38706. * Define the horizontal resolution off the screen.
  38707. */
  38708. hResolution: number;
  38709. /**
  38710. * Define the vertical resolution off the screen.
  38711. */
  38712. vResolution: number;
  38713. /**
  38714. * Define the horizontal screen size.
  38715. */
  38716. hScreenSize: number;
  38717. /**
  38718. * Define the vertical screen size.
  38719. */
  38720. vScreenSize: number;
  38721. /**
  38722. * Define the vertical screen center position.
  38723. */
  38724. vScreenCenter: number;
  38725. /**
  38726. * Define the distance of the eyes to the screen.
  38727. */
  38728. eyeToScreenDistance: number;
  38729. /**
  38730. * Define the distance between both lenses
  38731. */
  38732. lensSeparationDistance: number;
  38733. /**
  38734. * Define the distance between both viewer's eyes.
  38735. */
  38736. interpupillaryDistance: number;
  38737. /**
  38738. * Define the distortion factor of the VR postprocess.
  38739. * Please, touch with care.
  38740. */
  38741. distortionK: number[];
  38742. /**
  38743. * Define the chromatic aberration correction factors for the VR post process.
  38744. */
  38745. chromaAbCorrection: number[];
  38746. /**
  38747. * Define the scale factor of the post process.
  38748. * The smaller the better but the slower.
  38749. */
  38750. postProcessScaleFactor: number;
  38751. /**
  38752. * Define an offset for the lens center.
  38753. */
  38754. lensCenterOffset: number;
  38755. /**
  38756. * Define if the current vr camera should compensate the distortion of the lense or not.
  38757. */
  38758. compensateDistortion: boolean;
  38759. /**
  38760. * Defines if multiview should be enabled when rendering (Default: false)
  38761. */
  38762. multiviewEnabled: boolean;
  38763. /**
  38764. * Gets the rendering aspect ratio based on the provided resolutions.
  38765. */
  38766. readonly aspectRatio: number;
  38767. /**
  38768. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38769. */
  38770. readonly aspectRatioFov: number;
  38771. /**
  38772. * @hidden
  38773. */
  38774. readonly leftHMatrix: Matrix;
  38775. /**
  38776. * @hidden
  38777. */
  38778. readonly rightHMatrix: Matrix;
  38779. /**
  38780. * @hidden
  38781. */
  38782. readonly leftPreViewMatrix: Matrix;
  38783. /**
  38784. * @hidden
  38785. */
  38786. readonly rightPreViewMatrix: Matrix;
  38787. /**
  38788. * Get the default VRMetrics based on the most generic setup.
  38789. * @returns the default vr metrics
  38790. */
  38791. static GetDefault(): VRCameraMetrics;
  38792. }
  38793. }
  38794. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38795. /** @hidden */
  38796. export var vrDistortionCorrectionPixelShader: {
  38797. name: string;
  38798. shader: string;
  38799. };
  38800. }
  38801. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38802. import { Camera } from "babylonjs/Cameras/camera";
  38803. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38804. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38805. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38806. /**
  38807. * VRDistortionCorrectionPostProcess used for mobile VR
  38808. */
  38809. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38810. private _isRightEye;
  38811. private _distortionFactors;
  38812. private _postProcessScaleFactor;
  38813. private _lensCenterOffset;
  38814. private _scaleIn;
  38815. private _scaleFactor;
  38816. private _lensCenter;
  38817. /**
  38818. * Initializes the VRDistortionCorrectionPostProcess
  38819. * @param name The name of the effect.
  38820. * @param camera The camera to apply the render pass to.
  38821. * @param isRightEye If this is for the right eye distortion
  38822. * @param vrMetrics All the required metrics for the VR camera
  38823. */
  38824. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38825. }
  38826. }
  38827. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38828. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38829. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38830. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38831. import { Scene } from "babylonjs/scene";
  38832. import { Vector3 } from "babylonjs/Maths/math";
  38833. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38834. import "babylonjs/Cameras/RigModes/vrRigMode";
  38835. /**
  38836. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38837. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38838. */
  38839. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38840. /**
  38841. * Creates a new VRDeviceOrientationArcRotateCamera
  38842. * @param name defines camera name
  38843. * @param alpha defines the camera rotation along the logitudinal axis
  38844. * @param beta defines the camera rotation along the latitudinal axis
  38845. * @param radius defines the camera distance from its target
  38846. * @param target defines the camera target
  38847. * @param scene defines the scene the camera belongs to
  38848. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38849. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38850. */
  38851. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38852. /**
  38853. * Gets camera class name
  38854. * @returns VRDeviceOrientationArcRotateCamera
  38855. */
  38856. getClassName(): string;
  38857. }
  38858. }
  38859. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38860. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38861. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38862. import { Scene } from "babylonjs/scene";
  38863. import { Vector3 } from "babylonjs/Maths/math";
  38864. import "babylonjs/Cameras/RigModes/vrRigMode";
  38865. /**
  38866. * Camera used to simulate VR rendering (based on FreeCamera)
  38867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38868. */
  38869. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38870. /**
  38871. * Creates a new VRDeviceOrientationFreeCamera
  38872. * @param name defines camera name
  38873. * @param position defines the start position of the camera
  38874. * @param scene defines the scene the camera belongs to
  38875. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38876. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38877. */
  38878. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38879. /**
  38880. * Gets camera class name
  38881. * @returns VRDeviceOrientationFreeCamera
  38882. */
  38883. getClassName(): string;
  38884. }
  38885. }
  38886. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38887. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38888. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38889. import { Scene } from "babylonjs/scene";
  38890. import { Vector3 } from "babylonjs/Maths/math";
  38891. /**
  38892. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38893. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38894. */
  38895. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38896. /**
  38897. * Creates a new VRDeviceOrientationGamepadCamera
  38898. * @param name defines camera name
  38899. * @param position defines the start position of the camera
  38900. * @param scene defines the scene the camera belongs to
  38901. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38902. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38903. */
  38904. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38905. /**
  38906. * Gets camera class name
  38907. * @returns VRDeviceOrientationGamepadCamera
  38908. */
  38909. getClassName(): string;
  38910. }
  38911. }
  38912. declare module "babylonjs/Gamepads/xboxGamepad" {
  38913. import { Observable } from "babylonjs/Misc/observable";
  38914. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38915. /**
  38916. * Defines supported buttons for XBox360 compatible gamepads
  38917. */
  38918. export enum Xbox360Button {
  38919. /** A */
  38920. A = 0,
  38921. /** B */
  38922. B = 1,
  38923. /** X */
  38924. X = 2,
  38925. /** Y */
  38926. Y = 3,
  38927. /** Start */
  38928. Start = 4,
  38929. /** Back */
  38930. Back = 5,
  38931. /** Left button */
  38932. LB = 6,
  38933. /** Right button */
  38934. RB = 7,
  38935. /** Left stick */
  38936. LeftStick = 8,
  38937. /** Right stick */
  38938. RightStick = 9
  38939. }
  38940. /** Defines values for XBox360 DPad */
  38941. export enum Xbox360Dpad {
  38942. /** Up */
  38943. Up = 0,
  38944. /** Down */
  38945. Down = 1,
  38946. /** Left */
  38947. Left = 2,
  38948. /** Right */
  38949. Right = 3
  38950. }
  38951. /**
  38952. * Defines a XBox360 gamepad
  38953. */
  38954. export class Xbox360Pad extends Gamepad {
  38955. private _leftTrigger;
  38956. private _rightTrigger;
  38957. private _onlefttriggerchanged;
  38958. private _onrighttriggerchanged;
  38959. private _onbuttondown;
  38960. private _onbuttonup;
  38961. private _ondpaddown;
  38962. private _ondpadup;
  38963. /** Observable raised when a button is pressed */
  38964. onButtonDownObservable: Observable<Xbox360Button>;
  38965. /** Observable raised when a button is released */
  38966. onButtonUpObservable: Observable<Xbox360Button>;
  38967. /** Observable raised when a pad is pressed */
  38968. onPadDownObservable: Observable<Xbox360Dpad>;
  38969. /** Observable raised when a pad is released */
  38970. onPadUpObservable: Observable<Xbox360Dpad>;
  38971. private _buttonA;
  38972. private _buttonB;
  38973. private _buttonX;
  38974. private _buttonY;
  38975. private _buttonBack;
  38976. private _buttonStart;
  38977. private _buttonLB;
  38978. private _buttonRB;
  38979. private _buttonLeftStick;
  38980. private _buttonRightStick;
  38981. private _dPadUp;
  38982. private _dPadDown;
  38983. private _dPadLeft;
  38984. private _dPadRight;
  38985. private _isXboxOnePad;
  38986. /**
  38987. * Creates a new XBox360 gamepad object
  38988. * @param id defines the id of this gamepad
  38989. * @param index defines its index
  38990. * @param gamepad defines the internal HTML gamepad object
  38991. * @param xboxOne defines if it is a XBox One gamepad
  38992. */
  38993. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38994. /**
  38995. * Defines the callback to call when left trigger is pressed
  38996. * @param callback defines the callback to use
  38997. */
  38998. onlefttriggerchanged(callback: (value: number) => void): void;
  38999. /**
  39000. * Defines the callback to call when right trigger is pressed
  39001. * @param callback defines the callback to use
  39002. */
  39003. onrighttriggerchanged(callback: (value: number) => void): void;
  39004. /**
  39005. * Gets the left trigger value
  39006. */
  39007. /**
  39008. * Sets the left trigger value
  39009. */
  39010. leftTrigger: number;
  39011. /**
  39012. * Gets the right trigger value
  39013. */
  39014. /**
  39015. * Sets the right trigger value
  39016. */
  39017. rightTrigger: number;
  39018. /**
  39019. * Defines the callback to call when a button is pressed
  39020. * @param callback defines the callback to use
  39021. */
  39022. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39023. /**
  39024. * Defines the callback to call when a button is released
  39025. * @param callback defines the callback to use
  39026. */
  39027. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39028. /**
  39029. * Defines the callback to call when a pad is pressed
  39030. * @param callback defines the callback to use
  39031. */
  39032. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39033. /**
  39034. * Defines the callback to call when a pad is released
  39035. * @param callback defines the callback to use
  39036. */
  39037. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39038. private _setButtonValue;
  39039. private _setDPadValue;
  39040. /**
  39041. * Gets the value of the `A` button
  39042. */
  39043. /**
  39044. * Sets the value of the `A` button
  39045. */
  39046. buttonA: number;
  39047. /**
  39048. * Gets the value of the `B` button
  39049. */
  39050. /**
  39051. * Sets the value of the `B` button
  39052. */
  39053. buttonB: number;
  39054. /**
  39055. * Gets the value of the `X` button
  39056. */
  39057. /**
  39058. * Sets the value of the `X` button
  39059. */
  39060. buttonX: number;
  39061. /**
  39062. * Gets the value of the `Y` button
  39063. */
  39064. /**
  39065. * Sets the value of the `Y` button
  39066. */
  39067. buttonY: number;
  39068. /**
  39069. * Gets the value of the `Start` button
  39070. */
  39071. /**
  39072. * Sets the value of the `Start` button
  39073. */
  39074. buttonStart: number;
  39075. /**
  39076. * Gets the value of the `Back` button
  39077. */
  39078. /**
  39079. * Sets the value of the `Back` button
  39080. */
  39081. buttonBack: number;
  39082. /**
  39083. * Gets the value of the `Left` button
  39084. */
  39085. /**
  39086. * Sets the value of the `Left` button
  39087. */
  39088. buttonLB: number;
  39089. /**
  39090. * Gets the value of the `Right` button
  39091. */
  39092. /**
  39093. * Sets the value of the `Right` button
  39094. */
  39095. buttonRB: number;
  39096. /**
  39097. * Gets the value of the Left joystick
  39098. */
  39099. /**
  39100. * Sets the value of the Left joystick
  39101. */
  39102. buttonLeftStick: number;
  39103. /**
  39104. * Gets the value of the Right joystick
  39105. */
  39106. /**
  39107. * Sets the value of the Right joystick
  39108. */
  39109. buttonRightStick: number;
  39110. /**
  39111. * Gets the value of D-pad up
  39112. */
  39113. /**
  39114. * Sets the value of D-pad up
  39115. */
  39116. dPadUp: number;
  39117. /**
  39118. * Gets the value of D-pad down
  39119. */
  39120. /**
  39121. * Sets the value of D-pad down
  39122. */
  39123. dPadDown: number;
  39124. /**
  39125. * Gets the value of D-pad left
  39126. */
  39127. /**
  39128. * Sets the value of D-pad left
  39129. */
  39130. dPadLeft: number;
  39131. /**
  39132. * Gets the value of D-pad right
  39133. */
  39134. /**
  39135. * Sets the value of D-pad right
  39136. */
  39137. dPadRight: number;
  39138. /**
  39139. * Force the gamepad to synchronize with device values
  39140. */
  39141. update(): void;
  39142. /**
  39143. * Disposes the gamepad
  39144. */
  39145. dispose(): void;
  39146. }
  39147. }
  39148. declare module "babylonjs/Materials/pushMaterial" {
  39149. import { Nullable } from "babylonjs/types";
  39150. import { Scene } from "babylonjs/scene";
  39151. import { Matrix } from "babylonjs/Maths/math";
  39152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39153. import { Mesh } from "babylonjs/Meshes/mesh";
  39154. import { Material } from "babylonjs/Materials/material";
  39155. import { Effect } from "babylonjs/Materials/effect";
  39156. /**
  39157. * Base class of materials working in push mode in babylon JS
  39158. * @hidden
  39159. */
  39160. export class PushMaterial extends Material {
  39161. protected _activeEffect: Effect;
  39162. protected _normalMatrix: Matrix;
  39163. /**
  39164. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39165. * This means that the material can keep using a previous shader while a new one is being compiled.
  39166. * This is mostly used when shader parallel compilation is supported (true by default)
  39167. */
  39168. allowShaderHotSwapping: boolean;
  39169. constructor(name: string, scene: Scene);
  39170. getEffect(): Effect;
  39171. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39172. /**
  39173. * Binds the given world matrix to the active effect
  39174. *
  39175. * @param world the matrix to bind
  39176. */
  39177. bindOnlyWorldMatrix(world: Matrix): void;
  39178. /**
  39179. * Binds the given normal matrix to the active effect
  39180. *
  39181. * @param normalMatrix the matrix to bind
  39182. */
  39183. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39184. bind(world: Matrix, mesh?: Mesh): void;
  39185. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39186. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39187. }
  39188. }
  39189. declare module "babylonjs/Materials/materialFlags" {
  39190. /**
  39191. * This groups all the flags used to control the materials channel.
  39192. */
  39193. export class MaterialFlags {
  39194. private static _DiffuseTextureEnabled;
  39195. /**
  39196. * Are diffuse textures enabled in the application.
  39197. */
  39198. static DiffuseTextureEnabled: boolean;
  39199. private static _AmbientTextureEnabled;
  39200. /**
  39201. * Are ambient textures enabled in the application.
  39202. */
  39203. static AmbientTextureEnabled: boolean;
  39204. private static _OpacityTextureEnabled;
  39205. /**
  39206. * Are opacity textures enabled in the application.
  39207. */
  39208. static OpacityTextureEnabled: boolean;
  39209. private static _ReflectionTextureEnabled;
  39210. /**
  39211. * Are reflection textures enabled in the application.
  39212. */
  39213. static ReflectionTextureEnabled: boolean;
  39214. private static _EmissiveTextureEnabled;
  39215. /**
  39216. * Are emissive textures enabled in the application.
  39217. */
  39218. static EmissiveTextureEnabled: boolean;
  39219. private static _SpecularTextureEnabled;
  39220. /**
  39221. * Are specular textures enabled in the application.
  39222. */
  39223. static SpecularTextureEnabled: boolean;
  39224. private static _BumpTextureEnabled;
  39225. /**
  39226. * Are bump textures enabled in the application.
  39227. */
  39228. static BumpTextureEnabled: boolean;
  39229. private static _LightmapTextureEnabled;
  39230. /**
  39231. * Are lightmap textures enabled in the application.
  39232. */
  39233. static LightmapTextureEnabled: boolean;
  39234. private static _RefractionTextureEnabled;
  39235. /**
  39236. * Are refraction textures enabled in the application.
  39237. */
  39238. static RefractionTextureEnabled: boolean;
  39239. private static _ColorGradingTextureEnabled;
  39240. /**
  39241. * Are color grading textures enabled in the application.
  39242. */
  39243. static ColorGradingTextureEnabled: boolean;
  39244. private static _FresnelEnabled;
  39245. /**
  39246. * Are fresnels enabled in the application.
  39247. */
  39248. static FresnelEnabled: boolean;
  39249. private static _ClearCoatTextureEnabled;
  39250. /**
  39251. * Are clear coat textures enabled in the application.
  39252. */
  39253. static ClearCoatTextureEnabled: boolean;
  39254. private static _ClearCoatBumpTextureEnabled;
  39255. /**
  39256. * Are clear coat bump textures enabled in the application.
  39257. */
  39258. static ClearCoatBumpTextureEnabled: boolean;
  39259. private static _ClearCoatTintTextureEnabled;
  39260. /**
  39261. * Are clear coat tint textures enabled in the application.
  39262. */
  39263. static ClearCoatTintTextureEnabled: boolean;
  39264. private static _SheenTextureEnabled;
  39265. /**
  39266. * Are sheen textures enabled in the application.
  39267. */
  39268. static SheenTextureEnabled: boolean;
  39269. private static _AnisotropicTextureEnabled;
  39270. /**
  39271. * Are anisotropic textures enabled in the application.
  39272. */
  39273. static AnisotropicTextureEnabled: boolean;
  39274. }
  39275. }
  39276. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39277. /** @hidden */
  39278. export var defaultFragmentDeclaration: {
  39279. name: string;
  39280. shader: string;
  39281. };
  39282. }
  39283. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39284. /** @hidden */
  39285. export var defaultUboDeclaration: {
  39286. name: string;
  39287. shader: string;
  39288. };
  39289. }
  39290. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39291. /** @hidden */
  39292. export var lightFragmentDeclaration: {
  39293. name: string;
  39294. shader: string;
  39295. };
  39296. }
  39297. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39298. /** @hidden */
  39299. export var lightUboDeclaration: {
  39300. name: string;
  39301. shader: string;
  39302. };
  39303. }
  39304. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39305. /** @hidden */
  39306. export var lightsFragmentFunctions: {
  39307. name: string;
  39308. shader: string;
  39309. };
  39310. }
  39311. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39312. /** @hidden */
  39313. export var shadowsFragmentFunctions: {
  39314. name: string;
  39315. shader: string;
  39316. };
  39317. }
  39318. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39319. /** @hidden */
  39320. export var fresnelFunction: {
  39321. name: string;
  39322. shader: string;
  39323. };
  39324. }
  39325. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39326. /** @hidden */
  39327. export var reflectionFunction: {
  39328. name: string;
  39329. shader: string;
  39330. };
  39331. }
  39332. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39333. /** @hidden */
  39334. export var bumpFragmentFunctions: {
  39335. name: string;
  39336. shader: string;
  39337. };
  39338. }
  39339. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39340. /** @hidden */
  39341. export var logDepthDeclaration: {
  39342. name: string;
  39343. shader: string;
  39344. };
  39345. }
  39346. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39347. /** @hidden */
  39348. export var bumpFragment: {
  39349. name: string;
  39350. shader: string;
  39351. };
  39352. }
  39353. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39354. /** @hidden */
  39355. export var depthPrePass: {
  39356. name: string;
  39357. shader: string;
  39358. };
  39359. }
  39360. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39361. /** @hidden */
  39362. export var lightFragment: {
  39363. name: string;
  39364. shader: string;
  39365. };
  39366. }
  39367. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39368. /** @hidden */
  39369. export var logDepthFragment: {
  39370. name: string;
  39371. shader: string;
  39372. };
  39373. }
  39374. declare module "babylonjs/Shaders/default.fragment" {
  39375. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39376. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39378. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39379. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39380. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39381. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39382. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39383. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39384. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39385. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39386. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39387. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39388. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39389. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39390. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39391. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39392. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39393. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39394. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39395. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39396. /** @hidden */
  39397. export var defaultPixelShader: {
  39398. name: string;
  39399. shader: string;
  39400. };
  39401. }
  39402. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39403. /** @hidden */
  39404. export var defaultVertexDeclaration: {
  39405. name: string;
  39406. shader: string;
  39407. };
  39408. }
  39409. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39410. /** @hidden */
  39411. export var bumpVertexDeclaration: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39417. /** @hidden */
  39418. export var bumpVertex: {
  39419. name: string;
  39420. shader: string;
  39421. };
  39422. }
  39423. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39424. /** @hidden */
  39425. export var fogVertex: {
  39426. name: string;
  39427. shader: string;
  39428. };
  39429. }
  39430. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39431. /** @hidden */
  39432. export var shadowsVertex: {
  39433. name: string;
  39434. shader: string;
  39435. };
  39436. }
  39437. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39438. /** @hidden */
  39439. export var pointCloudVertex: {
  39440. name: string;
  39441. shader: string;
  39442. };
  39443. }
  39444. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39445. /** @hidden */
  39446. export var logDepthVertex: {
  39447. name: string;
  39448. shader: string;
  39449. };
  39450. }
  39451. declare module "babylonjs/Shaders/default.vertex" {
  39452. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39453. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39457. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39459. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39460. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39461. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39464. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39468. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39469. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39470. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39471. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39472. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39473. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39474. /** @hidden */
  39475. export var defaultVertexShader: {
  39476. name: string;
  39477. shader: string;
  39478. };
  39479. }
  39480. declare module "babylonjs/Materials/standardMaterial" {
  39481. import { SmartArray } from "babylonjs/Misc/smartArray";
  39482. import { IAnimatable } from "babylonjs/Misc/tools";
  39483. import { Nullable } from "babylonjs/types";
  39484. import { Scene } from "babylonjs/scene";
  39485. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39488. import { Mesh } from "babylonjs/Meshes/mesh";
  39489. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39490. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39491. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39492. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39493. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39496. import "babylonjs/Shaders/default.fragment";
  39497. import "babylonjs/Shaders/default.vertex";
  39498. /** @hidden */
  39499. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39500. MAINUV1: boolean;
  39501. MAINUV2: boolean;
  39502. DIFFUSE: boolean;
  39503. DIFFUSEDIRECTUV: number;
  39504. AMBIENT: boolean;
  39505. AMBIENTDIRECTUV: number;
  39506. OPACITY: boolean;
  39507. OPACITYDIRECTUV: number;
  39508. OPACITYRGB: boolean;
  39509. REFLECTION: boolean;
  39510. EMISSIVE: boolean;
  39511. EMISSIVEDIRECTUV: number;
  39512. SPECULAR: boolean;
  39513. SPECULARDIRECTUV: number;
  39514. BUMP: boolean;
  39515. BUMPDIRECTUV: number;
  39516. PARALLAX: boolean;
  39517. PARALLAXOCCLUSION: boolean;
  39518. SPECULAROVERALPHA: boolean;
  39519. CLIPPLANE: boolean;
  39520. CLIPPLANE2: boolean;
  39521. CLIPPLANE3: boolean;
  39522. CLIPPLANE4: boolean;
  39523. ALPHATEST: boolean;
  39524. DEPTHPREPASS: boolean;
  39525. ALPHAFROMDIFFUSE: boolean;
  39526. POINTSIZE: boolean;
  39527. FOG: boolean;
  39528. SPECULARTERM: boolean;
  39529. DIFFUSEFRESNEL: boolean;
  39530. OPACITYFRESNEL: boolean;
  39531. REFLECTIONFRESNEL: boolean;
  39532. REFRACTIONFRESNEL: boolean;
  39533. EMISSIVEFRESNEL: boolean;
  39534. FRESNEL: boolean;
  39535. NORMAL: boolean;
  39536. UV1: boolean;
  39537. UV2: boolean;
  39538. VERTEXCOLOR: boolean;
  39539. VERTEXALPHA: boolean;
  39540. NUM_BONE_INFLUENCERS: number;
  39541. BonesPerMesh: number;
  39542. BONETEXTURE: boolean;
  39543. INSTANCES: boolean;
  39544. GLOSSINESS: boolean;
  39545. ROUGHNESS: boolean;
  39546. EMISSIVEASILLUMINATION: boolean;
  39547. LINKEMISSIVEWITHDIFFUSE: boolean;
  39548. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39549. LIGHTMAP: boolean;
  39550. LIGHTMAPDIRECTUV: number;
  39551. OBJECTSPACE_NORMALMAP: boolean;
  39552. USELIGHTMAPASSHADOWMAP: boolean;
  39553. REFLECTIONMAP_3D: boolean;
  39554. REFLECTIONMAP_SPHERICAL: boolean;
  39555. REFLECTIONMAP_PLANAR: boolean;
  39556. REFLECTIONMAP_CUBIC: boolean;
  39557. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39558. REFLECTIONMAP_PROJECTION: boolean;
  39559. REFLECTIONMAP_SKYBOX: boolean;
  39560. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39561. REFLECTIONMAP_EXPLICIT: boolean;
  39562. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39563. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39564. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39565. INVERTCUBICMAP: boolean;
  39566. LOGARITHMICDEPTH: boolean;
  39567. REFRACTION: boolean;
  39568. REFRACTIONMAP_3D: boolean;
  39569. REFLECTIONOVERALPHA: boolean;
  39570. TWOSIDEDLIGHTING: boolean;
  39571. SHADOWFLOAT: boolean;
  39572. MORPHTARGETS: boolean;
  39573. MORPHTARGETS_NORMAL: boolean;
  39574. MORPHTARGETS_TANGENT: boolean;
  39575. NUM_MORPH_INFLUENCERS: number;
  39576. NONUNIFORMSCALING: boolean;
  39577. PREMULTIPLYALPHA: boolean;
  39578. IMAGEPROCESSING: boolean;
  39579. VIGNETTE: boolean;
  39580. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39581. VIGNETTEBLENDMODEOPAQUE: boolean;
  39582. TONEMAPPING: boolean;
  39583. TONEMAPPING_ACES: boolean;
  39584. CONTRAST: boolean;
  39585. COLORCURVES: boolean;
  39586. COLORGRADING: boolean;
  39587. COLORGRADING3D: boolean;
  39588. SAMPLER3DGREENDEPTH: boolean;
  39589. SAMPLER3DBGRMAP: boolean;
  39590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39591. MULTIVIEW: boolean;
  39592. /**
  39593. * If the reflection texture on this material is in linear color space
  39594. * @hidden
  39595. */
  39596. IS_REFLECTION_LINEAR: boolean;
  39597. /**
  39598. * If the refraction texture on this material is in linear color space
  39599. * @hidden
  39600. */
  39601. IS_REFRACTION_LINEAR: boolean;
  39602. EXPOSURE: boolean;
  39603. constructor();
  39604. setReflectionMode(modeToEnable: string): void;
  39605. }
  39606. /**
  39607. * This is the default material used in Babylon. It is the best trade off between quality
  39608. * and performances.
  39609. * @see http://doc.babylonjs.com/babylon101/materials
  39610. */
  39611. export class StandardMaterial extends PushMaterial {
  39612. private _diffuseTexture;
  39613. /**
  39614. * The basic texture of the material as viewed under a light.
  39615. */
  39616. diffuseTexture: Nullable<BaseTexture>;
  39617. private _ambientTexture;
  39618. /**
  39619. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39620. */
  39621. ambientTexture: Nullable<BaseTexture>;
  39622. private _opacityTexture;
  39623. /**
  39624. * Define the transparency of the material from a texture.
  39625. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39626. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39627. */
  39628. opacityTexture: Nullable<BaseTexture>;
  39629. private _reflectionTexture;
  39630. /**
  39631. * Define the texture used to display the reflection.
  39632. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39633. */
  39634. reflectionTexture: Nullable<BaseTexture>;
  39635. private _emissiveTexture;
  39636. /**
  39637. * Define texture of the material as if self lit.
  39638. * This will be mixed in the final result even in the absence of light.
  39639. */
  39640. emissiveTexture: Nullable<BaseTexture>;
  39641. private _specularTexture;
  39642. /**
  39643. * Define how the color and intensity of the highlight given by the light in the material.
  39644. */
  39645. specularTexture: Nullable<BaseTexture>;
  39646. private _bumpTexture;
  39647. /**
  39648. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39649. * 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.
  39650. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39651. */
  39652. bumpTexture: Nullable<BaseTexture>;
  39653. private _lightmapTexture;
  39654. /**
  39655. * Complex lighting can be computationally expensive to compute at runtime.
  39656. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39657. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39658. */
  39659. lightmapTexture: Nullable<BaseTexture>;
  39660. private _refractionTexture;
  39661. /**
  39662. * Define the texture used to display the refraction.
  39663. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39664. */
  39665. refractionTexture: Nullable<BaseTexture>;
  39666. /**
  39667. * The color of the material lit by the environmental background lighting.
  39668. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39669. */
  39670. ambientColor: Color3;
  39671. /**
  39672. * The basic color of the material as viewed under a light.
  39673. */
  39674. diffuseColor: Color3;
  39675. /**
  39676. * Define how the color and intensity of the highlight given by the light in the material.
  39677. */
  39678. specularColor: Color3;
  39679. /**
  39680. * Define the color of the material as if self lit.
  39681. * This will be mixed in the final result even in the absence of light.
  39682. */
  39683. emissiveColor: Color3;
  39684. /**
  39685. * Defines how sharp are the highlights in the material.
  39686. * The bigger the value the sharper giving a more glossy feeling to the result.
  39687. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39688. */
  39689. specularPower: number;
  39690. private _useAlphaFromDiffuseTexture;
  39691. /**
  39692. * Does the transparency come from the diffuse texture alpha channel.
  39693. */
  39694. useAlphaFromDiffuseTexture: boolean;
  39695. private _useEmissiveAsIllumination;
  39696. /**
  39697. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39698. */
  39699. useEmissiveAsIllumination: boolean;
  39700. private _linkEmissiveWithDiffuse;
  39701. /**
  39702. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39703. * the emissive level when the final color is close to one.
  39704. */
  39705. linkEmissiveWithDiffuse: boolean;
  39706. private _useSpecularOverAlpha;
  39707. /**
  39708. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39709. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39710. */
  39711. useSpecularOverAlpha: boolean;
  39712. private _useReflectionOverAlpha;
  39713. /**
  39714. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39715. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39716. */
  39717. useReflectionOverAlpha: boolean;
  39718. private _disableLighting;
  39719. /**
  39720. * Does lights from the scene impacts this material.
  39721. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39722. */
  39723. disableLighting: boolean;
  39724. private _useObjectSpaceNormalMap;
  39725. /**
  39726. * Allows using an object space normal map (instead of tangent space).
  39727. */
  39728. useObjectSpaceNormalMap: boolean;
  39729. private _useParallax;
  39730. /**
  39731. * Is parallax enabled or not.
  39732. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39733. */
  39734. useParallax: boolean;
  39735. private _useParallaxOcclusion;
  39736. /**
  39737. * Is parallax occlusion enabled or not.
  39738. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39739. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39740. */
  39741. useParallaxOcclusion: boolean;
  39742. /**
  39743. * 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.
  39744. */
  39745. parallaxScaleBias: number;
  39746. private _roughness;
  39747. /**
  39748. * Helps to define how blurry the reflections should appears in the material.
  39749. */
  39750. roughness: number;
  39751. /**
  39752. * In case of refraction, define the value of the indice of refraction.
  39753. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39754. */
  39755. indexOfRefraction: number;
  39756. /**
  39757. * Invert the refraction texture alongside the y axis.
  39758. * It can be useful with procedural textures or probe for instance.
  39759. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39760. */
  39761. invertRefractionY: boolean;
  39762. /**
  39763. * Defines the alpha limits in alpha test mode.
  39764. */
  39765. alphaCutOff: number;
  39766. private _useLightmapAsShadowmap;
  39767. /**
  39768. * In case of light mapping, define whether the map contains light or shadow informations.
  39769. */
  39770. useLightmapAsShadowmap: boolean;
  39771. private _diffuseFresnelParameters;
  39772. /**
  39773. * Define the diffuse fresnel parameters of the material.
  39774. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39775. */
  39776. diffuseFresnelParameters: FresnelParameters;
  39777. private _opacityFresnelParameters;
  39778. /**
  39779. * Define the opacity fresnel parameters of the material.
  39780. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39781. */
  39782. opacityFresnelParameters: FresnelParameters;
  39783. private _reflectionFresnelParameters;
  39784. /**
  39785. * Define the reflection fresnel parameters of the material.
  39786. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39787. */
  39788. reflectionFresnelParameters: FresnelParameters;
  39789. private _refractionFresnelParameters;
  39790. /**
  39791. * Define the refraction fresnel parameters of the material.
  39792. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39793. */
  39794. refractionFresnelParameters: FresnelParameters;
  39795. private _emissiveFresnelParameters;
  39796. /**
  39797. * Define the emissive fresnel parameters of the material.
  39798. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39799. */
  39800. emissiveFresnelParameters: FresnelParameters;
  39801. private _useReflectionFresnelFromSpecular;
  39802. /**
  39803. * If true automatically deducts the fresnels values from the material specularity.
  39804. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39805. */
  39806. useReflectionFresnelFromSpecular: boolean;
  39807. private _useGlossinessFromSpecularMapAlpha;
  39808. /**
  39809. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39810. */
  39811. useGlossinessFromSpecularMapAlpha: boolean;
  39812. private _maxSimultaneousLights;
  39813. /**
  39814. * Defines the maximum number of lights that can be used in the material
  39815. */
  39816. maxSimultaneousLights: number;
  39817. private _invertNormalMapX;
  39818. /**
  39819. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39820. */
  39821. invertNormalMapX: boolean;
  39822. private _invertNormalMapY;
  39823. /**
  39824. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39825. */
  39826. invertNormalMapY: boolean;
  39827. private _twoSidedLighting;
  39828. /**
  39829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39830. */
  39831. twoSidedLighting: boolean;
  39832. /**
  39833. * Default configuration related to image processing available in the standard Material.
  39834. */
  39835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39836. /**
  39837. * Gets the image processing configuration used either in this material.
  39838. */
  39839. /**
  39840. * Sets the Default image processing configuration used either in the this material.
  39841. *
  39842. * If sets to null, the scene one is in use.
  39843. */
  39844. imageProcessingConfiguration: ImageProcessingConfiguration;
  39845. /**
  39846. * Keep track of the image processing observer to allow dispose and replace.
  39847. */
  39848. private _imageProcessingObserver;
  39849. /**
  39850. * Attaches a new image processing configuration to the Standard Material.
  39851. * @param configuration
  39852. */
  39853. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39854. /**
  39855. * Gets wether the color curves effect is enabled.
  39856. */
  39857. /**
  39858. * Sets wether the color curves effect is enabled.
  39859. */
  39860. cameraColorCurvesEnabled: boolean;
  39861. /**
  39862. * Gets wether the color grading effect is enabled.
  39863. */
  39864. /**
  39865. * Gets wether the color grading effect is enabled.
  39866. */
  39867. cameraColorGradingEnabled: boolean;
  39868. /**
  39869. * Gets wether tonemapping is enabled or not.
  39870. */
  39871. /**
  39872. * Sets wether tonemapping is enabled or not
  39873. */
  39874. cameraToneMappingEnabled: boolean;
  39875. /**
  39876. * The camera exposure used on this material.
  39877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39878. * This corresponds to a photographic exposure.
  39879. */
  39880. /**
  39881. * The camera exposure used on this material.
  39882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39883. * This corresponds to a photographic exposure.
  39884. */
  39885. cameraExposure: number;
  39886. /**
  39887. * Gets The camera contrast used on this material.
  39888. */
  39889. /**
  39890. * Sets The camera contrast used on this material.
  39891. */
  39892. cameraContrast: number;
  39893. /**
  39894. * Gets the Color Grading 2D Lookup Texture.
  39895. */
  39896. /**
  39897. * Sets the Color Grading 2D Lookup Texture.
  39898. */
  39899. cameraColorGradingTexture: Nullable<BaseTexture>;
  39900. /**
  39901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39903. * 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;
  39904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39905. */
  39906. /**
  39907. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39908. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39909. * 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;
  39910. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39911. */
  39912. cameraColorCurves: Nullable<ColorCurves>;
  39913. /**
  39914. * Custom callback helping to override the default shader used in the material.
  39915. */
  39916. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39917. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39918. protected _worldViewProjectionMatrix: Matrix;
  39919. protected _globalAmbientColor: Color3;
  39920. protected _useLogarithmicDepth: boolean;
  39921. /**
  39922. * Instantiates a new standard material.
  39923. * This is the default material used in Babylon. It is the best trade off between quality
  39924. * and performances.
  39925. * @see http://doc.babylonjs.com/babylon101/materials
  39926. * @param name Define the name of the material in the scene
  39927. * @param scene Define the scene the material belong to
  39928. */
  39929. constructor(name: string, scene: Scene);
  39930. /**
  39931. * Gets a boolean indicating that current material needs to register RTT
  39932. */
  39933. readonly hasRenderTargetTextures: boolean;
  39934. /**
  39935. * Gets the current class name of the material e.g. "StandardMaterial"
  39936. * Mainly use in serialization.
  39937. * @returns the class name
  39938. */
  39939. getClassName(): string;
  39940. /**
  39941. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39942. * You can try switching to logarithmic depth.
  39943. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39944. */
  39945. useLogarithmicDepth: boolean;
  39946. /**
  39947. * Specifies if the material will require alpha blending
  39948. * @returns a boolean specifying if alpha blending is needed
  39949. */
  39950. needAlphaBlending(): boolean;
  39951. /**
  39952. * Specifies if this material should be rendered in alpha test mode
  39953. * @returns a boolean specifying if an alpha test is needed.
  39954. */
  39955. needAlphaTesting(): boolean;
  39956. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39957. /**
  39958. * Get the texture used for alpha test purpose.
  39959. * @returns the diffuse texture in case of the standard material.
  39960. */
  39961. getAlphaTestTexture(): Nullable<BaseTexture>;
  39962. /**
  39963. * Get if the submesh is ready to be used and all its information available.
  39964. * Child classes can use it to update shaders
  39965. * @param mesh defines the mesh to check
  39966. * @param subMesh defines which submesh to check
  39967. * @param useInstances specifies that instances should be used
  39968. * @returns a boolean indicating that the submesh is ready or not
  39969. */
  39970. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39971. /**
  39972. * Builds the material UBO layouts.
  39973. * Used internally during the effect preparation.
  39974. */
  39975. buildUniformLayout(): void;
  39976. /**
  39977. * Unbinds the material from the mesh
  39978. */
  39979. unbind(): void;
  39980. /**
  39981. * Binds the submesh to this material by preparing the effect and shader to draw
  39982. * @param world defines the world transformation matrix
  39983. * @param mesh defines the mesh containing the submesh
  39984. * @param subMesh defines the submesh to bind the material to
  39985. */
  39986. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39987. /**
  39988. * Get the list of animatables in the material.
  39989. * @returns the list of animatables object used in the material
  39990. */
  39991. getAnimatables(): IAnimatable[];
  39992. /**
  39993. * Gets the active textures from the material
  39994. * @returns an array of textures
  39995. */
  39996. getActiveTextures(): BaseTexture[];
  39997. /**
  39998. * Specifies if the material uses a texture
  39999. * @param texture defines the texture to check against the material
  40000. * @returns a boolean specifying if the material uses the texture
  40001. */
  40002. hasTexture(texture: BaseTexture): boolean;
  40003. /**
  40004. * Disposes the material
  40005. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40006. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40007. */
  40008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40009. /**
  40010. * Makes a duplicate of the material, and gives it a new name
  40011. * @param name defines the new name for the duplicated material
  40012. * @returns the cloned material
  40013. */
  40014. clone(name: string): StandardMaterial;
  40015. /**
  40016. * Serializes this material in a JSON representation
  40017. * @returns the serialized material object
  40018. */
  40019. serialize(): any;
  40020. /**
  40021. * Creates a standard material from parsed material data
  40022. * @param source defines the JSON representation of the material
  40023. * @param scene defines the hosting scene
  40024. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40025. * @returns a new standard material
  40026. */
  40027. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40028. /**
  40029. * Are diffuse textures enabled in the application.
  40030. */
  40031. static DiffuseTextureEnabled: boolean;
  40032. /**
  40033. * Are ambient textures enabled in the application.
  40034. */
  40035. static AmbientTextureEnabled: boolean;
  40036. /**
  40037. * Are opacity textures enabled in the application.
  40038. */
  40039. static OpacityTextureEnabled: boolean;
  40040. /**
  40041. * Are reflection textures enabled in the application.
  40042. */
  40043. static ReflectionTextureEnabled: boolean;
  40044. /**
  40045. * Are emissive textures enabled in the application.
  40046. */
  40047. static EmissiveTextureEnabled: boolean;
  40048. /**
  40049. * Are specular textures enabled in the application.
  40050. */
  40051. static SpecularTextureEnabled: boolean;
  40052. /**
  40053. * Are bump textures enabled in the application.
  40054. */
  40055. static BumpTextureEnabled: boolean;
  40056. /**
  40057. * Are lightmap textures enabled in the application.
  40058. */
  40059. static LightmapTextureEnabled: boolean;
  40060. /**
  40061. * Are refraction textures enabled in the application.
  40062. */
  40063. static RefractionTextureEnabled: boolean;
  40064. /**
  40065. * Are color grading textures enabled in the application.
  40066. */
  40067. static ColorGradingTextureEnabled: boolean;
  40068. /**
  40069. * Are fresnels enabled in the application.
  40070. */
  40071. static FresnelEnabled: boolean;
  40072. }
  40073. }
  40074. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40075. import { Scene } from "babylonjs/scene";
  40076. import { Texture } from "babylonjs/Materials/Textures/texture";
  40077. /**
  40078. * A class extending Texture allowing drawing on a texture
  40079. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40080. */
  40081. export class DynamicTexture extends Texture {
  40082. private _generateMipMaps;
  40083. private _canvas;
  40084. private _context;
  40085. private _engine;
  40086. /**
  40087. * Creates a DynamicTexture
  40088. * @param name defines the name of the texture
  40089. * @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
  40090. * @param scene defines the scene where you want the texture
  40091. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40092. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40093. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40094. */
  40095. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40096. /**
  40097. * Get the current class name of the texture useful for serialization or dynamic coding.
  40098. * @returns "DynamicTexture"
  40099. */
  40100. getClassName(): string;
  40101. /**
  40102. * Gets the current state of canRescale
  40103. */
  40104. readonly canRescale: boolean;
  40105. private _recreate;
  40106. /**
  40107. * Scales the texture
  40108. * @param ratio the scale factor to apply to both width and height
  40109. */
  40110. scale(ratio: number): void;
  40111. /**
  40112. * Resizes the texture
  40113. * @param width the new width
  40114. * @param height the new height
  40115. */
  40116. scaleTo(width: number, height: number): void;
  40117. /**
  40118. * Gets the context of the canvas used by the texture
  40119. * @returns the canvas context of the dynamic texture
  40120. */
  40121. getContext(): CanvasRenderingContext2D;
  40122. /**
  40123. * Clears the texture
  40124. */
  40125. clear(): void;
  40126. /**
  40127. * Updates the texture
  40128. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40129. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40130. */
  40131. update(invertY?: boolean, premulAlpha?: boolean): void;
  40132. /**
  40133. * Draws text onto the texture
  40134. * @param text defines the text to be drawn
  40135. * @param x defines the placement of the text from the left
  40136. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40137. * @param font defines the font to be used with font-style, font-size, font-name
  40138. * @param color defines the color used for the text
  40139. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40140. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40141. * @param update defines whether texture is immediately update (default is true)
  40142. */
  40143. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40144. /**
  40145. * Clones the texture
  40146. * @returns the clone of the texture.
  40147. */
  40148. clone(): DynamicTexture;
  40149. /**
  40150. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40151. * @returns a serialized dynamic texture object
  40152. */
  40153. serialize(): any;
  40154. /** @hidden */
  40155. _rebuild(): void;
  40156. }
  40157. }
  40158. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40159. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40160. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40161. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40162. /** @hidden */
  40163. export var imageProcessingPixelShader: {
  40164. name: string;
  40165. shader: string;
  40166. };
  40167. }
  40168. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40169. import { Nullable } from "babylonjs/types";
  40170. import { Color4 } from "babylonjs/Maths/math";
  40171. import { Camera } from "babylonjs/Cameras/camera";
  40172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40173. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40174. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40175. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40176. import { Engine } from "babylonjs/Engines/engine";
  40177. import "babylonjs/Shaders/imageProcessing.fragment";
  40178. import "babylonjs/Shaders/postprocess.vertex";
  40179. /**
  40180. * ImageProcessingPostProcess
  40181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40182. */
  40183. export class ImageProcessingPostProcess extends PostProcess {
  40184. /**
  40185. * Default configuration related to image processing available in the PBR Material.
  40186. */
  40187. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40188. /**
  40189. * Gets the image processing configuration used either in this material.
  40190. */
  40191. /**
  40192. * Sets the Default image processing configuration used either in the this material.
  40193. *
  40194. * If sets to null, the scene one is in use.
  40195. */
  40196. imageProcessingConfiguration: ImageProcessingConfiguration;
  40197. /**
  40198. * Keep track of the image processing observer to allow dispose and replace.
  40199. */
  40200. private _imageProcessingObserver;
  40201. /**
  40202. * Attaches a new image processing configuration to the PBR Material.
  40203. * @param configuration
  40204. */
  40205. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40206. /**
  40207. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40208. */
  40209. /**
  40210. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40211. */
  40212. colorCurves: Nullable<ColorCurves>;
  40213. /**
  40214. * Gets wether the color curves effect is enabled.
  40215. */
  40216. /**
  40217. * Sets wether the color curves effect is enabled.
  40218. */
  40219. colorCurvesEnabled: boolean;
  40220. /**
  40221. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40222. */
  40223. /**
  40224. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40225. */
  40226. colorGradingTexture: Nullable<BaseTexture>;
  40227. /**
  40228. * Gets wether the color grading effect is enabled.
  40229. */
  40230. /**
  40231. * Gets wether the color grading effect is enabled.
  40232. */
  40233. colorGradingEnabled: boolean;
  40234. /**
  40235. * Gets exposure used in the effect.
  40236. */
  40237. /**
  40238. * Sets exposure used in the effect.
  40239. */
  40240. exposure: number;
  40241. /**
  40242. * Gets wether tonemapping is enabled or not.
  40243. */
  40244. /**
  40245. * Sets wether tonemapping is enabled or not
  40246. */
  40247. toneMappingEnabled: boolean;
  40248. /**
  40249. * Gets the type of tone mapping effect.
  40250. */
  40251. /**
  40252. * Sets the type of tone mapping effect.
  40253. */
  40254. toneMappingType: number;
  40255. /**
  40256. * Gets contrast used in the effect.
  40257. */
  40258. /**
  40259. * Sets contrast used in the effect.
  40260. */
  40261. contrast: number;
  40262. /**
  40263. * Gets Vignette stretch size.
  40264. */
  40265. /**
  40266. * Sets Vignette stretch size.
  40267. */
  40268. vignetteStretch: number;
  40269. /**
  40270. * Gets Vignette centre X Offset.
  40271. */
  40272. /**
  40273. * Sets Vignette centre X Offset.
  40274. */
  40275. vignetteCentreX: number;
  40276. /**
  40277. * Gets Vignette centre Y Offset.
  40278. */
  40279. /**
  40280. * Sets Vignette centre Y Offset.
  40281. */
  40282. vignetteCentreY: number;
  40283. /**
  40284. * Gets Vignette weight or intensity of the vignette effect.
  40285. */
  40286. /**
  40287. * Sets Vignette weight or intensity of the vignette effect.
  40288. */
  40289. vignetteWeight: number;
  40290. /**
  40291. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40292. * if vignetteEnabled is set to true.
  40293. */
  40294. /**
  40295. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40296. * if vignetteEnabled is set to true.
  40297. */
  40298. vignetteColor: Color4;
  40299. /**
  40300. * Gets Camera field of view used by the Vignette effect.
  40301. */
  40302. /**
  40303. * Sets Camera field of view used by the Vignette effect.
  40304. */
  40305. vignetteCameraFov: number;
  40306. /**
  40307. * Gets the vignette blend mode allowing different kind of effect.
  40308. */
  40309. /**
  40310. * Sets the vignette blend mode allowing different kind of effect.
  40311. */
  40312. vignetteBlendMode: number;
  40313. /**
  40314. * Gets wether the vignette effect is enabled.
  40315. */
  40316. /**
  40317. * Sets wether the vignette effect is enabled.
  40318. */
  40319. vignetteEnabled: boolean;
  40320. private _fromLinearSpace;
  40321. /**
  40322. * Gets wether the input of the processing is in Gamma or Linear Space.
  40323. */
  40324. /**
  40325. * Sets wether the input of the processing is in Gamma or Linear Space.
  40326. */
  40327. fromLinearSpace: boolean;
  40328. /**
  40329. * Defines cache preventing GC.
  40330. */
  40331. private _defines;
  40332. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40333. /**
  40334. * "ImageProcessingPostProcess"
  40335. * @returns "ImageProcessingPostProcess"
  40336. */
  40337. getClassName(): string;
  40338. protected _updateParameters(): void;
  40339. dispose(camera?: Camera): void;
  40340. }
  40341. }
  40342. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40343. import { Scene } from "babylonjs/scene";
  40344. import { Color3 } from "babylonjs/Maths/math";
  40345. import { Mesh } from "babylonjs/Meshes/mesh";
  40346. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40347. /**
  40348. * Class containing static functions to help procedurally build meshes
  40349. */
  40350. export class GroundBuilder {
  40351. /**
  40352. * Creates a ground mesh
  40353. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40354. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40356. * @param name defines the name of the mesh
  40357. * @param options defines the options used to create the mesh
  40358. * @param scene defines the hosting scene
  40359. * @returns the ground mesh
  40360. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40361. */
  40362. static CreateGround(name: string, options: {
  40363. width?: number;
  40364. height?: number;
  40365. subdivisions?: number;
  40366. subdivisionsX?: number;
  40367. subdivisionsY?: number;
  40368. updatable?: boolean;
  40369. }, scene: any): Mesh;
  40370. /**
  40371. * Creates a tiled ground mesh
  40372. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40373. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40374. * * 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
  40375. * * 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
  40376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40377. * @param name defines the name of the mesh
  40378. * @param options defines the options used to create the mesh
  40379. * @param scene defines the hosting scene
  40380. * @returns the tiled ground mesh
  40381. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40382. */
  40383. static CreateTiledGround(name: string, options: {
  40384. xmin: number;
  40385. zmin: number;
  40386. xmax: number;
  40387. zmax: number;
  40388. subdivisions?: {
  40389. w: number;
  40390. h: number;
  40391. };
  40392. precision?: {
  40393. w: number;
  40394. h: number;
  40395. };
  40396. updatable?: boolean;
  40397. }, scene: Scene): Mesh;
  40398. /**
  40399. * Creates a ground mesh from a height map
  40400. * * The parameter `url` sets the URL of the height map image resource.
  40401. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40402. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40403. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40404. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40405. * * 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.
  40406. * * 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).
  40407. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40409. * @param name defines the name of the mesh
  40410. * @param url defines the url to the height map
  40411. * @param options defines the options used to create the mesh
  40412. * @param scene defines the hosting scene
  40413. * @returns the ground mesh
  40414. * @see https://doc.babylonjs.com/babylon101/height_map
  40415. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40416. */
  40417. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40418. width?: number;
  40419. height?: number;
  40420. subdivisions?: number;
  40421. minHeight?: number;
  40422. maxHeight?: number;
  40423. colorFilter?: Color3;
  40424. alphaFilter?: number;
  40425. updatable?: boolean;
  40426. onReady?: (mesh: GroundMesh) => void;
  40427. }, scene: Scene): GroundMesh;
  40428. }
  40429. }
  40430. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40431. import { Vector4 } from "babylonjs/Maths/math";
  40432. import { Mesh } from "babylonjs/Meshes/mesh";
  40433. /**
  40434. * Class containing static functions to help procedurally build meshes
  40435. */
  40436. export class TorusBuilder {
  40437. /**
  40438. * Creates a torus mesh
  40439. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40440. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40441. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40445. * @param name defines the name of the mesh
  40446. * @param options defines the options used to create the mesh
  40447. * @param scene defines the hosting scene
  40448. * @returns the torus mesh
  40449. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40450. */
  40451. static CreateTorus(name: string, options: {
  40452. diameter?: number;
  40453. thickness?: number;
  40454. tessellation?: number;
  40455. updatable?: boolean;
  40456. sideOrientation?: number;
  40457. frontUVs?: Vector4;
  40458. backUVs?: Vector4;
  40459. }, scene: any): Mesh;
  40460. }
  40461. }
  40462. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40463. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40464. import { Mesh } from "babylonjs/Meshes/mesh";
  40465. /**
  40466. * Class containing static functions to help procedurally build meshes
  40467. */
  40468. export class CylinderBuilder {
  40469. /**
  40470. * Creates a cylinder or a cone mesh
  40471. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40472. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40473. * * 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.
  40474. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40475. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40476. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40477. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40478. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40479. * * 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).
  40480. * * 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
  40481. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40482. * * 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
  40483. * * 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.
  40484. * * If `enclose` is false, a ring surface is one element.
  40485. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40486. * * 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
  40487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40490. * @param name defines the name of the mesh
  40491. * @param options defines the options used to create the mesh
  40492. * @param scene defines the hosting scene
  40493. * @returns the cylinder mesh
  40494. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40495. */
  40496. static CreateCylinder(name: string, options: {
  40497. height?: number;
  40498. diameterTop?: number;
  40499. diameterBottom?: number;
  40500. diameter?: number;
  40501. tessellation?: number;
  40502. subdivisions?: number;
  40503. arc?: number;
  40504. faceColors?: Color4[];
  40505. faceUV?: Vector4[];
  40506. updatable?: boolean;
  40507. hasRings?: boolean;
  40508. enclose?: boolean;
  40509. sideOrientation?: number;
  40510. frontUVs?: Vector4;
  40511. backUVs?: Vector4;
  40512. }, scene: any): Mesh;
  40513. }
  40514. }
  40515. declare module "babylonjs/Gamepads/gamepadManager" {
  40516. import { Observable } from "babylonjs/Misc/observable";
  40517. import { Nullable } from "babylonjs/types";
  40518. import { Scene } from "babylonjs/scene";
  40519. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40520. /**
  40521. * Manager for handling gamepads
  40522. */
  40523. export class GamepadManager {
  40524. private _scene?;
  40525. private _babylonGamepads;
  40526. private _oneGamepadConnected;
  40527. /** @hidden */
  40528. _isMonitoring: boolean;
  40529. private _gamepadEventSupported;
  40530. private _gamepadSupport;
  40531. /**
  40532. * observable to be triggered when the gamepad controller has been connected
  40533. */
  40534. onGamepadConnectedObservable: Observable<Gamepad>;
  40535. /**
  40536. * observable to be triggered when the gamepad controller has been disconnected
  40537. */
  40538. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40539. private _onGamepadConnectedEvent;
  40540. private _onGamepadDisconnectedEvent;
  40541. /**
  40542. * Initializes the gamepad manager
  40543. * @param _scene BabylonJS scene
  40544. */
  40545. constructor(_scene?: Scene | undefined);
  40546. /**
  40547. * The gamepads in the game pad manager
  40548. */
  40549. readonly gamepads: Gamepad[];
  40550. /**
  40551. * Get the gamepad controllers based on type
  40552. * @param type The type of gamepad controller
  40553. * @returns Nullable gamepad
  40554. */
  40555. getGamepadByType(type?: number): Nullable<Gamepad>;
  40556. /**
  40557. * Disposes the gamepad manager
  40558. */
  40559. dispose(): void;
  40560. private _addNewGamepad;
  40561. private _startMonitoringGamepads;
  40562. private _stopMonitoringGamepads;
  40563. /** @hidden */
  40564. _checkGamepadsStatus(): void;
  40565. private _updateGamepadObjects;
  40566. }
  40567. }
  40568. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40569. import { Nullable } from "babylonjs/types";
  40570. import { Scene } from "babylonjs/scene";
  40571. import { ISceneComponent } from "babylonjs/sceneComponent";
  40572. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40573. module "babylonjs/scene" {
  40574. interface Scene {
  40575. /** @hidden */
  40576. _gamepadManager: Nullable<GamepadManager>;
  40577. /**
  40578. * Gets the gamepad manager associated with the scene
  40579. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40580. */
  40581. gamepadManager: GamepadManager;
  40582. }
  40583. }
  40584. module "babylonjs/Cameras/freeCameraInputsManager" {
  40585. /**
  40586. * Interface representing a free camera inputs manager
  40587. */
  40588. interface FreeCameraInputsManager {
  40589. /**
  40590. * Adds gamepad input support to the FreeCameraInputsManager.
  40591. * @returns the FreeCameraInputsManager
  40592. */
  40593. addGamepad(): FreeCameraInputsManager;
  40594. }
  40595. }
  40596. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40597. /**
  40598. * Interface representing an arc rotate camera inputs manager
  40599. */
  40600. interface ArcRotateCameraInputsManager {
  40601. /**
  40602. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40603. * @returns the camera inputs manager
  40604. */
  40605. addGamepad(): ArcRotateCameraInputsManager;
  40606. }
  40607. }
  40608. /**
  40609. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40610. */
  40611. export class GamepadSystemSceneComponent implements ISceneComponent {
  40612. /**
  40613. * The component name helpfull to identify the component in the list of scene components.
  40614. */
  40615. readonly name: string;
  40616. /**
  40617. * The scene the component belongs to.
  40618. */
  40619. scene: Scene;
  40620. /**
  40621. * Creates a new instance of the component for the given scene
  40622. * @param scene Defines the scene to register the component in
  40623. */
  40624. constructor(scene: Scene);
  40625. /**
  40626. * Registers the component in a given scene
  40627. */
  40628. register(): void;
  40629. /**
  40630. * Rebuilds the elements related to this component in case of
  40631. * context lost for instance.
  40632. */
  40633. rebuild(): void;
  40634. /**
  40635. * Disposes the component and the associated ressources
  40636. */
  40637. dispose(): void;
  40638. private _beforeCameraUpdate;
  40639. }
  40640. }
  40641. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40642. import { Observable } from "babylonjs/Misc/observable";
  40643. import { Nullable } from "babylonjs/types";
  40644. import { Camera } from "babylonjs/Cameras/camera";
  40645. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40646. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40647. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40648. import { Scene } from "babylonjs/scene";
  40649. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40650. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40652. import { Mesh } from "babylonjs/Meshes/mesh";
  40653. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40654. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40655. import "babylonjs/Meshes/Builders/groundBuilder";
  40656. import "babylonjs/Meshes/Builders/torusBuilder";
  40657. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40658. import "babylonjs/Gamepads/gamepadSceneComponent";
  40659. import "babylonjs/Animations/animatable";
  40660. /**
  40661. * Options to modify the vr teleportation behavior.
  40662. */
  40663. export interface VRTeleportationOptions {
  40664. /**
  40665. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40666. */
  40667. floorMeshName?: string;
  40668. /**
  40669. * A list of meshes to be used as the teleportation floor. (default: empty)
  40670. */
  40671. floorMeshes?: Mesh[];
  40672. }
  40673. /**
  40674. * Options to modify the vr experience helper's behavior.
  40675. */
  40676. export interface VRExperienceHelperOptions extends WebVROptions {
  40677. /**
  40678. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40679. */
  40680. createDeviceOrientationCamera?: boolean;
  40681. /**
  40682. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40683. */
  40684. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40685. /**
  40686. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40687. */
  40688. laserToggle?: boolean;
  40689. /**
  40690. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40691. */
  40692. floorMeshes?: Mesh[];
  40693. /**
  40694. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40695. */
  40696. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40697. }
  40698. /**
  40699. * Event containing information after VR has been entered
  40700. */
  40701. export class OnAfterEnteringVRObservableEvent {
  40702. /**
  40703. * If entering vr was successful
  40704. */
  40705. success: boolean;
  40706. }
  40707. /**
  40708. * Helps to quickly add VR support to an existing scene.
  40709. * See http://doc.babylonjs.com/how_to/webvr_helper
  40710. */
  40711. export class VRExperienceHelper {
  40712. /** Options to modify the vr experience helper's behavior. */
  40713. webVROptions: VRExperienceHelperOptions;
  40714. private _scene;
  40715. private _position;
  40716. private _btnVR;
  40717. private _btnVRDisplayed;
  40718. private _webVRsupported;
  40719. private _webVRready;
  40720. private _webVRrequesting;
  40721. private _webVRpresenting;
  40722. private _hasEnteredVR;
  40723. private _fullscreenVRpresenting;
  40724. private _canvas;
  40725. private _webVRCamera;
  40726. private _vrDeviceOrientationCamera;
  40727. private _deviceOrientationCamera;
  40728. private _existingCamera;
  40729. private _onKeyDown;
  40730. private _onVrDisplayPresentChange;
  40731. private _onVRDisplayChanged;
  40732. private _onVRRequestPresentStart;
  40733. private _onVRRequestPresentComplete;
  40734. /**
  40735. * Observable raised right before entering VR.
  40736. */
  40737. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40738. /**
  40739. * Observable raised when entering VR has completed.
  40740. */
  40741. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40742. /**
  40743. * Observable raised when exiting VR.
  40744. */
  40745. onExitingVRObservable: Observable<VRExperienceHelper>;
  40746. /**
  40747. * Observable raised when controller mesh is loaded.
  40748. */
  40749. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40750. /** Return this.onEnteringVRObservable
  40751. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40752. */
  40753. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40754. /** Return this.onExitingVRObservable
  40755. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40756. */
  40757. readonly onExitingVR: Observable<VRExperienceHelper>;
  40758. /** Return this.onControllerMeshLoadedObservable
  40759. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40760. */
  40761. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40762. private _rayLength;
  40763. private _useCustomVRButton;
  40764. private _teleportationRequested;
  40765. private _teleportActive;
  40766. private _floorMeshName;
  40767. private _floorMeshesCollection;
  40768. private _rotationAllowed;
  40769. private _teleportBackwardsVector;
  40770. private _teleportationTarget;
  40771. private _isDefaultTeleportationTarget;
  40772. private _postProcessMove;
  40773. private _teleportationFillColor;
  40774. private _teleportationBorderColor;
  40775. private _rotationAngle;
  40776. private _haloCenter;
  40777. private _cameraGazer;
  40778. private _padSensibilityUp;
  40779. private _padSensibilityDown;
  40780. private _leftController;
  40781. private _rightController;
  40782. /**
  40783. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40784. */
  40785. onNewMeshSelected: Observable<AbstractMesh>;
  40786. /**
  40787. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40788. */
  40789. onNewMeshPicked: Observable<PickingInfo>;
  40790. private _circleEase;
  40791. /**
  40792. * Observable raised before camera teleportation
  40793. */
  40794. onBeforeCameraTeleport: Observable<Vector3>;
  40795. /**
  40796. * Observable raised after camera teleportation
  40797. */
  40798. onAfterCameraTeleport: Observable<Vector3>;
  40799. /**
  40800. * Observable raised when current selected mesh gets unselected
  40801. */
  40802. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40803. private _raySelectionPredicate;
  40804. /**
  40805. * To be optionaly changed by user to define custom ray selection
  40806. */
  40807. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40808. /**
  40809. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40810. */
  40811. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40812. /**
  40813. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40814. */
  40815. teleportationEnabled: boolean;
  40816. private _defaultHeight;
  40817. private _teleportationInitialized;
  40818. private _interactionsEnabled;
  40819. private _interactionsRequested;
  40820. private _displayGaze;
  40821. private _displayLaserPointer;
  40822. /**
  40823. * The mesh used to display where the user is going to teleport.
  40824. */
  40825. /**
  40826. * Sets the mesh to be used to display where the user is going to teleport.
  40827. */
  40828. teleportationTarget: Mesh;
  40829. /**
  40830. * 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
  40831. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40832. * See http://doc.babylonjs.com/resources/baking_transformations
  40833. */
  40834. gazeTrackerMesh: Mesh;
  40835. /**
  40836. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40837. */
  40838. updateGazeTrackerScale: boolean;
  40839. /**
  40840. * If the gaze trackers color should be updated when selecting meshes
  40841. */
  40842. updateGazeTrackerColor: boolean;
  40843. /**
  40844. * The gaze tracking mesh corresponding to the left controller
  40845. */
  40846. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40847. /**
  40848. * The gaze tracking mesh corresponding to the right controller
  40849. */
  40850. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40851. /**
  40852. * If the ray of the gaze should be displayed.
  40853. */
  40854. /**
  40855. * Sets if the ray of the gaze should be displayed.
  40856. */
  40857. displayGaze: boolean;
  40858. /**
  40859. * If the ray of the LaserPointer should be displayed.
  40860. */
  40861. /**
  40862. * Sets if the ray of the LaserPointer should be displayed.
  40863. */
  40864. displayLaserPointer: boolean;
  40865. /**
  40866. * The deviceOrientationCamera used as the camera when not in VR.
  40867. */
  40868. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40869. /**
  40870. * Based on the current WebVR support, returns the current VR camera used.
  40871. */
  40872. readonly currentVRCamera: Nullable<Camera>;
  40873. /**
  40874. * The webVRCamera which is used when in VR.
  40875. */
  40876. readonly webVRCamera: WebVRFreeCamera;
  40877. /**
  40878. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40879. */
  40880. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40881. private readonly _teleportationRequestInitiated;
  40882. /**
  40883. * Defines wether or not Pointer lock should be requested when switching to
  40884. * full screen.
  40885. */
  40886. requestPointerLockOnFullScreen: boolean;
  40887. /**
  40888. * Instantiates a VRExperienceHelper.
  40889. * Helps to quickly add VR support to an existing scene.
  40890. * @param scene The scene the VRExperienceHelper belongs to.
  40891. * @param webVROptions Options to modify the vr experience helper's behavior.
  40892. */
  40893. constructor(scene: Scene,
  40894. /** Options to modify the vr experience helper's behavior. */
  40895. webVROptions?: VRExperienceHelperOptions);
  40896. private _onDefaultMeshLoaded;
  40897. private _onResize;
  40898. private _onFullscreenChange;
  40899. /**
  40900. * Gets a value indicating if we are currently in VR mode.
  40901. */
  40902. readonly isInVRMode: boolean;
  40903. private onVrDisplayPresentChange;
  40904. private onVRDisplayChanged;
  40905. private moveButtonToBottomRight;
  40906. private displayVRButton;
  40907. private updateButtonVisibility;
  40908. private _cachedAngularSensibility;
  40909. /**
  40910. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40911. * Otherwise, will use the fullscreen API.
  40912. */
  40913. enterVR(): void;
  40914. /**
  40915. * Attempt to exit VR, or fullscreen.
  40916. */
  40917. exitVR(): void;
  40918. /**
  40919. * The position of the vr experience helper.
  40920. */
  40921. /**
  40922. * Sets the position of the vr experience helper.
  40923. */
  40924. position: Vector3;
  40925. /**
  40926. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40927. */
  40928. enableInteractions(): void;
  40929. private readonly _noControllerIsActive;
  40930. private beforeRender;
  40931. private _isTeleportationFloor;
  40932. /**
  40933. * Adds a floor mesh to be used for teleportation.
  40934. * @param floorMesh the mesh to be used for teleportation.
  40935. */
  40936. addFloorMesh(floorMesh: Mesh): void;
  40937. /**
  40938. * Removes a floor mesh from being used for teleportation.
  40939. * @param floorMesh the mesh to be removed.
  40940. */
  40941. removeFloorMesh(floorMesh: Mesh): void;
  40942. /**
  40943. * Enables interactions and teleportation using the VR controllers and gaze.
  40944. * @param vrTeleportationOptions options to modify teleportation behavior.
  40945. */
  40946. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40947. private _onNewGamepadConnected;
  40948. private _tryEnableInteractionOnController;
  40949. private _onNewGamepadDisconnected;
  40950. private _enableInteractionOnController;
  40951. private _checkTeleportWithRay;
  40952. private _checkRotate;
  40953. private _checkTeleportBackwards;
  40954. private _enableTeleportationOnController;
  40955. private _createTeleportationCircles;
  40956. private _displayTeleportationTarget;
  40957. private _hideTeleportationTarget;
  40958. private _rotateCamera;
  40959. private _moveTeleportationSelectorTo;
  40960. private _workingVector;
  40961. private _workingQuaternion;
  40962. private _workingMatrix;
  40963. /**
  40964. * Teleports the users feet to the desired location
  40965. * @param location The location where the user's feet should be placed
  40966. */
  40967. teleportCamera(location: Vector3): void;
  40968. private _convertNormalToDirectionOfRay;
  40969. private _castRayAndSelectObject;
  40970. private _notifySelectedMeshUnselected;
  40971. /**
  40972. * Sets the color of the laser ray from the vr controllers.
  40973. * @param color new color for the ray.
  40974. */
  40975. changeLaserColor(color: Color3): void;
  40976. /**
  40977. * Sets the color of the ray from the vr headsets gaze.
  40978. * @param color new color for the ray.
  40979. */
  40980. changeGazeColor(color: Color3): void;
  40981. /**
  40982. * Exits VR and disposes of the vr experience helper
  40983. */
  40984. dispose(): void;
  40985. /**
  40986. * Gets the name of the VRExperienceHelper class
  40987. * @returns "VRExperienceHelper"
  40988. */
  40989. getClassName(): string;
  40990. }
  40991. }
  40992. declare module "babylonjs/Cameras/VR/index" {
  40993. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40994. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40995. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40996. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40997. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40998. export * from "babylonjs/Cameras/VR/webVRCamera";
  40999. }
  41000. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41001. import { Observable } from "babylonjs/Misc/observable";
  41002. import { Nullable } from "babylonjs/types";
  41003. import { IDisposable, Scene } from "babylonjs/scene";
  41004. import { Vector3 } from "babylonjs/Maths/math";
  41005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41006. import { Ray } from "babylonjs/Culling/ray";
  41007. /**
  41008. * Manages an XRSession
  41009. * @see https://doc.babylonjs.com/how_to/webxr
  41010. */
  41011. export class WebXRSessionManager implements IDisposable {
  41012. private scene;
  41013. /**
  41014. * Fires every time a new xrFrame arrives which can be used to update the camera
  41015. */
  41016. onXRFrameObservable: Observable<any>;
  41017. /**
  41018. * Fires when the xr session is ended either by the device or manually done
  41019. */
  41020. onXRSessionEnded: Observable<any>;
  41021. /** @hidden */
  41022. _xrSession: XRSession;
  41023. /** @hidden */
  41024. _frameOfReference: XRFrameOfReference;
  41025. /** @hidden */
  41026. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41027. /** @hidden */
  41028. _currentXRFrame: Nullable<XRFrame>;
  41029. private _xrNavigator;
  41030. private _xrDevice;
  41031. private _tmpMatrix;
  41032. /**
  41033. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41034. * @param scene The scene which the session should be created for
  41035. */
  41036. constructor(scene: Scene);
  41037. /**
  41038. * Initializes the manager
  41039. * After initialization enterXR can be called to start an XR session
  41040. * @returns Promise which resolves after it is initialized
  41041. */
  41042. initializeAsync(): Promise<void>;
  41043. /**
  41044. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41045. * @param sessionCreationOptions xr options to create the session with
  41046. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41047. * @returns Promise which resolves after it enters XR
  41048. */
  41049. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41050. /**
  41051. * Stops the xrSession and restores the renderloop
  41052. * @returns Promise which resolves after it exits XR
  41053. */
  41054. exitXRAsync(): Promise<void>;
  41055. /**
  41056. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41057. * @param ray ray to cast into the environment
  41058. * @returns Promise which resolves with a collision point in the environment if it exists
  41059. */
  41060. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41061. /**
  41062. * Checks if a session would be supported for the creation options specified
  41063. * @param options creation options to check if they are supported
  41064. * @returns true if supported
  41065. */
  41066. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41067. /**
  41068. * @hidden
  41069. * Converts the render layer of xrSession to a render target
  41070. * @param session session to create render target for
  41071. * @param scene scene the new render target should be created for
  41072. */
  41073. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41074. /**
  41075. * Disposes of the session manager
  41076. */
  41077. dispose(): void;
  41078. }
  41079. }
  41080. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41081. import { Scene } from "babylonjs/scene";
  41082. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41083. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41084. /**
  41085. * WebXR Camera which holds the views for the xrSession
  41086. * @see https://doc.babylonjs.com/how_to/webxr
  41087. */
  41088. export class WebXRCamera extends FreeCamera {
  41089. private static _TmpMatrix;
  41090. /**
  41091. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41092. * @param name the name of the camera
  41093. * @param scene the scene to add the camera to
  41094. */
  41095. constructor(name: string, scene: Scene);
  41096. private _updateNumberOfRigCameras;
  41097. /** @hidden */
  41098. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41099. /**
  41100. * Updates the cameras position from the current pose information of the XR session
  41101. * @param xrSessionManager the session containing pose information
  41102. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41103. */
  41104. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41105. }
  41106. }
  41107. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41108. import { Nullable } from "babylonjs/types";
  41109. import { Observable } from "babylonjs/Misc/observable";
  41110. import { IDisposable, Scene } from "babylonjs/scene";
  41111. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41113. import { Ray } from "babylonjs/Culling/ray";
  41114. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41115. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41116. /**
  41117. * States of the webXR experience
  41118. */
  41119. export enum WebXRState {
  41120. /**
  41121. * Transitioning to being in XR mode
  41122. */
  41123. ENTERING_XR = 0,
  41124. /**
  41125. * Transitioning to non XR mode
  41126. */
  41127. EXITING_XR = 1,
  41128. /**
  41129. * In XR mode and presenting
  41130. */
  41131. IN_XR = 2,
  41132. /**
  41133. * Not entered XR mode
  41134. */
  41135. NOT_IN_XR = 3
  41136. }
  41137. /**
  41138. * Helper class used to enable XR
  41139. * @see https://doc.babylonjs.com/how_to/webxr
  41140. */
  41141. export class WebXRExperienceHelper implements IDisposable {
  41142. private scene;
  41143. /**
  41144. * 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
  41145. */
  41146. container: AbstractMesh;
  41147. /**
  41148. * Camera used to render xr content
  41149. */
  41150. camera: WebXRCamera;
  41151. /**
  41152. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41153. */
  41154. state: WebXRState;
  41155. private _setState;
  41156. private static _TmpVector;
  41157. /**
  41158. * Fires when the state of the experience helper has changed
  41159. */
  41160. onStateChangedObservable: Observable<WebXRState>;
  41161. /** @hidden */
  41162. _sessionManager: WebXRSessionManager;
  41163. private _nonVRCamera;
  41164. private _originalSceneAutoClear;
  41165. private _supported;
  41166. /**
  41167. * Creates the experience helper
  41168. * @param scene the scene to attach the experience helper to
  41169. * @returns a promise for the experience helper
  41170. */
  41171. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41172. /**
  41173. * Creates a WebXRExperienceHelper
  41174. * @param scene The scene the helper should be created in
  41175. */
  41176. private constructor();
  41177. /**
  41178. * Exits XR mode and returns the scene to its original state
  41179. * @returns promise that resolves after xr mode has exited
  41180. */
  41181. exitXRAsync(): Promise<void>;
  41182. /**
  41183. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41184. * @param sessionCreationOptions options for the XR session
  41185. * @param frameOfReference frame of reference of the XR session
  41186. * @returns promise that resolves after xr mode has entered
  41187. */
  41188. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41189. /**
  41190. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41191. * @param ray ray to cast into the environment
  41192. * @returns Promise which resolves with a collision point in the environment if it exists
  41193. */
  41194. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41195. /**
  41196. * Updates the global position of the camera by moving the camera's container
  41197. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41198. * @param position The desired global position of the camera
  41199. */
  41200. setPositionOfCameraUsingContainer(position: Vector3): void;
  41201. /**
  41202. * Rotates the xr camera by rotating the camera's container around the camera's position
  41203. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41204. * @param rotation the desired quaternion rotation to apply to the camera
  41205. */
  41206. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41207. /**
  41208. * Checks if the creation options are supported by the xr session
  41209. * @param options creation options
  41210. * @returns true if supported
  41211. */
  41212. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41213. /**
  41214. * Disposes of the experience helper
  41215. */
  41216. dispose(): void;
  41217. }
  41218. }
  41219. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41220. import { Nullable } from "babylonjs/types";
  41221. import { Observable } from "babylonjs/Misc/observable";
  41222. import { IDisposable, Scene } from "babylonjs/scene";
  41223. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41224. /**
  41225. * Button which can be used to enter a different mode of XR
  41226. */
  41227. export class WebXREnterExitUIButton {
  41228. /** button element */
  41229. element: HTMLElement;
  41230. /** XR initialization options for the button */
  41231. initializationOptions: XRSessionCreationOptions;
  41232. /**
  41233. * Creates a WebXREnterExitUIButton
  41234. * @param element button element
  41235. * @param initializationOptions XR initialization options for the button
  41236. */
  41237. constructor(
  41238. /** button element */
  41239. element: HTMLElement,
  41240. /** XR initialization options for the button */
  41241. initializationOptions: XRSessionCreationOptions);
  41242. /**
  41243. * Overwritable function which can be used to update the button's visuals when the state changes
  41244. * @param activeButton the current active button in the UI
  41245. */
  41246. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41247. }
  41248. /**
  41249. * Options to create the webXR UI
  41250. */
  41251. export class WebXREnterExitUIOptions {
  41252. /**
  41253. * Context to enter xr with
  41254. */
  41255. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41256. /**
  41257. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41258. */
  41259. customButtons?: Array<WebXREnterExitUIButton>;
  41260. }
  41261. /**
  41262. * UI to allow the user to enter/exit XR mode
  41263. */
  41264. export class WebXREnterExitUI implements IDisposable {
  41265. private scene;
  41266. private _overlay;
  41267. private _buttons;
  41268. private _activeButton;
  41269. /**
  41270. * Fired every time the active button is changed.
  41271. *
  41272. * When xr is entered via a button that launches xr that button will be the callback parameter
  41273. *
  41274. * When exiting xr the callback parameter will be null)
  41275. */
  41276. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41277. /**
  41278. * Creates UI to allow the user to enter/exit XR mode
  41279. * @param scene the scene to add the ui to
  41280. * @param helper the xr experience helper to enter/exit xr with
  41281. * @param options options to configure the UI
  41282. * @returns the created ui
  41283. */
  41284. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41285. private constructor();
  41286. private _updateButtons;
  41287. /**
  41288. * Disposes of the object
  41289. */
  41290. dispose(): void;
  41291. }
  41292. }
  41293. declare module "babylonjs/Cameras/XR/webXRInput" {
  41294. import { IDisposable, Scene } from "babylonjs/scene";
  41295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41296. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41297. /**
  41298. * Represents an XR input
  41299. */
  41300. export class WebXRController {
  41301. /**
  41302. * 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
  41303. */
  41304. grip?: AbstractMesh;
  41305. /**
  41306. * Pointer which can be used to select objects or attach a visible laser to
  41307. */
  41308. pointer: AbstractMesh;
  41309. /**
  41310. * Creates the controller
  41311. * @see https://doc.babylonjs.com/how_to/webxr
  41312. * @param scene the scene which the controller should be associated to
  41313. */
  41314. constructor(scene: Scene);
  41315. /**
  41316. * Disposes of the object
  41317. */
  41318. dispose(): void;
  41319. }
  41320. /**
  41321. * XR input used to track XR inputs such as controllers/rays
  41322. */
  41323. export class WebXRInput implements IDisposable {
  41324. private helper;
  41325. /**
  41326. * XR controllers being tracked
  41327. */
  41328. controllers: Array<WebXRController>;
  41329. private _tmpMatrix;
  41330. private _frameObserver;
  41331. /**
  41332. * Initializes the WebXRInput
  41333. * @param helper experience helper which the input should be created for
  41334. */
  41335. constructor(helper: WebXRExperienceHelper);
  41336. /**
  41337. * Disposes of the object
  41338. */
  41339. dispose(): void;
  41340. }
  41341. }
  41342. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41343. import { Nullable } from "babylonjs/types";
  41344. import { IDisposable } from "babylonjs/scene";
  41345. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41346. /**
  41347. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41348. */
  41349. export class WebXRManagedOutputCanvas implements IDisposable {
  41350. private _canvas;
  41351. /**
  41352. * xrpresent context of the canvas which can be used to display/mirror xr content
  41353. */
  41354. canvasContext: Nullable<WebGLRenderingContext>;
  41355. /**
  41356. * Initializes the canvas to be added/removed upon entering/exiting xr
  41357. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41358. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41359. */
  41360. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41361. /**
  41362. * Disposes of the object
  41363. */
  41364. dispose(): void;
  41365. private _setManagedOutputCanvas;
  41366. private _addCanvas;
  41367. private _removeCanvas;
  41368. }
  41369. }
  41370. declare module "babylonjs/Cameras/XR/index" {
  41371. export * from "babylonjs/Cameras/XR/webXRCamera";
  41372. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41373. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41374. export * from "babylonjs/Cameras/XR/webXRInput";
  41375. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41376. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41377. }
  41378. declare module "babylonjs/Cameras/RigModes/index" {
  41379. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41380. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41381. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41382. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41383. }
  41384. declare module "babylonjs/Cameras/index" {
  41385. export * from "babylonjs/Cameras/Inputs/index";
  41386. export * from "babylonjs/Cameras/cameraInputsManager";
  41387. export * from "babylonjs/Cameras/camera";
  41388. export * from "babylonjs/Cameras/targetCamera";
  41389. export * from "babylonjs/Cameras/freeCamera";
  41390. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41391. export * from "babylonjs/Cameras/touchCamera";
  41392. export * from "babylonjs/Cameras/arcRotateCamera";
  41393. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41394. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41395. export * from "babylonjs/Cameras/flyCamera";
  41396. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41397. export * from "babylonjs/Cameras/followCamera";
  41398. export * from "babylonjs/Cameras/gamepadCamera";
  41399. export * from "babylonjs/Cameras/Stereoscopic/index";
  41400. export * from "babylonjs/Cameras/universalCamera";
  41401. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41402. export * from "babylonjs/Cameras/VR/index";
  41403. export * from "babylonjs/Cameras/XR/index";
  41404. export * from "babylonjs/Cameras/RigModes/index";
  41405. }
  41406. declare module "babylonjs/Collisions/index" {
  41407. export * from "babylonjs/Collisions/collider";
  41408. export * from "babylonjs/Collisions/collisionCoordinator";
  41409. export * from "babylonjs/Collisions/pickingInfo";
  41410. export * from "babylonjs/Collisions/intersectionInfo";
  41411. }
  41412. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41413. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41414. import { Vector3, Plane } from "babylonjs/Maths/math";
  41415. import { Ray } from "babylonjs/Culling/ray";
  41416. /**
  41417. * Contains an array of blocks representing the octree
  41418. */
  41419. export interface IOctreeContainer<T> {
  41420. /**
  41421. * Blocks within the octree
  41422. */
  41423. blocks: Array<OctreeBlock<T>>;
  41424. }
  41425. /**
  41426. * Class used to store a cell in an octree
  41427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41428. */
  41429. export class OctreeBlock<T> {
  41430. /**
  41431. * Gets the content of the current block
  41432. */
  41433. entries: T[];
  41434. /**
  41435. * Gets the list of block children
  41436. */
  41437. blocks: Array<OctreeBlock<T>>;
  41438. private _depth;
  41439. private _maxDepth;
  41440. private _capacity;
  41441. private _minPoint;
  41442. private _maxPoint;
  41443. private _boundingVectors;
  41444. private _creationFunc;
  41445. /**
  41446. * Creates a new block
  41447. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41448. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41449. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41450. * @param depth defines the current depth of this block in the octree
  41451. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41452. * @param creationFunc defines a callback to call when an element is added to the block
  41453. */
  41454. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41455. /**
  41456. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41457. */
  41458. readonly capacity: number;
  41459. /**
  41460. * Gets the minimum vector (in world space) of the block's bounding box
  41461. */
  41462. readonly minPoint: Vector3;
  41463. /**
  41464. * Gets the maximum vector (in world space) of the block's bounding box
  41465. */
  41466. readonly maxPoint: Vector3;
  41467. /**
  41468. * Add a new element to this block
  41469. * @param entry defines the element to add
  41470. */
  41471. addEntry(entry: T): void;
  41472. /**
  41473. * Remove an element from this block
  41474. * @param entry defines the element to remove
  41475. */
  41476. removeEntry(entry: T): void;
  41477. /**
  41478. * Add an array of elements to this block
  41479. * @param entries defines the array of elements to add
  41480. */
  41481. addEntries(entries: T[]): void;
  41482. /**
  41483. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41484. * @param frustumPlanes defines the frustum planes to test
  41485. * @param selection defines the array to store current content if selection is positive
  41486. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41487. */
  41488. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41489. /**
  41490. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41491. * @param sphereCenter defines the bounding sphere center
  41492. * @param sphereRadius defines the bounding sphere radius
  41493. * @param selection defines the array to store current content if selection is positive
  41494. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41495. */
  41496. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41497. /**
  41498. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41499. * @param ray defines the ray to test with
  41500. * @param selection defines the array to store current content if selection is positive
  41501. */
  41502. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41503. /**
  41504. * Subdivide the content into child blocks (this block will then be empty)
  41505. */
  41506. createInnerBlocks(): void;
  41507. /**
  41508. * @hidden
  41509. */
  41510. 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;
  41511. }
  41512. }
  41513. declare module "babylonjs/Culling/Octrees/octree" {
  41514. import { SmartArray } from "babylonjs/Misc/smartArray";
  41515. import { Vector3, Plane } from "babylonjs/Maths/math";
  41516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41518. import { Ray } from "babylonjs/Culling/ray";
  41519. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41520. /**
  41521. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41522. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41523. */
  41524. export class Octree<T> {
  41525. /** 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.) */
  41526. maxDepth: number;
  41527. /**
  41528. * Blocks within the octree containing objects
  41529. */
  41530. blocks: Array<OctreeBlock<T>>;
  41531. /**
  41532. * Content stored in the octree
  41533. */
  41534. dynamicContent: T[];
  41535. private _maxBlockCapacity;
  41536. private _selectionContent;
  41537. private _creationFunc;
  41538. /**
  41539. * Creates a octree
  41540. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41541. * @param creationFunc function to be used to instatiate the octree
  41542. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41543. * @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.)
  41544. */
  41545. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41546. /** 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.) */
  41547. maxDepth?: number);
  41548. /**
  41549. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41550. * @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);
  41551. * @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);
  41552. * @param entries meshes to be added to the octree blocks
  41553. */
  41554. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41555. /**
  41556. * Adds a mesh to the octree
  41557. * @param entry Mesh to add to the octree
  41558. */
  41559. addMesh(entry: T): void;
  41560. /**
  41561. * Remove an element from the octree
  41562. * @param entry defines the element to remove
  41563. */
  41564. removeMesh(entry: T): void;
  41565. /**
  41566. * Selects an array of meshes within the frustum
  41567. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41568. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41569. * @returns array of meshes within the frustum
  41570. */
  41571. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41572. /**
  41573. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41574. * @param sphereCenter defines the bounding sphere center
  41575. * @param sphereRadius defines the bounding sphere radius
  41576. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41577. * @returns an array of objects that intersect the sphere
  41578. */
  41579. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41580. /**
  41581. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41582. * @param ray defines the ray to test with
  41583. * @returns array of intersected objects
  41584. */
  41585. intersectsRay(ray: Ray): SmartArray<T>;
  41586. /**
  41587. * Adds a mesh into the octree block if it intersects the block
  41588. */
  41589. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41590. /**
  41591. * Adds a submesh into the octree block if it intersects the block
  41592. */
  41593. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41594. }
  41595. }
  41596. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41597. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41598. import { Scene } from "babylonjs/scene";
  41599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41601. import { Ray } from "babylonjs/Culling/ray";
  41602. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41603. import { Collider } from "babylonjs/Collisions/collider";
  41604. module "babylonjs/scene" {
  41605. interface Scene {
  41606. /**
  41607. * @hidden
  41608. * Backing Filed
  41609. */
  41610. _selectionOctree: Octree<AbstractMesh>;
  41611. /**
  41612. * Gets the octree used to boost mesh selection (picking)
  41613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41614. */
  41615. selectionOctree: Octree<AbstractMesh>;
  41616. /**
  41617. * Creates or updates the octree used to boost selection (picking)
  41618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41619. * @param maxCapacity defines the maximum capacity per leaf
  41620. * @param maxDepth defines the maximum depth of the octree
  41621. * @returns an octree of AbstractMesh
  41622. */
  41623. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41624. }
  41625. }
  41626. module "babylonjs/Meshes/abstractMesh" {
  41627. interface AbstractMesh {
  41628. /**
  41629. * @hidden
  41630. * Backing Field
  41631. */
  41632. _submeshesOctree: Octree<SubMesh>;
  41633. /**
  41634. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41635. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41636. * @param maxCapacity defines the maximum size of each block (64 by default)
  41637. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41638. * @returns the new octree
  41639. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41641. */
  41642. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41643. }
  41644. }
  41645. /**
  41646. * Defines the octree scene component responsible to manage any octrees
  41647. * in a given scene.
  41648. */
  41649. export class OctreeSceneComponent {
  41650. /**
  41651. * The component name helpfull to identify the component in the list of scene components.
  41652. */
  41653. readonly name: string;
  41654. /**
  41655. * The scene the component belongs to.
  41656. */
  41657. scene: Scene;
  41658. /**
  41659. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41660. */
  41661. readonly checksIsEnabled: boolean;
  41662. /**
  41663. * Creates a new instance of the component for the given scene
  41664. * @param scene Defines the scene to register the component in
  41665. */
  41666. constructor(scene: Scene);
  41667. /**
  41668. * Registers the component in a given scene
  41669. */
  41670. register(): void;
  41671. /**
  41672. * Return the list of active meshes
  41673. * @returns the list of active meshes
  41674. */
  41675. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41676. /**
  41677. * Return the list of active sub meshes
  41678. * @param mesh The mesh to get the candidates sub meshes from
  41679. * @returns the list of active sub meshes
  41680. */
  41681. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41682. private _tempRay;
  41683. /**
  41684. * Return the list of sub meshes intersecting with a given local ray
  41685. * @param mesh defines the mesh to find the submesh for
  41686. * @param localRay defines the ray in local space
  41687. * @returns the list of intersecting sub meshes
  41688. */
  41689. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41690. /**
  41691. * Return the list of sub meshes colliding with a collider
  41692. * @param mesh defines the mesh to find the submesh for
  41693. * @param collider defines the collider to evaluate the collision against
  41694. * @returns the list of colliding sub meshes
  41695. */
  41696. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41697. /**
  41698. * Rebuilds the elements related to this component in case of
  41699. * context lost for instance.
  41700. */
  41701. rebuild(): void;
  41702. /**
  41703. * Disposes the component and the associated ressources.
  41704. */
  41705. dispose(): void;
  41706. }
  41707. }
  41708. declare module "babylonjs/Culling/Octrees/index" {
  41709. export * from "babylonjs/Culling/Octrees/octree";
  41710. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41711. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41712. }
  41713. declare module "babylonjs/Culling/index" {
  41714. export * from "babylonjs/Culling/boundingBox";
  41715. export * from "babylonjs/Culling/boundingInfo";
  41716. export * from "babylonjs/Culling/boundingSphere";
  41717. export * from "babylonjs/Culling/Octrees/index";
  41718. export * from "babylonjs/Culling/ray";
  41719. }
  41720. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41721. import { IDisposable, Scene } from "babylonjs/scene";
  41722. import { Nullable } from "babylonjs/types";
  41723. import { Observable } from "babylonjs/Misc/observable";
  41724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41725. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41726. /**
  41727. * Renders a layer on top of an existing scene
  41728. */
  41729. export class UtilityLayerRenderer implements IDisposable {
  41730. /** the original scene that will be rendered on top of */
  41731. originalScene: Scene;
  41732. private _pointerCaptures;
  41733. private _lastPointerEvents;
  41734. private static _DefaultUtilityLayer;
  41735. private static _DefaultKeepDepthUtilityLayer;
  41736. private _sharedGizmoLight;
  41737. /**
  41738. * @hidden
  41739. * Light which used by gizmos to get light shading
  41740. */
  41741. _getSharedGizmoLight(): HemisphericLight;
  41742. /**
  41743. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41744. */
  41745. pickUtilitySceneFirst: boolean;
  41746. /**
  41747. * 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)
  41748. */
  41749. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41750. /**
  41751. * 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)
  41752. */
  41753. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41754. /**
  41755. * The scene that is rendered on top of the original scene
  41756. */
  41757. utilityLayerScene: Scene;
  41758. /**
  41759. * If the utility layer should automatically be rendered on top of existing scene
  41760. */
  41761. shouldRender: boolean;
  41762. /**
  41763. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41764. */
  41765. onlyCheckPointerDownEvents: boolean;
  41766. /**
  41767. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41768. */
  41769. processAllEvents: boolean;
  41770. /**
  41771. * Observable raised when the pointer move from the utility layer scene to the main scene
  41772. */
  41773. onPointerOutObservable: Observable<number>;
  41774. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41775. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41776. private _afterRenderObserver;
  41777. private _sceneDisposeObserver;
  41778. private _originalPointerObserver;
  41779. /**
  41780. * Instantiates a UtilityLayerRenderer
  41781. * @param originalScene the original scene that will be rendered on top of
  41782. * @param handleEvents boolean indicating if the utility layer should handle events
  41783. */
  41784. constructor(
  41785. /** the original scene that will be rendered on top of */
  41786. originalScene: Scene, handleEvents?: boolean);
  41787. private _notifyObservers;
  41788. /**
  41789. * Renders the utility layers scene on top of the original scene
  41790. */
  41791. render(): void;
  41792. /**
  41793. * Disposes of the renderer
  41794. */
  41795. dispose(): void;
  41796. private _updateCamera;
  41797. }
  41798. }
  41799. declare module "babylonjs/Gizmos/gizmo" {
  41800. import { Nullable } from "babylonjs/types";
  41801. import { IDisposable } from "babylonjs/scene";
  41802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41803. import { Mesh } from "babylonjs/Meshes/mesh";
  41804. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41805. /**
  41806. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41807. */
  41808. export class Gizmo implements IDisposable {
  41809. /** The utility layer the gizmo will be added to */
  41810. gizmoLayer: UtilityLayerRenderer;
  41811. /**
  41812. * The root mesh of the gizmo
  41813. */
  41814. _rootMesh: Mesh;
  41815. private _attachedMesh;
  41816. /**
  41817. * Ratio for the scale of the gizmo (Default: 1)
  41818. */
  41819. scaleRatio: number;
  41820. private _tmpMatrix;
  41821. /**
  41822. * If a custom mesh has been set (Default: false)
  41823. */
  41824. protected _customMeshSet: boolean;
  41825. /**
  41826. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41827. * * When set, interactions will be enabled
  41828. */
  41829. attachedMesh: Nullable<AbstractMesh>;
  41830. /**
  41831. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41832. * @param mesh The mesh to replace the default mesh of the gizmo
  41833. */
  41834. setCustomMesh(mesh: Mesh): void;
  41835. /**
  41836. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41837. */
  41838. updateGizmoRotationToMatchAttachedMesh: boolean;
  41839. /**
  41840. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41841. */
  41842. updateGizmoPositionToMatchAttachedMesh: boolean;
  41843. /**
  41844. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41845. */
  41846. protected _updateScale: boolean;
  41847. protected _interactionsEnabled: boolean;
  41848. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41849. private _beforeRenderObserver;
  41850. /**
  41851. * Creates a gizmo
  41852. * @param gizmoLayer The utility layer the gizmo will be added to
  41853. */
  41854. constructor(
  41855. /** The utility layer the gizmo will be added to */
  41856. gizmoLayer?: UtilityLayerRenderer);
  41857. private _tempVector;
  41858. /**
  41859. * @hidden
  41860. * Updates the gizmo to match the attached mesh's position/rotation
  41861. */
  41862. protected _update(): void;
  41863. /**
  41864. * Disposes of the gizmo
  41865. */
  41866. dispose(): void;
  41867. }
  41868. }
  41869. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41870. import { Observable } from "babylonjs/Misc/observable";
  41871. import { Nullable } from "babylonjs/types";
  41872. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41875. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41876. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41877. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41878. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41879. import { Scene } from "babylonjs/scene";
  41880. /**
  41881. * Single axis drag gizmo
  41882. */
  41883. export class AxisDragGizmo extends Gizmo {
  41884. /**
  41885. * Drag behavior responsible for the gizmos dragging interactions
  41886. */
  41887. dragBehavior: PointerDragBehavior;
  41888. private _pointerObserver;
  41889. /**
  41890. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41891. */
  41892. snapDistance: number;
  41893. /**
  41894. * Event that fires each time the gizmo snaps to a new location.
  41895. * * snapDistance is the the change in distance
  41896. */
  41897. onSnapObservable: Observable<{
  41898. snapDistance: number;
  41899. }>;
  41900. /** @hidden */
  41901. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41902. /** @hidden */
  41903. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41904. /**
  41905. * Creates an AxisDragGizmo
  41906. * @param gizmoLayer The utility layer the gizmo will be added to
  41907. * @param dragAxis The axis which the gizmo will be able to drag on
  41908. * @param color The color of the gizmo
  41909. */
  41910. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41911. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41912. /**
  41913. * Disposes of the gizmo
  41914. */
  41915. dispose(): void;
  41916. }
  41917. }
  41918. declare module "babylonjs/Debug/axesViewer" {
  41919. import { Vector3 } from "babylonjs/Maths/math";
  41920. import { Nullable } from "babylonjs/types";
  41921. import { Scene } from "babylonjs/scene";
  41922. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41923. /**
  41924. * The Axes viewer will show 3 axes in a specific point in space
  41925. */
  41926. export class AxesViewer {
  41927. private _xAxis;
  41928. private _yAxis;
  41929. private _zAxis;
  41930. private _scaleLinesFactor;
  41931. private _instanced;
  41932. /**
  41933. * Gets the hosting scene
  41934. */
  41935. scene: Scene;
  41936. /**
  41937. * Gets or sets a number used to scale line length
  41938. */
  41939. scaleLines: number;
  41940. /** Gets the node hierarchy used to render x-axis */
  41941. readonly xAxis: TransformNode;
  41942. /** Gets the node hierarchy used to render y-axis */
  41943. readonly yAxis: TransformNode;
  41944. /** Gets the node hierarchy used to render z-axis */
  41945. readonly zAxis: TransformNode;
  41946. /**
  41947. * Creates a new AxesViewer
  41948. * @param scene defines the hosting scene
  41949. * @param scaleLines defines a number used to scale line length (1 by default)
  41950. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41951. * @param xAxis defines the node hierarchy used to render the x-axis
  41952. * @param yAxis defines the node hierarchy used to render the y-axis
  41953. * @param zAxis defines the node hierarchy used to render the z-axis
  41954. */
  41955. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41956. /**
  41957. * Force the viewer to update
  41958. * @param position defines the position of the viewer
  41959. * @param xaxis defines the x axis of the viewer
  41960. * @param yaxis defines the y axis of the viewer
  41961. * @param zaxis defines the z axis of the viewer
  41962. */
  41963. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41964. /**
  41965. * Creates an instance of this axes viewer.
  41966. * @returns a new axes viewer with instanced meshes
  41967. */
  41968. createInstance(): AxesViewer;
  41969. /** Releases resources */
  41970. dispose(): void;
  41971. private static _SetRenderingGroupId;
  41972. }
  41973. }
  41974. declare module "babylonjs/Debug/boneAxesViewer" {
  41975. import { Nullable } from "babylonjs/types";
  41976. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41977. import { Vector3 } from "babylonjs/Maths/math";
  41978. import { Mesh } from "babylonjs/Meshes/mesh";
  41979. import { Bone } from "babylonjs/Bones/bone";
  41980. import { Scene } from "babylonjs/scene";
  41981. /**
  41982. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41983. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41984. */
  41985. export class BoneAxesViewer extends AxesViewer {
  41986. /**
  41987. * Gets or sets the target mesh where to display the axes viewer
  41988. */
  41989. mesh: Nullable<Mesh>;
  41990. /**
  41991. * Gets or sets the target bone where to display the axes viewer
  41992. */
  41993. bone: Nullable<Bone>;
  41994. /** Gets current position */
  41995. pos: Vector3;
  41996. /** Gets direction of X axis */
  41997. xaxis: Vector3;
  41998. /** Gets direction of Y axis */
  41999. yaxis: Vector3;
  42000. /** Gets direction of Z axis */
  42001. zaxis: Vector3;
  42002. /**
  42003. * Creates a new BoneAxesViewer
  42004. * @param scene defines the hosting scene
  42005. * @param bone defines the target bone
  42006. * @param mesh defines the target mesh
  42007. * @param scaleLines defines a scaling factor for line length (1 by default)
  42008. */
  42009. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42010. /**
  42011. * Force the viewer to update
  42012. */
  42013. update(): void;
  42014. /** Releases resources */
  42015. dispose(): void;
  42016. }
  42017. }
  42018. declare module "babylonjs/Debug/debugLayer" {
  42019. import { Observable } from "babylonjs/Misc/observable";
  42020. import { Scene } from "babylonjs/scene";
  42021. /**
  42022. * Interface used to define scene explorer extensibility option
  42023. */
  42024. export interface IExplorerExtensibilityOption {
  42025. /**
  42026. * Define the option label
  42027. */
  42028. label: string;
  42029. /**
  42030. * Defines the action to execute on click
  42031. */
  42032. action: (entity: any) => void;
  42033. }
  42034. /**
  42035. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42036. */
  42037. export interface IExplorerExtensibilityGroup {
  42038. /**
  42039. * Defines a predicate to test if a given type mut be extended
  42040. */
  42041. predicate: (entity: any) => boolean;
  42042. /**
  42043. * Gets the list of options added to a type
  42044. */
  42045. entries: IExplorerExtensibilityOption[];
  42046. }
  42047. /**
  42048. * Interface used to define the options to use to create the Inspector
  42049. */
  42050. export interface IInspectorOptions {
  42051. /**
  42052. * Display in overlay mode (default: false)
  42053. */
  42054. overlay?: boolean;
  42055. /**
  42056. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42057. */
  42058. globalRoot?: HTMLElement;
  42059. /**
  42060. * Display the Scene explorer
  42061. */
  42062. showExplorer?: boolean;
  42063. /**
  42064. * Display the property inspector
  42065. */
  42066. showInspector?: boolean;
  42067. /**
  42068. * Display in embed mode (both panes on the right)
  42069. */
  42070. embedMode?: boolean;
  42071. /**
  42072. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42073. */
  42074. handleResize?: boolean;
  42075. /**
  42076. * Allow the panes to popup (default: true)
  42077. */
  42078. enablePopup?: boolean;
  42079. /**
  42080. * Allow the panes to be closed by users (default: true)
  42081. */
  42082. enableClose?: boolean;
  42083. /**
  42084. * Optional list of extensibility entries
  42085. */
  42086. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42087. /**
  42088. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42089. */
  42090. inspectorURL?: string;
  42091. }
  42092. module "babylonjs/scene" {
  42093. interface Scene {
  42094. /**
  42095. * @hidden
  42096. * Backing field
  42097. */
  42098. _debugLayer: DebugLayer;
  42099. /**
  42100. * Gets the debug layer (aka Inspector) associated with the scene
  42101. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42102. */
  42103. debugLayer: DebugLayer;
  42104. }
  42105. }
  42106. /**
  42107. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42108. * what is happening in your scene
  42109. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42110. */
  42111. export class DebugLayer {
  42112. /**
  42113. * Define the url to get the inspector script from.
  42114. * By default it uses the babylonjs CDN.
  42115. * @ignoreNaming
  42116. */
  42117. static InspectorURL: string;
  42118. private _scene;
  42119. private BJSINSPECTOR;
  42120. /**
  42121. * Observable triggered when a property is changed through the inspector.
  42122. */
  42123. onPropertyChangedObservable: Observable<{
  42124. object: any;
  42125. property: string;
  42126. value: any;
  42127. initialValue: any;
  42128. }>;
  42129. /**
  42130. * Instantiates a new debug layer.
  42131. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42132. * what is happening in your scene
  42133. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42134. * @param scene Defines the scene to inspect
  42135. */
  42136. constructor(scene: Scene);
  42137. /** Creates the inspector window. */
  42138. private _createInspector;
  42139. /**
  42140. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42141. * @param entity defines the entity to select
  42142. * @param lineContainerTitle defines the specific block to highlight
  42143. */
  42144. select(entity: any, lineContainerTitle?: string): void;
  42145. /** Get the inspector from bundle or global */
  42146. private _getGlobalInspector;
  42147. /**
  42148. * Get if the inspector is visible or not.
  42149. * @returns true if visible otherwise, false
  42150. */
  42151. isVisible(): boolean;
  42152. /**
  42153. * Hide the inspector and close its window.
  42154. */
  42155. hide(): void;
  42156. /**
  42157. * Launch the debugLayer.
  42158. * @param config Define the configuration of the inspector
  42159. * @return a promise fulfilled when the debug layer is visible
  42160. */
  42161. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42162. }
  42163. }
  42164. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42165. import { Nullable } from "babylonjs/types";
  42166. import { Scene } from "babylonjs/scene";
  42167. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42168. import { Mesh } from "babylonjs/Meshes/mesh";
  42169. /**
  42170. * Class containing static functions to help procedurally build meshes
  42171. */
  42172. export class BoxBuilder {
  42173. /**
  42174. * Creates a box mesh
  42175. * * The parameter `size` sets the size (float) of each box side (default 1)
  42176. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42177. * * 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)
  42178. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42182. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42183. * @param name defines the name of the mesh
  42184. * @param options defines the options used to create the mesh
  42185. * @param scene defines the hosting scene
  42186. * @returns the box mesh
  42187. */
  42188. static CreateBox(name: string, options: {
  42189. size?: number;
  42190. width?: number;
  42191. height?: number;
  42192. depth?: number;
  42193. faceUV?: Vector4[];
  42194. faceColors?: Color4[];
  42195. sideOrientation?: number;
  42196. frontUVs?: Vector4;
  42197. backUVs?: Vector4;
  42198. updatable?: boolean;
  42199. }, scene?: Nullable<Scene>): Mesh;
  42200. }
  42201. }
  42202. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42203. import { Vector4 } from "babylonjs/Maths/math";
  42204. import { Mesh } from "babylonjs/Meshes/mesh";
  42205. /**
  42206. * Class containing static functions to help procedurally build meshes
  42207. */
  42208. export class SphereBuilder {
  42209. /**
  42210. * Creates a sphere mesh
  42211. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42212. * * 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`)
  42213. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42214. * * 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
  42215. * * 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)
  42216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42219. * @param name defines the name of the mesh
  42220. * @param options defines the options used to create the mesh
  42221. * @param scene defines the hosting scene
  42222. * @returns the sphere mesh
  42223. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42224. */
  42225. static CreateSphere(name: string, options: {
  42226. segments?: number;
  42227. diameter?: number;
  42228. diameterX?: number;
  42229. diameterY?: number;
  42230. diameterZ?: number;
  42231. arc?: number;
  42232. slice?: number;
  42233. sideOrientation?: number;
  42234. frontUVs?: Vector4;
  42235. backUVs?: Vector4;
  42236. updatable?: boolean;
  42237. }, scene: any): Mesh;
  42238. }
  42239. }
  42240. declare module "babylonjs/Debug/physicsViewer" {
  42241. import { Nullable } from "babylonjs/types";
  42242. import { Scene } from "babylonjs/scene";
  42243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42244. import { Mesh } from "babylonjs/Meshes/mesh";
  42245. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42246. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42247. /**
  42248. * Used to show the physics impostor around the specific mesh
  42249. */
  42250. export class PhysicsViewer {
  42251. /** @hidden */
  42252. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42253. /** @hidden */
  42254. protected _meshes: Array<Nullable<AbstractMesh>>;
  42255. /** @hidden */
  42256. protected _scene: Nullable<Scene>;
  42257. /** @hidden */
  42258. protected _numMeshes: number;
  42259. /** @hidden */
  42260. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42261. private _renderFunction;
  42262. private _utilityLayer;
  42263. private _debugBoxMesh;
  42264. private _debugSphereMesh;
  42265. private _debugMaterial;
  42266. private _debugMeshMeshes;
  42267. /**
  42268. * Creates a new PhysicsViewer
  42269. * @param scene defines the hosting scene
  42270. */
  42271. constructor(scene: Scene);
  42272. /** @hidden */
  42273. protected _updateDebugMeshes(): void;
  42274. /**
  42275. * Renders a specified physic impostor
  42276. * @param impostor defines the impostor to render
  42277. * @param targetMesh defines the mesh represented by the impostor
  42278. * @returns the new debug mesh used to render the impostor
  42279. */
  42280. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42281. /**
  42282. * Hides a specified physic impostor
  42283. * @param impostor defines the impostor to hide
  42284. */
  42285. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42286. private _getDebugMaterial;
  42287. private _getDebugBoxMesh;
  42288. private _getDebugSphereMesh;
  42289. private _getDebugMeshMesh;
  42290. private _getDebugMesh;
  42291. /** Releases all resources */
  42292. dispose(): void;
  42293. }
  42294. }
  42295. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42296. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42297. import { Nullable } from "babylonjs/types";
  42298. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42299. import { Scene } from "babylonjs/scene";
  42300. /**
  42301. * Class containing static functions to help procedurally build meshes
  42302. */
  42303. export class LinesBuilder {
  42304. /**
  42305. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42306. * * 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
  42307. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42308. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42309. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42310. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42311. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42312. * * 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
  42313. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42316. * @param name defines the name of the new line system
  42317. * @param options defines the options used to create the line system
  42318. * @param scene defines the hosting scene
  42319. * @returns a new line system mesh
  42320. */
  42321. static CreateLineSystem(name: string, options: {
  42322. lines: Vector3[][];
  42323. updatable?: boolean;
  42324. instance?: Nullable<LinesMesh>;
  42325. colors?: Nullable<Color4[][]>;
  42326. useVertexAlpha?: boolean;
  42327. }, scene: Nullable<Scene>): LinesMesh;
  42328. /**
  42329. * Creates a line mesh
  42330. * 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
  42331. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42332. * * The parameter `points` is an array successive Vector3
  42333. * * 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
  42334. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42335. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42336. * * When updating an instance, remember that only point positions can change, not the number of points
  42337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42339. * @param name defines the name of the new line system
  42340. * @param options defines the options used to create the line system
  42341. * @param scene defines the hosting scene
  42342. * @returns a new line mesh
  42343. */
  42344. static CreateLines(name: string, options: {
  42345. points: Vector3[];
  42346. updatable?: boolean;
  42347. instance?: Nullable<LinesMesh>;
  42348. colors?: Color4[];
  42349. useVertexAlpha?: boolean;
  42350. }, scene?: Nullable<Scene>): LinesMesh;
  42351. /**
  42352. * Creates a dashed line mesh
  42353. * * 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
  42354. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42355. * * The parameter `points` is an array successive Vector3
  42356. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42357. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42358. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42359. * * 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
  42360. * * When updating an instance, remember that only point positions can change, not the number of points
  42361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42362. * @param name defines the name of the mesh
  42363. * @param options defines the options used to create the mesh
  42364. * @param scene defines the hosting scene
  42365. * @returns the dashed line mesh
  42366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42367. */
  42368. static CreateDashedLines(name: string, options: {
  42369. points: Vector3[];
  42370. dashSize?: number;
  42371. gapSize?: number;
  42372. dashNb?: number;
  42373. updatable?: boolean;
  42374. instance?: LinesMesh;
  42375. }, scene?: Nullable<Scene>): LinesMesh;
  42376. }
  42377. }
  42378. declare module "babylonjs/Debug/rayHelper" {
  42379. import { Nullable } from "babylonjs/types";
  42380. import { Ray } from "babylonjs/Culling/ray";
  42381. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42382. import { Scene } from "babylonjs/scene";
  42383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42384. import "babylonjs/Meshes/Builders/linesBuilder";
  42385. /**
  42386. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42387. * in order to better appreciate the issue one might have.
  42388. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42389. */
  42390. export class RayHelper {
  42391. /**
  42392. * Defines the ray we are currently tryin to visualize.
  42393. */
  42394. ray: Nullable<Ray>;
  42395. private _renderPoints;
  42396. private _renderLine;
  42397. private _renderFunction;
  42398. private _scene;
  42399. private _updateToMeshFunction;
  42400. private _attachedToMesh;
  42401. private _meshSpaceDirection;
  42402. private _meshSpaceOrigin;
  42403. /**
  42404. * Helper function to create a colored helper in a scene in one line.
  42405. * @param ray Defines the ray we are currently tryin to visualize
  42406. * @param scene Defines the scene the ray is used in
  42407. * @param color Defines the color we want to see the ray in
  42408. * @returns The newly created ray helper.
  42409. */
  42410. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42411. /**
  42412. * Instantiate a new ray helper.
  42413. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42414. * in order to better appreciate the issue one might have.
  42415. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42416. * @param ray Defines the ray we are currently tryin to visualize
  42417. */
  42418. constructor(ray: Ray);
  42419. /**
  42420. * Shows the ray we are willing to debug.
  42421. * @param scene Defines the scene the ray needs to be rendered in
  42422. * @param color Defines the color the ray needs to be rendered in
  42423. */
  42424. show(scene: Scene, color?: Color3): void;
  42425. /**
  42426. * Hides the ray we are debugging.
  42427. */
  42428. hide(): void;
  42429. private _render;
  42430. /**
  42431. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42432. * @param mesh Defines the mesh we want the helper attached to
  42433. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42434. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42435. * @param length Defines the length of the ray
  42436. */
  42437. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42438. /**
  42439. * Detach the ray helper from the mesh it has previously been attached to.
  42440. */
  42441. detachFromMesh(): void;
  42442. private _updateToMesh;
  42443. /**
  42444. * Dispose the helper and release its associated resources.
  42445. */
  42446. dispose(): void;
  42447. }
  42448. }
  42449. declare module "babylonjs/Debug/skeletonViewer" {
  42450. import { Color3 } from "babylonjs/Maths/math";
  42451. import { Scene } from "babylonjs/scene";
  42452. import { Nullable } from "babylonjs/types";
  42453. import { Skeleton } from "babylonjs/Bones/skeleton";
  42454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42455. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42456. /**
  42457. * Class used to render a debug view of a given skeleton
  42458. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42459. */
  42460. export class SkeletonViewer {
  42461. /** defines the skeleton to render */
  42462. skeleton: Skeleton;
  42463. /** defines the mesh attached to the skeleton */
  42464. mesh: AbstractMesh;
  42465. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42466. autoUpdateBonesMatrices: boolean;
  42467. /** defines the rendering group id to use with the viewer */
  42468. renderingGroupId: number;
  42469. /** Gets or sets the color used to render the skeleton */
  42470. color: Color3;
  42471. private _scene;
  42472. private _debugLines;
  42473. private _debugMesh;
  42474. private _isEnabled;
  42475. private _renderFunction;
  42476. private _utilityLayer;
  42477. /**
  42478. * Returns the mesh used to render the bones
  42479. */
  42480. readonly debugMesh: Nullable<LinesMesh>;
  42481. /**
  42482. * Creates a new SkeletonViewer
  42483. * @param skeleton defines the skeleton to render
  42484. * @param mesh defines the mesh attached to the skeleton
  42485. * @param scene defines the hosting scene
  42486. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42487. * @param renderingGroupId defines the rendering group id to use with the viewer
  42488. */
  42489. constructor(
  42490. /** defines the skeleton to render */
  42491. skeleton: Skeleton,
  42492. /** defines the mesh attached to the skeleton */
  42493. mesh: AbstractMesh, scene: Scene,
  42494. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42495. autoUpdateBonesMatrices?: boolean,
  42496. /** defines the rendering group id to use with the viewer */
  42497. renderingGroupId?: number);
  42498. /** Gets or sets a boolean indicating if the viewer is enabled */
  42499. isEnabled: boolean;
  42500. private _getBonePosition;
  42501. private _getLinesForBonesWithLength;
  42502. private _getLinesForBonesNoLength;
  42503. /** Update the viewer to sync with current skeleton state */
  42504. update(): void;
  42505. /** Release associated resources */
  42506. dispose(): void;
  42507. }
  42508. }
  42509. declare module "babylonjs/Debug/index" {
  42510. export * from "babylonjs/Debug/axesViewer";
  42511. export * from "babylonjs/Debug/boneAxesViewer";
  42512. export * from "babylonjs/Debug/debugLayer";
  42513. export * from "babylonjs/Debug/physicsViewer";
  42514. export * from "babylonjs/Debug/rayHelper";
  42515. export * from "babylonjs/Debug/skeletonViewer";
  42516. }
  42517. declare module "babylonjs/Engines/nullEngine" {
  42518. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42519. import { Scene } from "babylonjs/scene";
  42520. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42521. import { Engine } from "babylonjs/Engines/engine";
  42522. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42523. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42525. import { Effect } from "babylonjs/Materials/effect";
  42526. /**
  42527. * Options to create the null engine
  42528. */
  42529. export class NullEngineOptions {
  42530. /**
  42531. * Render width (Default: 512)
  42532. */
  42533. renderWidth: number;
  42534. /**
  42535. * Render height (Default: 256)
  42536. */
  42537. renderHeight: number;
  42538. /**
  42539. * Texture size (Default: 512)
  42540. */
  42541. textureSize: number;
  42542. /**
  42543. * If delta time between frames should be constant
  42544. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42545. */
  42546. deterministicLockstep: boolean;
  42547. /**
  42548. * Maximum about of steps between frames (Default: 4)
  42549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42550. */
  42551. lockstepMaxSteps: number;
  42552. }
  42553. /**
  42554. * The null engine class provides support for headless version of babylon.js.
  42555. * This can be used in server side scenario or for testing purposes
  42556. */
  42557. export class NullEngine extends Engine {
  42558. private _options;
  42559. /**
  42560. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42561. */
  42562. isDeterministicLockStep(): boolean;
  42563. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42564. getLockstepMaxSteps(): number;
  42565. /**
  42566. * Sets hardware scaling, used to save performance if needed
  42567. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42568. */
  42569. getHardwareScalingLevel(): number;
  42570. constructor(options?: NullEngineOptions);
  42571. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42572. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42573. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42574. getRenderWidth(useScreen?: boolean): number;
  42575. getRenderHeight(useScreen?: boolean): number;
  42576. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42577. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42578. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42579. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42580. bindSamplers(effect: Effect): void;
  42581. enableEffect(effect: Effect): void;
  42582. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42583. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42584. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42585. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42586. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42587. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42588. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42589. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42590. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42591. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42592. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42593. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42594. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42595. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42596. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42597. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42598. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42599. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42600. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42601. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42602. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42603. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42604. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42605. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42606. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42607. bindBuffers(vertexBuffers: {
  42608. [key: string]: VertexBuffer;
  42609. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42610. wipeCaches(bruteForce?: boolean): void;
  42611. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42612. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42613. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42614. /** @hidden */
  42615. _createTexture(): WebGLTexture;
  42616. /** @hidden */
  42617. _releaseTexture(texture: InternalTexture): void;
  42618. 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;
  42619. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42620. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42621. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42622. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42623. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42624. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42625. areAllEffectsReady(): boolean;
  42626. /**
  42627. * @hidden
  42628. * Get the current error code of the webGL context
  42629. * @returns the error code
  42630. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42631. */
  42632. getError(): number;
  42633. /** @hidden */
  42634. _getUnpackAlignement(): number;
  42635. /** @hidden */
  42636. _unpackFlipY(value: boolean): void;
  42637. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42638. /**
  42639. * Updates a dynamic vertex buffer.
  42640. * @param vertexBuffer the vertex buffer to update
  42641. * @param data the data used to update the vertex buffer
  42642. * @param byteOffset the byte offset of the data (optional)
  42643. * @param byteLength the byte length of the data (optional)
  42644. */
  42645. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42646. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42647. /** @hidden */
  42648. _bindTexture(channel: number, texture: InternalTexture): void;
  42649. /** @hidden */
  42650. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42651. releaseEffects(): void;
  42652. displayLoadingUI(): void;
  42653. hideLoadingUI(): void;
  42654. /** @hidden */
  42655. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42656. /** @hidden */
  42657. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42658. /** @hidden */
  42659. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42660. /** @hidden */
  42661. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42662. }
  42663. }
  42664. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42665. import { Nullable, int } from "babylonjs/types";
  42666. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42667. /** @hidden */
  42668. export class _OcclusionDataStorage {
  42669. /** @hidden */
  42670. occlusionInternalRetryCounter: number;
  42671. /** @hidden */
  42672. isOcclusionQueryInProgress: boolean;
  42673. /** @hidden */
  42674. isOccluded: boolean;
  42675. /** @hidden */
  42676. occlusionRetryCount: number;
  42677. /** @hidden */
  42678. occlusionType: number;
  42679. /** @hidden */
  42680. occlusionQueryAlgorithmType: number;
  42681. }
  42682. module "babylonjs/Engines/engine" {
  42683. interface Engine {
  42684. /**
  42685. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42686. * @return the new query
  42687. */
  42688. createQuery(): WebGLQuery;
  42689. /**
  42690. * Delete and release a webGL query
  42691. * @param query defines the query to delete
  42692. * @return the current engine
  42693. */
  42694. deleteQuery(query: WebGLQuery): Engine;
  42695. /**
  42696. * Check if a given query has resolved and got its value
  42697. * @param query defines the query to check
  42698. * @returns true if the query got its value
  42699. */
  42700. isQueryResultAvailable(query: WebGLQuery): boolean;
  42701. /**
  42702. * Gets the value of a given query
  42703. * @param query defines the query to check
  42704. * @returns the value of the query
  42705. */
  42706. getQueryResult(query: WebGLQuery): number;
  42707. /**
  42708. * Initiates an occlusion query
  42709. * @param algorithmType defines the algorithm to use
  42710. * @param query defines the query to use
  42711. * @returns the current engine
  42712. * @see http://doc.babylonjs.com/features/occlusionquery
  42713. */
  42714. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42715. /**
  42716. * Ends an occlusion query
  42717. * @see http://doc.babylonjs.com/features/occlusionquery
  42718. * @param algorithmType defines the algorithm to use
  42719. * @returns the current engine
  42720. */
  42721. endOcclusionQuery(algorithmType: number): Engine;
  42722. /**
  42723. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42724. * Please note that only one query can be issued at a time
  42725. * @returns a time token used to track the time span
  42726. */
  42727. startTimeQuery(): Nullable<_TimeToken>;
  42728. /**
  42729. * Ends a time query
  42730. * @param token defines the token used to measure the time span
  42731. * @returns the time spent (in ns)
  42732. */
  42733. endTimeQuery(token: _TimeToken): int;
  42734. /** @hidden */
  42735. _currentNonTimestampToken: Nullable<_TimeToken>;
  42736. /** @hidden */
  42737. _createTimeQuery(): WebGLQuery;
  42738. /** @hidden */
  42739. _deleteTimeQuery(query: WebGLQuery): void;
  42740. /** @hidden */
  42741. _getGlAlgorithmType(algorithmType: number): number;
  42742. /** @hidden */
  42743. _getTimeQueryResult(query: WebGLQuery): any;
  42744. /** @hidden */
  42745. _getTimeQueryAvailability(query: WebGLQuery): any;
  42746. }
  42747. }
  42748. module "babylonjs/Meshes/abstractMesh" {
  42749. interface AbstractMesh {
  42750. /**
  42751. * Backing filed
  42752. * @hidden
  42753. */
  42754. __occlusionDataStorage: _OcclusionDataStorage;
  42755. /**
  42756. * Access property
  42757. * @hidden
  42758. */
  42759. _occlusionDataStorage: _OcclusionDataStorage;
  42760. /**
  42761. * 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.
  42762. * The default value is -1 which means don't break the query and wait till the result
  42763. * @see http://doc.babylonjs.com/features/occlusionquery
  42764. */
  42765. occlusionRetryCount: number;
  42766. /**
  42767. * 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:
  42768. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42769. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42770. * * 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.
  42771. * @see http://doc.babylonjs.com/features/occlusionquery
  42772. */
  42773. occlusionType: number;
  42774. /**
  42775. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42776. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42777. * * 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.
  42778. * @see http://doc.babylonjs.com/features/occlusionquery
  42779. */
  42780. occlusionQueryAlgorithmType: number;
  42781. /**
  42782. * 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
  42783. * @see http://doc.babylonjs.com/features/occlusionquery
  42784. */
  42785. isOccluded: boolean;
  42786. /**
  42787. * Flag to check the progress status of the query
  42788. * @see http://doc.babylonjs.com/features/occlusionquery
  42789. */
  42790. isOcclusionQueryInProgress: boolean;
  42791. }
  42792. }
  42793. }
  42794. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42795. import { Nullable } from "babylonjs/types";
  42796. /** @hidden */
  42797. export var _forceTransformFeedbackToBundle: boolean;
  42798. module "babylonjs/Engines/engine" {
  42799. interface Engine {
  42800. /**
  42801. * Creates a webGL transform feedback object
  42802. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42803. * @returns the webGL transform feedback object
  42804. */
  42805. createTransformFeedback(): WebGLTransformFeedback;
  42806. /**
  42807. * Delete a webGL transform feedback object
  42808. * @param value defines the webGL transform feedback object to delete
  42809. */
  42810. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42811. /**
  42812. * Bind a webGL transform feedback object to the webgl context
  42813. * @param value defines the webGL transform feedback object to bind
  42814. */
  42815. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42816. /**
  42817. * Begins a transform feedback operation
  42818. * @param usePoints defines if points or triangles must be used
  42819. */
  42820. beginTransformFeedback(usePoints: boolean): void;
  42821. /**
  42822. * Ends a transform feedback operation
  42823. */
  42824. endTransformFeedback(): void;
  42825. /**
  42826. * Specify the varyings to use with transform feedback
  42827. * @param program defines the associated webGL program
  42828. * @param value defines the list of strings representing the varying names
  42829. */
  42830. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42831. /**
  42832. * Bind a webGL buffer for a transform feedback operation
  42833. * @param value defines the webGL buffer to bind
  42834. */
  42835. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42836. }
  42837. }
  42838. }
  42839. declare module "babylonjs/Engines/Extensions/index" {
  42840. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42841. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42842. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42843. }
  42844. declare module "babylonjs/Engines/index" {
  42845. export * from "babylonjs/Engines/constants";
  42846. export * from "babylonjs/Engines/engine";
  42847. export * from "babylonjs/Engines/engineStore";
  42848. export * from "babylonjs/Engines/nullEngine";
  42849. export * from "babylonjs/Engines/Extensions/index";
  42850. }
  42851. declare module "babylonjs/Events/clipboardEvents" {
  42852. /**
  42853. * Gather the list of clipboard event types as constants.
  42854. */
  42855. export class ClipboardEventTypes {
  42856. /**
  42857. * The clipboard event is fired when a copy command is active (pressed).
  42858. */
  42859. static readonly COPY: number;
  42860. /**
  42861. * The clipboard event is fired when a cut command is active (pressed).
  42862. */
  42863. static readonly CUT: number;
  42864. /**
  42865. * The clipboard event is fired when a paste command is active (pressed).
  42866. */
  42867. static readonly PASTE: number;
  42868. }
  42869. /**
  42870. * This class is used to store clipboard related info for the onClipboardObservable event.
  42871. */
  42872. export class ClipboardInfo {
  42873. /**
  42874. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42875. */
  42876. type: number;
  42877. /**
  42878. * Defines the related dom event
  42879. */
  42880. event: ClipboardEvent;
  42881. /**
  42882. *Creates an instance of ClipboardInfo.
  42883. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42884. * @param event Defines the related dom event
  42885. */
  42886. constructor(
  42887. /**
  42888. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42889. */
  42890. type: number,
  42891. /**
  42892. * Defines the related dom event
  42893. */
  42894. event: ClipboardEvent);
  42895. /**
  42896. * Get the clipboard event's type from the keycode.
  42897. * @param keyCode Defines the keyCode for the current keyboard event.
  42898. * @return {number}
  42899. */
  42900. static GetTypeFromCharacter(keyCode: number): number;
  42901. }
  42902. }
  42903. declare module "babylonjs/Events/index" {
  42904. export * from "babylonjs/Events/keyboardEvents";
  42905. export * from "babylonjs/Events/pointerEvents";
  42906. export * from "babylonjs/Events/clipboardEvents";
  42907. }
  42908. declare module "babylonjs/Loading/sceneLoader" {
  42909. import { Observable } from "babylonjs/Misc/observable";
  42910. import { Nullable } from "babylonjs/types";
  42911. import { Scene } from "babylonjs/scene";
  42912. import { Engine } from "babylonjs/Engines/engine";
  42913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42914. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42915. import { AssetContainer } from "babylonjs/assetContainer";
  42916. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42917. import { Skeleton } from "babylonjs/Bones/skeleton";
  42918. /**
  42919. * Class used to represent data loading progression
  42920. */
  42921. export class SceneLoaderProgressEvent {
  42922. /** defines if data length to load can be evaluated */
  42923. readonly lengthComputable: boolean;
  42924. /** defines the loaded data length */
  42925. readonly loaded: number;
  42926. /** defines the data length to load */
  42927. readonly total: number;
  42928. /**
  42929. * Create a new progress event
  42930. * @param lengthComputable defines if data length to load can be evaluated
  42931. * @param loaded defines the loaded data length
  42932. * @param total defines the data length to load
  42933. */
  42934. constructor(
  42935. /** defines if data length to load can be evaluated */
  42936. lengthComputable: boolean,
  42937. /** defines the loaded data length */
  42938. loaded: number,
  42939. /** defines the data length to load */
  42940. total: number);
  42941. /**
  42942. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42943. * @param event defines the source event
  42944. * @returns a new SceneLoaderProgressEvent
  42945. */
  42946. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42947. }
  42948. /**
  42949. * Interface used by SceneLoader plugins to define supported file extensions
  42950. */
  42951. export interface ISceneLoaderPluginExtensions {
  42952. /**
  42953. * Defines the list of supported extensions
  42954. */
  42955. [extension: string]: {
  42956. isBinary: boolean;
  42957. };
  42958. }
  42959. /**
  42960. * Interface used by SceneLoader plugin factory
  42961. */
  42962. export interface ISceneLoaderPluginFactory {
  42963. /**
  42964. * Defines the name of the factory
  42965. */
  42966. name: string;
  42967. /**
  42968. * Function called to create a new plugin
  42969. * @return the new plugin
  42970. */
  42971. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42972. /**
  42973. * Boolean indicating if the plugin can direct load specific data
  42974. */
  42975. canDirectLoad?: (data: string) => boolean;
  42976. }
  42977. /**
  42978. * Interface used to define a SceneLoader plugin
  42979. */
  42980. export interface ISceneLoaderPlugin {
  42981. /**
  42982. * The friendly name of this plugin.
  42983. */
  42984. name: string;
  42985. /**
  42986. * The file extensions supported by this plugin.
  42987. */
  42988. extensions: string | ISceneLoaderPluginExtensions;
  42989. /**
  42990. * Import meshes into a scene.
  42991. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42992. * @param scene The scene to import into
  42993. * @param data The data to import
  42994. * @param rootUrl The root url for scene and resources
  42995. * @param meshes The meshes array to import into
  42996. * @param particleSystems The particle systems array to import into
  42997. * @param skeletons The skeletons array to import into
  42998. * @param onError The callback when import fails
  42999. * @returns True if successful or false otherwise
  43000. */
  43001. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43002. /**
  43003. * Load into a scene.
  43004. * @param scene The scene to load into
  43005. * @param data The data to import
  43006. * @param rootUrl The root url for scene and resources
  43007. * @param onError The callback when import fails
  43008. * @returns true if successful or false otherwise
  43009. */
  43010. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43011. /**
  43012. * The callback that returns true if the data can be directly loaded.
  43013. */
  43014. canDirectLoad?: (data: string) => boolean;
  43015. /**
  43016. * The callback that allows custom handling of the root url based on the response url.
  43017. */
  43018. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43019. /**
  43020. * Load into an asset container.
  43021. * @param scene The scene to load into
  43022. * @param data The data to import
  43023. * @param rootUrl The root url for scene and resources
  43024. * @param onError The callback when import fails
  43025. * @returns The loaded asset container
  43026. */
  43027. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43028. }
  43029. /**
  43030. * Interface used to define an async SceneLoader plugin
  43031. */
  43032. export interface ISceneLoaderPluginAsync {
  43033. /**
  43034. * The friendly name of this plugin.
  43035. */
  43036. name: string;
  43037. /**
  43038. * The file extensions supported by this plugin.
  43039. */
  43040. extensions: string | ISceneLoaderPluginExtensions;
  43041. /**
  43042. * Import meshes into a scene.
  43043. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43044. * @param scene The scene to import into
  43045. * @param data The data to import
  43046. * @param rootUrl The root url for scene and resources
  43047. * @param onProgress The callback when the load progresses
  43048. * @param fileName Defines the name of the file to load
  43049. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43050. */
  43051. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43052. meshes: AbstractMesh[];
  43053. particleSystems: IParticleSystem[];
  43054. skeletons: Skeleton[];
  43055. animationGroups: AnimationGroup[];
  43056. }>;
  43057. /**
  43058. * Load into a scene.
  43059. * @param scene The scene to load into
  43060. * @param data The data to import
  43061. * @param rootUrl The root url for scene and resources
  43062. * @param onProgress The callback when the load progresses
  43063. * @param fileName Defines the name of the file to load
  43064. * @returns Nothing
  43065. */
  43066. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43067. /**
  43068. * The callback that returns true if the data can be directly loaded.
  43069. */
  43070. canDirectLoad?: (data: string) => boolean;
  43071. /**
  43072. * The callback that allows custom handling of the root url based on the response url.
  43073. */
  43074. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43075. /**
  43076. * Load into an asset container.
  43077. * @param scene The scene to load into
  43078. * @param data The data to import
  43079. * @param rootUrl The root url for scene and resources
  43080. * @param onProgress The callback when the load progresses
  43081. * @param fileName Defines the name of the file to load
  43082. * @returns The loaded asset container
  43083. */
  43084. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43085. }
  43086. /**
  43087. * Class used to load scene from various file formats using registered plugins
  43088. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43089. */
  43090. export class SceneLoader {
  43091. /**
  43092. * No logging while loading
  43093. */
  43094. static readonly NO_LOGGING: number;
  43095. /**
  43096. * Minimal logging while loading
  43097. */
  43098. static readonly MINIMAL_LOGGING: number;
  43099. /**
  43100. * Summary logging while loading
  43101. */
  43102. static readonly SUMMARY_LOGGING: number;
  43103. /**
  43104. * Detailled logging while loading
  43105. */
  43106. static readonly DETAILED_LOGGING: number;
  43107. /**
  43108. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43109. */
  43110. static ForceFullSceneLoadingForIncremental: boolean;
  43111. /**
  43112. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43113. */
  43114. static ShowLoadingScreen: boolean;
  43115. /**
  43116. * Defines the current logging level (while loading the scene)
  43117. * @ignorenaming
  43118. */
  43119. static loggingLevel: number;
  43120. /**
  43121. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43122. */
  43123. static CleanBoneMatrixWeights: boolean;
  43124. /**
  43125. * Event raised when a plugin is used to load a scene
  43126. */
  43127. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43128. private static _registeredPlugins;
  43129. private static _getDefaultPlugin;
  43130. private static _getPluginForExtension;
  43131. private static _getPluginForDirectLoad;
  43132. private static _getPluginForFilename;
  43133. private static _getDirectLoad;
  43134. private static _loadData;
  43135. private static _getFileInfo;
  43136. /**
  43137. * Gets a plugin that can load the given extension
  43138. * @param extension defines the extension to load
  43139. * @returns a plugin or null if none works
  43140. */
  43141. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43142. /**
  43143. * Gets a boolean indicating that the given extension can be loaded
  43144. * @param extension defines the extension to load
  43145. * @returns true if the extension is supported
  43146. */
  43147. static IsPluginForExtensionAvailable(extension: string): boolean;
  43148. /**
  43149. * Adds a new plugin to the list of registered plugins
  43150. * @param plugin defines the plugin to add
  43151. */
  43152. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43153. /**
  43154. * Import meshes into a scene
  43155. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43156. * @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)
  43157. * @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)
  43158. * @param scene the instance of BABYLON.Scene to append to
  43159. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43160. * @param onProgress a callback with a progress event for each file being loaded
  43161. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43162. * @param pluginExtension the extension used to determine the plugin
  43163. * @returns The loaded plugin
  43164. */
  43165. 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>;
  43166. /**
  43167. * Import meshes into a scene
  43168. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43169. * @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)
  43170. * @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)
  43171. * @param scene the instance of BABYLON.Scene to append to
  43172. * @param onProgress a callback with a progress event for each file being loaded
  43173. * @param pluginExtension the extension used to determine the plugin
  43174. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43175. */
  43176. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43177. meshes: AbstractMesh[];
  43178. particleSystems: IParticleSystem[];
  43179. skeletons: Skeleton[];
  43180. animationGroups: AnimationGroup[];
  43181. }>;
  43182. /**
  43183. * Load a scene
  43184. * @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)
  43185. * @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)
  43186. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43187. * @param onSuccess a callback with the scene when import succeeds
  43188. * @param onProgress a callback with a progress event for each file being loaded
  43189. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43190. * @param pluginExtension the extension used to determine the plugin
  43191. * @returns The loaded plugin
  43192. */
  43193. 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>;
  43194. /**
  43195. * Load a scene
  43196. * @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)
  43197. * @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)
  43198. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43199. * @param onProgress a callback with a progress event for each file being loaded
  43200. * @param pluginExtension the extension used to determine the plugin
  43201. * @returns The loaded scene
  43202. */
  43203. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43204. /**
  43205. * Append a scene
  43206. * @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)
  43207. * @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)
  43208. * @param scene is the instance of BABYLON.Scene to append to
  43209. * @param onSuccess a callback with the scene when import succeeds
  43210. * @param onProgress a callback with a progress event for each file being loaded
  43211. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43212. * @param pluginExtension the extension used to determine the plugin
  43213. * @returns The loaded plugin
  43214. */
  43215. 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>;
  43216. /**
  43217. * Append a scene
  43218. * @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)
  43219. * @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)
  43220. * @param scene is the instance of BABYLON.Scene to append to
  43221. * @param onProgress a callback with a progress event for each file being loaded
  43222. * @param pluginExtension the extension used to determine the plugin
  43223. * @returns The given scene
  43224. */
  43225. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43226. /**
  43227. * Load a scene into an asset container
  43228. * @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)
  43229. * @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)
  43230. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43231. * @param onSuccess a callback with the scene when import succeeds
  43232. * @param onProgress a callback with a progress event for each file being loaded
  43233. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43234. * @param pluginExtension the extension used to determine the plugin
  43235. * @returns The loaded plugin
  43236. */
  43237. 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>;
  43238. /**
  43239. * Load a scene into an asset container
  43240. * @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)
  43241. * @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)
  43242. * @param scene is the instance of Scene to append to
  43243. * @param onProgress a callback with a progress event for each file being loaded
  43244. * @param pluginExtension the extension used to determine the plugin
  43245. * @returns The loaded asset container
  43246. */
  43247. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43248. }
  43249. }
  43250. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43251. import { Scene } from "babylonjs/scene";
  43252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43253. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43254. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43255. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43256. /**
  43257. * Google Daydream controller
  43258. */
  43259. export class DaydreamController extends WebVRController {
  43260. /**
  43261. * Base Url for the controller model.
  43262. */
  43263. static MODEL_BASE_URL: string;
  43264. /**
  43265. * File name for the controller model.
  43266. */
  43267. static MODEL_FILENAME: string;
  43268. /**
  43269. * Gamepad Id prefix used to identify Daydream Controller.
  43270. */
  43271. static readonly GAMEPAD_ID_PREFIX: string;
  43272. /**
  43273. * Creates a new DaydreamController from a gamepad
  43274. * @param vrGamepad the gamepad that the controller should be created from
  43275. */
  43276. constructor(vrGamepad: any);
  43277. /**
  43278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43279. * @param scene scene in which to add meshes
  43280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43281. */
  43282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43283. /**
  43284. * Called once for each button that changed state since the last frame
  43285. * @param buttonIdx Which button index changed
  43286. * @param state New state of the button
  43287. * @param changes Which properties on the state changed since last frame
  43288. */
  43289. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43290. }
  43291. }
  43292. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43293. import { Scene } from "babylonjs/scene";
  43294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43295. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43296. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43297. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43298. /**
  43299. * Gear VR Controller
  43300. */
  43301. export class GearVRController extends WebVRController {
  43302. /**
  43303. * Base Url for the controller model.
  43304. */
  43305. static MODEL_BASE_URL: string;
  43306. /**
  43307. * File name for the controller model.
  43308. */
  43309. static MODEL_FILENAME: string;
  43310. /**
  43311. * Gamepad Id prefix used to identify this controller.
  43312. */
  43313. static readonly GAMEPAD_ID_PREFIX: string;
  43314. private readonly _buttonIndexToObservableNameMap;
  43315. /**
  43316. * Creates a new GearVRController from a gamepad
  43317. * @param vrGamepad the gamepad that the controller should be created from
  43318. */
  43319. constructor(vrGamepad: any);
  43320. /**
  43321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43322. * @param scene scene in which to add meshes
  43323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43324. */
  43325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43326. /**
  43327. * Called once for each button that changed state since the last frame
  43328. * @param buttonIdx Which button index changed
  43329. * @param state New state of the button
  43330. * @param changes Which properties on the state changed since last frame
  43331. */
  43332. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43333. }
  43334. }
  43335. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43336. import { Scene } from "babylonjs/scene";
  43337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43338. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43339. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43340. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43341. /**
  43342. * Generic Controller
  43343. */
  43344. export class GenericController extends WebVRController {
  43345. /**
  43346. * Base Url for the controller model.
  43347. */
  43348. static readonly MODEL_BASE_URL: string;
  43349. /**
  43350. * File name for the controller model.
  43351. */
  43352. static readonly MODEL_FILENAME: string;
  43353. /**
  43354. * Creates a new GenericController from a gamepad
  43355. * @param vrGamepad the gamepad that the controller should be created from
  43356. */
  43357. constructor(vrGamepad: any);
  43358. /**
  43359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43360. * @param scene scene in which to add meshes
  43361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43362. */
  43363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43364. /**
  43365. * Called once for each button that changed state since the last frame
  43366. * @param buttonIdx Which button index changed
  43367. * @param state New state of the button
  43368. * @param changes Which properties on the state changed since last frame
  43369. */
  43370. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43371. }
  43372. }
  43373. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43374. import { Observable } from "babylonjs/Misc/observable";
  43375. import { Scene } from "babylonjs/scene";
  43376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43377. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43378. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43379. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43380. /**
  43381. * Oculus Touch Controller
  43382. */
  43383. export class OculusTouchController extends WebVRController {
  43384. /**
  43385. * Base Url for the controller model.
  43386. */
  43387. static MODEL_BASE_URL: string;
  43388. /**
  43389. * File name for the left controller model.
  43390. */
  43391. static MODEL_LEFT_FILENAME: string;
  43392. /**
  43393. * File name for the right controller model.
  43394. */
  43395. static MODEL_RIGHT_FILENAME: string;
  43396. /**
  43397. * Fired when the secondary trigger on this controller is modified
  43398. */
  43399. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43400. /**
  43401. * Fired when the thumb rest on this controller is modified
  43402. */
  43403. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43404. /**
  43405. * Creates a new OculusTouchController from a gamepad
  43406. * @param vrGamepad the gamepad that the controller should be created from
  43407. */
  43408. constructor(vrGamepad: any);
  43409. /**
  43410. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43411. * @param scene scene in which to add meshes
  43412. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43413. */
  43414. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43415. /**
  43416. * Fired when the A button on this controller is modified
  43417. */
  43418. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43419. /**
  43420. * Fired when the B button on this controller is modified
  43421. */
  43422. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43423. /**
  43424. * Fired when the X button on this controller is modified
  43425. */
  43426. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43427. /**
  43428. * Fired when the Y button on this controller is modified
  43429. */
  43430. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43431. /**
  43432. * Called once for each button that changed state since the last frame
  43433. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43434. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43435. * 2) secondary trigger (same)
  43436. * 3) A (right) X (left), touch, pressed = value
  43437. * 4) B / Y
  43438. * 5) thumb rest
  43439. * @param buttonIdx Which button index changed
  43440. * @param state New state of the button
  43441. * @param changes Which properties on the state changed since last frame
  43442. */
  43443. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43444. }
  43445. }
  43446. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43447. import { Scene } from "babylonjs/scene";
  43448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43449. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43450. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43451. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43452. import { Observable } from "babylonjs/Misc/observable";
  43453. /**
  43454. * Vive Controller
  43455. */
  43456. export class ViveController extends WebVRController {
  43457. /**
  43458. * Base Url for the controller model.
  43459. */
  43460. static MODEL_BASE_URL: string;
  43461. /**
  43462. * File name for the controller model.
  43463. */
  43464. static MODEL_FILENAME: string;
  43465. /**
  43466. * Creates a new ViveController from a gamepad
  43467. * @param vrGamepad the gamepad that the controller should be created from
  43468. */
  43469. constructor(vrGamepad: any);
  43470. /**
  43471. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43472. * @param scene scene in which to add meshes
  43473. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43474. */
  43475. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43476. /**
  43477. * Fired when the left button on this controller is modified
  43478. */
  43479. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43480. /**
  43481. * Fired when the right button on this controller is modified
  43482. */
  43483. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43484. /**
  43485. * Fired when the menu button on this controller is modified
  43486. */
  43487. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43488. /**
  43489. * Called once for each button that changed state since the last frame
  43490. * Vive mapping:
  43491. * 0: touchpad
  43492. * 1: trigger
  43493. * 2: left AND right buttons
  43494. * 3: menu button
  43495. * @param buttonIdx Which button index changed
  43496. * @param state New state of the button
  43497. * @param changes Which properties on the state changed since last frame
  43498. */
  43499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43500. }
  43501. }
  43502. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43503. import { Observable } from "babylonjs/Misc/observable";
  43504. import { Scene } from "babylonjs/scene";
  43505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43506. import { Ray } from "babylonjs/Culling/ray";
  43507. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43508. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43509. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43510. /**
  43511. * Defines the WindowsMotionController object that the state of the windows motion controller
  43512. */
  43513. export class WindowsMotionController extends WebVRController {
  43514. /**
  43515. * The base url used to load the left and right controller models
  43516. */
  43517. static MODEL_BASE_URL: string;
  43518. /**
  43519. * The name of the left controller model file
  43520. */
  43521. static MODEL_LEFT_FILENAME: string;
  43522. /**
  43523. * The name of the right controller model file
  43524. */
  43525. static MODEL_RIGHT_FILENAME: string;
  43526. /**
  43527. * The controller name prefix for this controller type
  43528. */
  43529. static readonly GAMEPAD_ID_PREFIX: string;
  43530. /**
  43531. * The controller id pattern for this controller type
  43532. */
  43533. private static readonly GAMEPAD_ID_PATTERN;
  43534. private _loadedMeshInfo;
  43535. private readonly _mapping;
  43536. /**
  43537. * Fired when the trackpad on this controller is clicked
  43538. */
  43539. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the trackpad on this controller is modified
  43542. */
  43543. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43544. /**
  43545. * The current x and y values of this controller's trackpad
  43546. */
  43547. trackpad: StickValues;
  43548. /**
  43549. * Creates a new WindowsMotionController from a gamepad
  43550. * @param vrGamepad the gamepad that the controller should be created from
  43551. */
  43552. constructor(vrGamepad: any);
  43553. /**
  43554. * Fired when the trigger on this controller is modified
  43555. */
  43556. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43557. /**
  43558. * Fired when the menu button on this controller is modified
  43559. */
  43560. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43561. /**
  43562. * Fired when the grip button on this controller is modified
  43563. */
  43564. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43565. /**
  43566. * Fired when the thumbstick button on this controller is modified
  43567. */
  43568. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43569. /**
  43570. * Fired when the touchpad button on this controller is modified
  43571. */
  43572. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43573. /**
  43574. * Fired when the touchpad values on this controller are modified
  43575. */
  43576. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43577. private _updateTrackpad;
  43578. /**
  43579. * Called once per frame by the engine.
  43580. */
  43581. update(): void;
  43582. /**
  43583. * Called once for each button that changed state since the last frame
  43584. * @param buttonIdx Which button index changed
  43585. * @param state New state of the button
  43586. * @param changes Which properties on the state changed since last frame
  43587. */
  43588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43589. /**
  43590. * Moves the buttons on the controller mesh based on their current state
  43591. * @param buttonName the name of the button to move
  43592. * @param buttonValue the value of the button which determines the buttons new position
  43593. */
  43594. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43595. /**
  43596. * Moves the axis on the controller mesh based on its current state
  43597. * @param axis the index of the axis
  43598. * @param axisValue the value of the axis which determines the meshes new position
  43599. * @hidden
  43600. */
  43601. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43602. /**
  43603. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43604. * @param scene scene in which to add meshes
  43605. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43606. */
  43607. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43608. /**
  43609. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43610. * can be transformed by button presses and axes values, based on this._mapping.
  43611. *
  43612. * @param scene scene in which the meshes exist
  43613. * @param meshes list of meshes that make up the controller model to process
  43614. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43615. */
  43616. private processModel;
  43617. private createMeshInfo;
  43618. /**
  43619. * Gets the ray of the controller in the direction the controller is pointing
  43620. * @param length the length the resulting ray should be
  43621. * @returns a ray in the direction the controller is pointing
  43622. */
  43623. getForwardRay(length?: number): Ray;
  43624. /**
  43625. * Disposes of the controller
  43626. */
  43627. dispose(): void;
  43628. }
  43629. }
  43630. declare module "babylonjs/Gamepads/Controllers/index" {
  43631. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43632. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43633. export * from "babylonjs/Gamepads/Controllers/genericController";
  43634. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43635. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43636. export * from "babylonjs/Gamepads/Controllers/viveController";
  43637. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43638. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43639. }
  43640. declare module "babylonjs/Gamepads/index" {
  43641. export * from "babylonjs/Gamepads/Controllers/index";
  43642. export * from "babylonjs/Gamepads/gamepad";
  43643. export * from "babylonjs/Gamepads/gamepadManager";
  43644. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43645. export * from "babylonjs/Gamepads/xboxGamepad";
  43646. }
  43647. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43648. import { Observable } from "babylonjs/Misc/observable";
  43649. import { Nullable } from "babylonjs/types";
  43650. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43652. import { Mesh } from "babylonjs/Meshes/mesh";
  43653. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43654. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43655. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43656. /**
  43657. * Single axis scale gizmo
  43658. */
  43659. export class AxisScaleGizmo extends Gizmo {
  43660. private _coloredMaterial;
  43661. /**
  43662. * Drag behavior responsible for the gizmos dragging interactions
  43663. */
  43664. dragBehavior: PointerDragBehavior;
  43665. private _pointerObserver;
  43666. /**
  43667. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43668. */
  43669. snapDistance: number;
  43670. /**
  43671. * Event that fires each time the gizmo snaps to a new location.
  43672. * * snapDistance is the the change in distance
  43673. */
  43674. onSnapObservable: Observable<{
  43675. snapDistance: number;
  43676. }>;
  43677. /**
  43678. * If the scaling operation should be done on all axis (default: false)
  43679. */
  43680. uniformScaling: boolean;
  43681. /**
  43682. * Creates an AxisScaleGizmo
  43683. * @param gizmoLayer The utility layer the gizmo will be added to
  43684. * @param dragAxis The axis which the gizmo will be able to scale on
  43685. * @param color The color of the gizmo
  43686. */
  43687. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43689. /**
  43690. * Disposes of the gizmo
  43691. */
  43692. dispose(): void;
  43693. /**
  43694. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43695. * @param mesh The mesh to replace the default mesh of the gizmo
  43696. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43697. */
  43698. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43699. }
  43700. }
  43701. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43702. import { Observable } from "babylonjs/Misc/observable";
  43703. import { Nullable } from "babylonjs/types";
  43704. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43706. import { Mesh } from "babylonjs/Meshes/mesh";
  43707. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43708. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43709. import "babylonjs/Meshes/Builders/boxBuilder";
  43710. /**
  43711. * Bounding box gizmo
  43712. */
  43713. export class BoundingBoxGizmo extends Gizmo {
  43714. private _lineBoundingBox;
  43715. private _rotateSpheresParent;
  43716. private _scaleBoxesParent;
  43717. private _boundingDimensions;
  43718. private _renderObserver;
  43719. private _pointerObserver;
  43720. private _scaleDragSpeed;
  43721. private _tmpQuaternion;
  43722. private _tmpVector;
  43723. private _tmpRotationMatrix;
  43724. /**
  43725. * 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)
  43726. */
  43727. ignoreChildren: boolean;
  43728. /**
  43729. * 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)
  43730. */
  43731. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43732. /**
  43733. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43734. */
  43735. rotationSphereSize: number;
  43736. /**
  43737. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43738. */
  43739. scaleBoxSize: number;
  43740. /**
  43741. * 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)
  43742. */
  43743. fixedDragMeshScreenSize: boolean;
  43744. /**
  43745. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43746. */
  43747. fixedDragMeshScreenSizeDistanceFactor: number;
  43748. /**
  43749. * Fired when a rotation sphere or scale box is dragged
  43750. */
  43751. onDragStartObservable: Observable<{}>;
  43752. /**
  43753. * Fired when a scale box is dragged
  43754. */
  43755. onScaleBoxDragObservable: Observable<{}>;
  43756. /**
  43757. * Fired when a scale box drag is ended
  43758. */
  43759. onScaleBoxDragEndObservable: Observable<{}>;
  43760. /**
  43761. * Fired when a rotation sphere is dragged
  43762. */
  43763. onRotationSphereDragObservable: Observable<{}>;
  43764. /**
  43765. * Fired when a rotation sphere drag is ended
  43766. */
  43767. onRotationSphereDragEndObservable: Observable<{}>;
  43768. /**
  43769. * 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)
  43770. */
  43771. scalePivot: Nullable<Vector3>;
  43772. private _anchorMesh;
  43773. private _existingMeshScale;
  43774. private _dragMesh;
  43775. private pointerDragBehavior;
  43776. private coloredMaterial;
  43777. private hoverColoredMaterial;
  43778. /**
  43779. * Sets the color of the bounding box gizmo
  43780. * @param color the color to set
  43781. */
  43782. setColor(color: Color3): void;
  43783. /**
  43784. * Creates an BoundingBoxGizmo
  43785. * @param gizmoLayer The utility layer the gizmo will be added to
  43786. * @param color The color of the gizmo
  43787. */
  43788. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43789. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43790. private _selectNode;
  43791. /**
  43792. * Updates the bounding box information for the Gizmo
  43793. */
  43794. updateBoundingBox(): void;
  43795. private _updateRotationSpheres;
  43796. private _updateScaleBoxes;
  43797. /**
  43798. * Enables rotation on the specified axis and disables rotation on the others
  43799. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43800. */
  43801. setEnabledRotationAxis(axis: string): void;
  43802. /**
  43803. * Enables/disables scaling
  43804. * @param enable if scaling should be enabled
  43805. */
  43806. setEnabledScaling(enable: boolean): void;
  43807. private _updateDummy;
  43808. /**
  43809. * Enables a pointer drag behavior on the bounding box of the gizmo
  43810. */
  43811. enableDragBehavior(): void;
  43812. /**
  43813. * Disposes of the gizmo
  43814. */
  43815. dispose(): void;
  43816. /**
  43817. * 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)
  43818. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43819. * @returns the bounding box mesh with the passed in mesh as a child
  43820. */
  43821. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43822. /**
  43823. * CustomMeshes are not supported by this gizmo
  43824. * @param mesh The mesh to replace the default mesh of the gizmo
  43825. */
  43826. setCustomMesh(mesh: Mesh): void;
  43827. }
  43828. }
  43829. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43830. import { Observable } from "babylonjs/Misc/observable";
  43831. import { Nullable } from "babylonjs/types";
  43832. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43834. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43837. import "babylonjs/Meshes/Builders/linesBuilder";
  43838. /**
  43839. * Single plane rotation gizmo
  43840. */
  43841. export class PlaneRotationGizmo extends Gizmo {
  43842. /**
  43843. * Drag behavior responsible for the gizmos dragging interactions
  43844. */
  43845. dragBehavior: PointerDragBehavior;
  43846. private _pointerObserver;
  43847. /**
  43848. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43849. */
  43850. snapDistance: number;
  43851. /**
  43852. * Event that fires each time the gizmo snaps to a new location.
  43853. * * snapDistance is the the change in distance
  43854. */
  43855. onSnapObservable: Observable<{
  43856. snapDistance: number;
  43857. }>;
  43858. /**
  43859. * Creates a PlaneRotationGizmo
  43860. * @param gizmoLayer The utility layer the gizmo will be added to
  43861. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43862. * @param color The color of the gizmo
  43863. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43864. */
  43865. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43866. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43867. /**
  43868. * Disposes of the gizmo
  43869. */
  43870. dispose(): void;
  43871. }
  43872. }
  43873. declare module "babylonjs/Gizmos/rotationGizmo" {
  43874. import { Observable } from "babylonjs/Misc/observable";
  43875. import { Nullable } from "babylonjs/types";
  43876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43877. import { Mesh } from "babylonjs/Meshes/mesh";
  43878. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43879. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43880. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43881. /**
  43882. * Gizmo that enables rotating a mesh along 3 axis
  43883. */
  43884. export class RotationGizmo extends Gizmo {
  43885. /**
  43886. * Internal gizmo used for interactions on the x axis
  43887. */
  43888. xGizmo: PlaneRotationGizmo;
  43889. /**
  43890. * Internal gizmo used for interactions on the y axis
  43891. */
  43892. yGizmo: PlaneRotationGizmo;
  43893. /**
  43894. * Internal gizmo used for interactions on the z axis
  43895. */
  43896. zGizmo: PlaneRotationGizmo;
  43897. /** Fires an event when any of it's sub gizmos are dragged */
  43898. onDragStartObservable: Observable<{}>;
  43899. /** Fires an event when any of it's sub gizmos are released from dragging */
  43900. onDragEndObservable: Observable<{}>;
  43901. attachedMesh: Nullable<AbstractMesh>;
  43902. /**
  43903. * Creates a RotationGizmo
  43904. * @param gizmoLayer The utility layer the gizmo will be added to
  43905. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43906. */
  43907. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43908. updateGizmoRotationToMatchAttachedMesh: boolean;
  43909. /**
  43910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43911. */
  43912. snapDistance: number;
  43913. /**
  43914. * Ratio for the scale of the gizmo (Default: 1)
  43915. */
  43916. scaleRatio: number;
  43917. /**
  43918. * Disposes of the gizmo
  43919. */
  43920. dispose(): void;
  43921. /**
  43922. * CustomMeshes are not supported by this gizmo
  43923. * @param mesh The mesh to replace the default mesh of the gizmo
  43924. */
  43925. setCustomMesh(mesh: Mesh): void;
  43926. }
  43927. }
  43928. declare module "babylonjs/Gizmos/positionGizmo" {
  43929. import { Observable } from "babylonjs/Misc/observable";
  43930. import { Nullable } from "babylonjs/types";
  43931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43932. import { Mesh } from "babylonjs/Meshes/mesh";
  43933. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43934. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43935. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43936. /**
  43937. * Gizmo that enables dragging a mesh along 3 axis
  43938. */
  43939. export class PositionGizmo extends Gizmo {
  43940. /**
  43941. * Internal gizmo used for interactions on the x axis
  43942. */
  43943. xGizmo: AxisDragGizmo;
  43944. /**
  43945. * Internal gizmo used for interactions on the y axis
  43946. */
  43947. yGizmo: AxisDragGizmo;
  43948. /**
  43949. * Internal gizmo used for interactions on the z axis
  43950. */
  43951. zGizmo: AxisDragGizmo;
  43952. /** Fires an event when any of it's sub gizmos are dragged */
  43953. onDragStartObservable: Observable<{}>;
  43954. /** Fires an event when any of it's sub gizmos are released from dragging */
  43955. onDragEndObservable: Observable<{}>;
  43956. attachedMesh: Nullable<AbstractMesh>;
  43957. /**
  43958. * Creates a PositionGizmo
  43959. * @param gizmoLayer The utility layer the gizmo will be added to
  43960. */
  43961. constructor(gizmoLayer?: UtilityLayerRenderer);
  43962. updateGizmoRotationToMatchAttachedMesh: boolean;
  43963. /**
  43964. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43965. */
  43966. snapDistance: number;
  43967. /**
  43968. * Ratio for the scale of the gizmo (Default: 1)
  43969. */
  43970. scaleRatio: number;
  43971. /**
  43972. * Disposes of the gizmo
  43973. */
  43974. dispose(): void;
  43975. /**
  43976. * CustomMeshes are not supported by this gizmo
  43977. * @param mesh The mesh to replace the default mesh of the gizmo
  43978. */
  43979. setCustomMesh(mesh: Mesh): void;
  43980. }
  43981. }
  43982. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43983. import { Scene } from "babylonjs/scene";
  43984. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43985. import { Mesh } from "babylonjs/Meshes/mesh";
  43986. /**
  43987. * Class containing static functions to help procedurally build meshes
  43988. */
  43989. export class PolyhedronBuilder {
  43990. /**
  43991. * Creates a polyhedron mesh
  43992. * * 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
  43993. * * The parameter `size` (positive float, default 1) sets the polygon size
  43994. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43995. * * 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`
  43996. * * 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
  43997. * * 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)`)
  43998. * * 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
  43999. * * 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
  44000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44003. * @param name defines the name of the mesh
  44004. * @param options defines the options used to create the mesh
  44005. * @param scene defines the hosting scene
  44006. * @returns the polyhedron mesh
  44007. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44008. */
  44009. static CreatePolyhedron(name: string, options: {
  44010. type?: number;
  44011. size?: number;
  44012. sizeX?: number;
  44013. sizeY?: number;
  44014. sizeZ?: number;
  44015. custom?: any;
  44016. faceUV?: Vector4[];
  44017. faceColors?: Color4[];
  44018. flat?: boolean;
  44019. updatable?: boolean;
  44020. sideOrientation?: number;
  44021. frontUVs?: Vector4;
  44022. backUVs?: Vector4;
  44023. }, scene: Scene): Mesh;
  44024. }
  44025. }
  44026. declare module "babylonjs/Gizmos/scaleGizmo" {
  44027. import { Observable } from "babylonjs/Misc/observable";
  44028. import { Nullable } from "babylonjs/types";
  44029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44030. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44031. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44032. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44033. /**
  44034. * Gizmo that enables scaling a mesh along 3 axis
  44035. */
  44036. export class ScaleGizmo extends Gizmo {
  44037. /**
  44038. * Internal gizmo used for interactions on the x axis
  44039. */
  44040. xGizmo: AxisScaleGizmo;
  44041. /**
  44042. * Internal gizmo used for interactions on the y axis
  44043. */
  44044. yGizmo: AxisScaleGizmo;
  44045. /**
  44046. * Internal gizmo used for interactions on the z axis
  44047. */
  44048. zGizmo: AxisScaleGizmo;
  44049. /**
  44050. * Internal gizmo used to scale all axis equally
  44051. */
  44052. uniformScaleGizmo: AxisScaleGizmo;
  44053. /** Fires an event when any of it's sub gizmos are dragged */
  44054. onDragStartObservable: Observable<{}>;
  44055. /** Fires an event when any of it's sub gizmos are released from dragging */
  44056. onDragEndObservable: Observable<{}>;
  44057. attachedMesh: Nullable<AbstractMesh>;
  44058. /**
  44059. * Creates a ScaleGizmo
  44060. * @param gizmoLayer The utility layer the gizmo will be added to
  44061. */
  44062. constructor(gizmoLayer?: UtilityLayerRenderer);
  44063. updateGizmoRotationToMatchAttachedMesh: boolean;
  44064. /**
  44065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44066. */
  44067. snapDistance: number;
  44068. /**
  44069. * Ratio for the scale of the gizmo (Default: 1)
  44070. */
  44071. scaleRatio: number;
  44072. /**
  44073. * Disposes of the gizmo
  44074. */
  44075. dispose(): void;
  44076. }
  44077. }
  44078. declare module "babylonjs/Gizmos/gizmoManager" {
  44079. import { Observable } from "babylonjs/Misc/observable";
  44080. import { Nullable } from "babylonjs/types";
  44081. import { Scene, IDisposable } from "babylonjs/scene";
  44082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44083. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44084. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44085. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44086. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44087. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44088. /**
  44089. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44090. */
  44091. export class GizmoManager implements IDisposable {
  44092. private scene;
  44093. /**
  44094. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44095. */
  44096. gizmos: {
  44097. positionGizmo: Nullable<PositionGizmo>;
  44098. rotationGizmo: Nullable<RotationGizmo>;
  44099. scaleGizmo: Nullable<ScaleGizmo>;
  44100. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44101. };
  44102. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44103. clearGizmoOnEmptyPointerEvent: boolean;
  44104. /** Fires an event when the manager is attached to a mesh */
  44105. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44106. private _gizmosEnabled;
  44107. private _pointerObserver;
  44108. private _attachedMesh;
  44109. private _boundingBoxColor;
  44110. private _defaultUtilityLayer;
  44111. private _defaultKeepDepthUtilityLayer;
  44112. /**
  44113. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44114. */
  44115. boundingBoxDragBehavior: SixDofDragBehavior;
  44116. /**
  44117. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44118. */
  44119. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44120. /**
  44121. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44122. */
  44123. usePointerToAttachGizmos: boolean;
  44124. /**
  44125. * Instatiates a gizmo manager
  44126. * @param scene the scene to overlay the gizmos on top of
  44127. */
  44128. constructor(scene: Scene);
  44129. /**
  44130. * Attaches a set of gizmos to the specified mesh
  44131. * @param mesh The mesh the gizmo's should be attached to
  44132. */
  44133. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44134. /**
  44135. * If the position gizmo is enabled
  44136. */
  44137. positionGizmoEnabled: boolean;
  44138. /**
  44139. * If the rotation gizmo is enabled
  44140. */
  44141. rotationGizmoEnabled: boolean;
  44142. /**
  44143. * If the scale gizmo is enabled
  44144. */
  44145. scaleGizmoEnabled: boolean;
  44146. /**
  44147. * If the boundingBox gizmo is enabled
  44148. */
  44149. boundingBoxGizmoEnabled: boolean;
  44150. /**
  44151. * Disposes of the gizmo manager
  44152. */
  44153. dispose(): void;
  44154. }
  44155. }
  44156. declare module "babylonjs/Lights/directionalLight" {
  44157. import { Camera } from "babylonjs/Cameras/camera";
  44158. import { Scene } from "babylonjs/scene";
  44159. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44161. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44162. import { Effect } from "babylonjs/Materials/effect";
  44163. /**
  44164. * A directional light is defined by a direction (what a surprise!).
  44165. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44166. * 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.
  44167. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44168. */
  44169. export class DirectionalLight extends ShadowLight {
  44170. private _shadowFrustumSize;
  44171. /**
  44172. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44173. */
  44174. /**
  44175. * Specifies a fix frustum size for the shadow generation.
  44176. */
  44177. shadowFrustumSize: number;
  44178. private _shadowOrthoScale;
  44179. /**
  44180. * Gets the shadow projection scale against the optimal computed one.
  44181. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44182. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44183. */
  44184. /**
  44185. * Sets the shadow projection scale against the optimal computed one.
  44186. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44187. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44188. */
  44189. shadowOrthoScale: number;
  44190. /**
  44191. * Automatically compute the projection matrix to best fit (including all the casters)
  44192. * on each frame.
  44193. */
  44194. autoUpdateExtends: boolean;
  44195. private _orthoLeft;
  44196. private _orthoRight;
  44197. private _orthoTop;
  44198. private _orthoBottom;
  44199. /**
  44200. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44201. * The directional light is emitted from everywhere in the given direction.
  44202. * It can cast shadows.
  44203. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44204. * @param name The friendly name of the light
  44205. * @param direction The direction of the light
  44206. * @param scene The scene the light belongs to
  44207. */
  44208. constructor(name: string, direction: Vector3, scene: Scene);
  44209. /**
  44210. * Returns the string "DirectionalLight".
  44211. * @return The class name
  44212. */
  44213. getClassName(): string;
  44214. /**
  44215. * Returns the integer 1.
  44216. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44217. */
  44218. getTypeID(): number;
  44219. /**
  44220. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44221. * Returns the DirectionalLight Shadow projection matrix.
  44222. */
  44223. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44224. /**
  44225. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44226. * Returns the DirectionalLight Shadow projection matrix.
  44227. */
  44228. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44229. /**
  44230. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44231. * Returns the DirectionalLight Shadow projection matrix.
  44232. */
  44233. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44234. protected _buildUniformLayout(): void;
  44235. /**
  44236. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44237. * @param effect The effect to update
  44238. * @param lightIndex The index of the light in the effect to update
  44239. * @returns The directional light
  44240. */
  44241. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44242. /**
  44243. * Gets the minZ used for shadow according to both the scene and the light.
  44244. *
  44245. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44246. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44247. * @param activeCamera The camera we are returning the min for
  44248. * @returns the depth min z
  44249. */
  44250. getDepthMinZ(activeCamera: Camera): number;
  44251. /**
  44252. * Gets the maxZ used for shadow according to both the scene and the light.
  44253. *
  44254. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44255. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44256. * @param activeCamera The camera we are returning the max for
  44257. * @returns the depth max z
  44258. */
  44259. getDepthMaxZ(activeCamera: Camera): number;
  44260. /**
  44261. * Prepares the list of defines specific to the light type.
  44262. * @param defines the list of defines
  44263. * @param lightIndex defines the index of the light for the effect
  44264. */
  44265. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44266. }
  44267. }
  44268. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44269. import { Mesh } from "babylonjs/Meshes/mesh";
  44270. /**
  44271. * Class containing static functions to help procedurally build meshes
  44272. */
  44273. export class HemisphereBuilder {
  44274. /**
  44275. * Creates a hemisphere mesh
  44276. * @param name defines the name of the mesh
  44277. * @param options defines the options used to create the mesh
  44278. * @param scene defines the hosting scene
  44279. * @returns the hemisphere mesh
  44280. */
  44281. static CreateHemisphere(name: string, options: {
  44282. segments?: number;
  44283. diameter?: number;
  44284. sideOrientation?: number;
  44285. }, scene: any): Mesh;
  44286. }
  44287. }
  44288. declare module "babylonjs/Lights/spotLight" {
  44289. import { Nullable } from "babylonjs/types";
  44290. import { Scene } from "babylonjs/scene";
  44291. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44293. import { Effect } from "babylonjs/Materials/effect";
  44294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44295. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44296. /**
  44297. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44298. * These values define a cone of light starting from the position, emitting toward the direction.
  44299. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44300. * and the exponent defines the speed of the decay of the light with distance (reach).
  44301. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44302. */
  44303. export class SpotLight extends ShadowLight {
  44304. private _angle;
  44305. private _innerAngle;
  44306. private _cosHalfAngle;
  44307. private _lightAngleScale;
  44308. private _lightAngleOffset;
  44309. /**
  44310. * Gets the cone angle of the spot light in Radians.
  44311. */
  44312. /**
  44313. * Sets the cone angle of the spot light in Radians.
  44314. */
  44315. angle: number;
  44316. /**
  44317. * Only used in gltf falloff mode, this defines the angle where
  44318. * the directional falloff will start before cutting at angle which could be seen
  44319. * as outer angle.
  44320. */
  44321. /**
  44322. * Only used in gltf falloff mode, this defines the angle where
  44323. * the directional falloff will start before cutting at angle which could be seen
  44324. * as outer angle.
  44325. */
  44326. innerAngle: number;
  44327. private _shadowAngleScale;
  44328. /**
  44329. * Allows scaling the angle of the light for shadow generation only.
  44330. */
  44331. /**
  44332. * Allows scaling the angle of the light for shadow generation only.
  44333. */
  44334. shadowAngleScale: number;
  44335. /**
  44336. * The light decay speed with the distance from the emission spot.
  44337. */
  44338. exponent: number;
  44339. private _projectionTextureMatrix;
  44340. /**
  44341. * Allows reading the projecton texture
  44342. */
  44343. readonly projectionTextureMatrix: Matrix;
  44344. protected _projectionTextureLightNear: number;
  44345. /**
  44346. * Gets the near clip of the Spotlight for texture projection.
  44347. */
  44348. /**
  44349. * Sets the near clip of the Spotlight for texture projection.
  44350. */
  44351. projectionTextureLightNear: number;
  44352. protected _projectionTextureLightFar: number;
  44353. /**
  44354. * Gets the far clip of the Spotlight for texture projection.
  44355. */
  44356. /**
  44357. * Sets the far clip of the Spotlight for texture projection.
  44358. */
  44359. projectionTextureLightFar: number;
  44360. protected _projectionTextureUpDirection: Vector3;
  44361. /**
  44362. * Gets the Up vector of the Spotlight for texture projection.
  44363. */
  44364. /**
  44365. * Sets the Up vector of the Spotlight for texture projection.
  44366. */
  44367. projectionTextureUpDirection: Vector3;
  44368. private _projectionTexture;
  44369. /**
  44370. * Gets the projection texture of the light.
  44371. */
  44372. /**
  44373. * Sets the projection texture of the light.
  44374. */
  44375. projectionTexture: Nullable<BaseTexture>;
  44376. private _projectionTextureViewLightDirty;
  44377. private _projectionTextureProjectionLightDirty;
  44378. private _projectionTextureDirty;
  44379. private _projectionTextureViewTargetVector;
  44380. private _projectionTextureViewLightMatrix;
  44381. private _projectionTextureProjectionLightMatrix;
  44382. private _projectionTextureScalingMatrix;
  44383. /**
  44384. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44385. * It can cast shadows.
  44386. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44387. * @param name The light friendly name
  44388. * @param position The position of the spot light in the scene
  44389. * @param direction The direction of the light in the scene
  44390. * @param angle The cone angle of the light in Radians
  44391. * @param exponent The light decay speed with the distance from the emission spot
  44392. * @param scene The scene the lights belongs to
  44393. */
  44394. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44395. /**
  44396. * Returns the string "SpotLight".
  44397. * @returns the class name
  44398. */
  44399. getClassName(): string;
  44400. /**
  44401. * Returns the integer 2.
  44402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44403. */
  44404. getTypeID(): number;
  44405. /**
  44406. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44407. */
  44408. protected _setDirection(value: Vector3): void;
  44409. /**
  44410. * Overrides the position setter to recompute the projection texture view light Matrix.
  44411. */
  44412. protected _setPosition(value: Vector3): void;
  44413. /**
  44414. * 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.
  44415. * Returns the SpotLight.
  44416. */
  44417. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44418. protected _computeProjectionTextureViewLightMatrix(): void;
  44419. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44420. /**
  44421. * Main function for light texture projection matrix computing.
  44422. */
  44423. protected _computeProjectionTextureMatrix(): void;
  44424. protected _buildUniformLayout(): void;
  44425. private _computeAngleValues;
  44426. /**
  44427. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44428. * @param effect The effect to update
  44429. * @param lightIndex The index of the light in the effect to update
  44430. * @returns The spot light
  44431. */
  44432. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44433. /**
  44434. * Disposes the light and the associated resources.
  44435. */
  44436. dispose(): void;
  44437. /**
  44438. * Prepares the list of defines specific to the light type.
  44439. * @param defines the list of defines
  44440. * @param lightIndex defines the index of the light for the effect
  44441. */
  44442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44443. }
  44444. }
  44445. declare module "babylonjs/Gizmos/lightGizmo" {
  44446. import { Nullable } from "babylonjs/types";
  44447. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44448. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44449. import { Light } from "babylonjs/Lights/light";
  44450. /**
  44451. * Gizmo that enables viewing a light
  44452. */
  44453. export class LightGizmo extends Gizmo {
  44454. private _lightMesh;
  44455. private _material;
  44456. /**
  44457. * Creates a LightGizmo
  44458. * @param gizmoLayer The utility layer the gizmo will be added to
  44459. */
  44460. constructor(gizmoLayer?: UtilityLayerRenderer);
  44461. private _light;
  44462. /**
  44463. * The light that the gizmo is attached to
  44464. */
  44465. light: Nullable<Light>;
  44466. /**
  44467. * @hidden
  44468. * Updates the gizmo to match the attached mesh's position/rotation
  44469. */
  44470. protected _update(): void;
  44471. private static _Scale;
  44472. /**
  44473. * Creates the lines for a light mesh
  44474. */
  44475. private static _createLightLines;
  44476. private static _CreateHemisphericLightMesh;
  44477. private static _CreatePointLightMesh;
  44478. private static _CreateSpotLightMesh;
  44479. private static _CreateDirectionalLightMesh;
  44480. }
  44481. }
  44482. declare module "babylonjs/Gizmos/index" {
  44483. export * from "babylonjs/Gizmos/axisDragGizmo";
  44484. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44485. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44486. export * from "babylonjs/Gizmos/gizmo";
  44487. export * from "babylonjs/Gizmos/gizmoManager";
  44488. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44489. export * from "babylonjs/Gizmos/positionGizmo";
  44490. export * from "babylonjs/Gizmos/rotationGizmo";
  44491. export * from "babylonjs/Gizmos/scaleGizmo";
  44492. export * from "babylonjs/Gizmos/lightGizmo";
  44493. }
  44494. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44495. /** @hidden */
  44496. export var backgroundFragmentDeclaration: {
  44497. name: string;
  44498. shader: string;
  44499. };
  44500. }
  44501. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44502. /** @hidden */
  44503. export var backgroundUboDeclaration: {
  44504. name: string;
  44505. shader: string;
  44506. };
  44507. }
  44508. declare module "babylonjs/Shaders/background.fragment" {
  44509. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44510. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44511. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44512. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44513. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44514. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44515. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44516. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44517. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44518. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44519. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44520. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44521. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44522. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44523. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44524. /** @hidden */
  44525. export var backgroundPixelShader: {
  44526. name: string;
  44527. shader: string;
  44528. };
  44529. }
  44530. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44531. /** @hidden */
  44532. export var backgroundVertexDeclaration: {
  44533. name: string;
  44534. shader: string;
  44535. };
  44536. }
  44537. declare module "babylonjs/Shaders/background.vertex" {
  44538. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44539. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44540. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44541. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44542. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44543. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44544. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44545. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44546. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44549. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44550. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44551. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44552. /** @hidden */
  44553. export var backgroundVertexShader: {
  44554. name: string;
  44555. shader: string;
  44556. };
  44557. }
  44558. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44559. import { Nullable, int, float } from "babylonjs/types";
  44560. import { Scene } from "babylonjs/scene";
  44561. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44564. import { Mesh } from "babylonjs/Meshes/mesh";
  44565. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44566. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44567. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44569. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44570. import "babylonjs/Shaders/background.fragment";
  44571. import "babylonjs/Shaders/background.vertex";
  44572. /**
  44573. * Background material used to create an efficient environement around your scene.
  44574. */
  44575. export class BackgroundMaterial extends PushMaterial {
  44576. /**
  44577. * Standard reflectance value at parallel view angle.
  44578. */
  44579. static StandardReflectance0: number;
  44580. /**
  44581. * Standard reflectance value at grazing angle.
  44582. */
  44583. static StandardReflectance90: number;
  44584. protected _primaryColor: Color3;
  44585. /**
  44586. * Key light Color (multiply against the environement texture)
  44587. */
  44588. primaryColor: Color3;
  44589. protected __perceptualColor: Nullable<Color3>;
  44590. /**
  44591. * Experimental Internal Use Only.
  44592. *
  44593. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44594. * This acts as a helper to set the primary color to a more "human friendly" value.
  44595. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44596. * output color as close as possible from the chosen value.
  44597. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44598. * part of lighting setup.)
  44599. */
  44600. _perceptualColor: Nullable<Color3>;
  44601. protected _primaryColorShadowLevel: float;
  44602. /**
  44603. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44604. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44605. */
  44606. primaryColorShadowLevel: float;
  44607. protected _primaryColorHighlightLevel: float;
  44608. /**
  44609. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44610. * The primary color is used at the level chosen to define what the white area would look.
  44611. */
  44612. primaryColorHighlightLevel: float;
  44613. protected _reflectionTexture: Nullable<BaseTexture>;
  44614. /**
  44615. * Reflection Texture used in the material.
  44616. * Should be author in a specific way for the best result (refer to the documentation).
  44617. */
  44618. reflectionTexture: Nullable<BaseTexture>;
  44619. protected _reflectionBlur: float;
  44620. /**
  44621. * Reflection Texture level of blur.
  44622. *
  44623. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44624. * texture twice.
  44625. */
  44626. reflectionBlur: float;
  44627. protected _diffuseTexture: Nullable<BaseTexture>;
  44628. /**
  44629. * Diffuse Texture used in the material.
  44630. * Should be author in a specific way for the best result (refer to the documentation).
  44631. */
  44632. diffuseTexture: Nullable<BaseTexture>;
  44633. protected _shadowLights: Nullable<IShadowLight[]>;
  44634. /**
  44635. * Specify the list of lights casting shadow on the material.
  44636. * All scene shadow lights will be included if null.
  44637. */
  44638. shadowLights: Nullable<IShadowLight[]>;
  44639. protected _shadowLevel: float;
  44640. /**
  44641. * Helps adjusting the shadow to a softer level if required.
  44642. * 0 means black shadows and 1 means no shadows.
  44643. */
  44644. shadowLevel: float;
  44645. protected _sceneCenter: Vector3;
  44646. /**
  44647. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44648. * It is usually zero but might be interesting to modify according to your setup.
  44649. */
  44650. sceneCenter: Vector3;
  44651. protected _opacityFresnel: boolean;
  44652. /**
  44653. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44654. * This helps ensuring a nice transition when the camera goes under the ground.
  44655. */
  44656. opacityFresnel: boolean;
  44657. protected _reflectionFresnel: boolean;
  44658. /**
  44659. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44660. * This helps adding a mirror texture on the ground.
  44661. */
  44662. reflectionFresnel: boolean;
  44663. protected _reflectionFalloffDistance: number;
  44664. /**
  44665. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44666. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44667. */
  44668. reflectionFalloffDistance: number;
  44669. protected _reflectionAmount: number;
  44670. /**
  44671. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44672. */
  44673. reflectionAmount: number;
  44674. protected _reflectionReflectance0: number;
  44675. /**
  44676. * This specifies the weight of the reflection at grazing angle.
  44677. */
  44678. reflectionReflectance0: number;
  44679. protected _reflectionReflectance90: number;
  44680. /**
  44681. * This specifies the weight of the reflection at a perpendicular point of view.
  44682. */
  44683. reflectionReflectance90: number;
  44684. /**
  44685. * Sets the reflection reflectance fresnel values according to the default standard
  44686. * empirically know to work well :-)
  44687. */
  44688. reflectionStandardFresnelWeight: number;
  44689. protected _useRGBColor: boolean;
  44690. /**
  44691. * Helps to directly use the maps channels instead of their level.
  44692. */
  44693. useRGBColor: boolean;
  44694. protected _enableNoise: boolean;
  44695. /**
  44696. * This helps reducing the banding effect that could occur on the background.
  44697. */
  44698. enableNoise: boolean;
  44699. /**
  44700. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44701. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44702. * Recommended to be keep at 1.0 except for special cases.
  44703. */
  44704. fovMultiplier: number;
  44705. private _fovMultiplier;
  44706. /**
  44707. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44708. */
  44709. useEquirectangularFOV: boolean;
  44710. private _maxSimultaneousLights;
  44711. /**
  44712. * Number of Simultaneous lights allowed on the material.
  44713. */
  44714. maxSimultaneousLights: int;
  44715. /**
  44716. * Default configuration related to image processing available in the Background Material.
  44717. */
  44718. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44719. /**
  44720. * Keep track of the image processing observer to allow dispose and replace.
  44721. */
  44722. private _imageProcessingObserver;
  44723. /**
  44724. * Attaches a new image processing configuration to the PBR Material.
  44725. * @param configuration (if null the scene configuration will be use)
  44726. */
  44727. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44728. /**
  44729. * Gets the image processing configuration used either in this material.
  44730. */
  44731. /**
  44732. * Sets the Default image processing configuration used either in the this material.
  44733. *
  44734. * If sets to null, the scene one is in use.
  44735. */
  44736. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44737. /**
  44738. * Gets wether the color curves effect is enabled.
  44739. */
  44740. /**
  44741. * Sets wether the color curves effect is enabled.
  44742. */
  44743. cameraColorCurvesEnabled: boolean;
  44744. /**
  44745. * Gets wether the color grading effect is enabled.
  44746. */
  44747. /**
  44748. * Gets wether the color grading effect is enabled.
  44749. */
  44750. cameraColorGradingEnabled: boolean;
  44751. /**
  44752. * Gets wether tonemapping is enabled or not.
  44753. */
  44754. /**
  44755. * Sets wether tonemapping is enabled or not
  44756. */
  44757. cameraToneMappingEnabled: boolean;
  44758. /**
  44759. * The camera exposure used on this material.
  44760. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44761. * This corresponds to a photographic exposure.
  44762. */
  44763. /**
  44764. * The camera exposure used on this material.
  44765. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44766. * This corresponds to a photographic exposure.
  44767. */
  44768. cameraExposure: float;
  44769. /**
  44770. * Gets The camera contrast used on this material.
  44771. */
  44772. /**
  44773. * Sets The camera contrast used on this material.
  44774. */
  44775. cameraContrast: float;
  44776. /**
  44777. * Gets the Color Grading 2D Lookup Texture.
  44778. */
  44779. /**
  44780. * Sets the Color Grading 2D Lookup Texture.
  44781. */
  44782. cameraColorGradingTexture: Nullable<BaseTexture>;
  44783. /**
  44784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44786. * 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;
  44787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44788. */
  44789. /**
  44790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44792. * 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;
  44793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44794. */
  44795. cameraColorCurves: Nullable<ColorCurves>;
  44796. /**
  44797. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44798. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44799. */
  44800. switchToBGR: boolean;
  44801. private _renderTargets;
  44802. private _reflectionControls;
  44803. private _white;
  44804. private _primaryShadowColor;
  44805. private _primaryHighlightColor;
  44806. /**
  44807. * Instantiates a Background Material in the given scene
  44808. * @param name The friendly name of the material
  44809. * @param scene The scene to add the material to
  44810. */
  44811. constructor(name: string, scene: Scene);
  44812. /**
  44813. * Gets a boolean indicating that current material needs to register RTT
  44814. */
  44815. readonly hasRenderTargetTextures: boolean;
  44816. /**
  44817. * The entire material has been created in order to prevent overdraw.
  44818. * @returns false
  44819. */
  44820. needAlphaTesting(): boolean;
  44821. /**
  44822. * The entire material has been created in order to prevent overdraw.
  44823. * @returns true if blending is enable
  44824. */
  44825. needAlphaBlending(): boolean;
  44826. /**
  44827. * Checks wether the material is ready to be rendered for a given mesh.
  44828. * @param mesh The mesh to render
  44829. * @param subMesh The submesh to check against
  44830. * @param useInstances Specify wether or not the material is used with instances
  44831. * @returns true if all the dependencies are ready (Textures, Effects...)
  44832. */
  44833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44834. /**
  44835. * Compute the primary color according to the chosen perceptual color.
  44836. */
  44837. private _computePrimaryColorFromPerceptualColor;
  44838. /**
  44839. * Compute the highlights and shadow colors according to their chosen levels.
  44840. */
  44841. private _computePrimaryColors;
  44842. /**
  44843. * Build the uniform buffer used in the material.
  44844. */
  44845. buildUniformLayout(): void;
  44846. /**
  44847. * Unbind the material.
  44848. */
  44849. unbind(): void;
  44850. /**
  44851. * Bind only the world matrix to the material.
  44852. * @param world The world matrix to bind.
  44853. */
  44854. bindOnlyWorldMatrix(world: Matrix): void;
  44855. /**
  44856. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44857. * @param world The world matrix to bind.
  44858. * @param subMesh The submesh to bind for.
  44859. */
  44860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44861. /**
  44862. * Dispose the material.
  44863. * @param forceDisposeEffect Force disposal of the associated effect.
  44864. * @param forceDisposeTextures Force disposal of the associated textures.
  44865. */
  44866. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44867. /**
  44868. * Clones the material.
  44869. * @param name The cloned name.
  44870. * @returns The cloned material.
  44871. */
  44872. clone(name: string): BackgroundMaterial;
  44873. /**
  44874. * Serializes the current material to its JSON representation.
  44875. * @returns The JSON representation.
  44876. */
  44877. serialize(): any;
  44878. /**
  44879. * Gets the class name of the material
  44880. * @returns "BackgroundMaterial"
  44881. */
  44882. getClassName(): string;
  44883. /**
  44884. * Parse a JSON input to create back a background material.
  44885. * @param source The JSON data to parse
  44886. * @param scene The scene to create the parsed material in
  44887. * @param rootUrl The root url of the assets the material depends upon
  44888. * @returns the instantiated BackgroundMaterial.
  44889. */
  44890. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44891. }
  44892. }
  44893. declare module "babylonjs/Helpers/environmentHelper" {
  44894. import { Observable } from "babylonjs/Misc/observable";
  44895. import { Nullable } from "babylonjs/types";
  44896. import { Scene } from "babylonjs/scene";
  44897. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44899. import { Mesh } from "babylonjs/Meshes/mesh";
  44900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44901. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44902. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44903. import "babylonjs/Meshes/Builders/planeBuilder";
  44904. import "babylonjs/Meshes/Builders/boxBuilder";
  44905. /**
  44906. * Represents the different options available during the creation of
  44907. * a Environment helper.
  44908. *
  44909. * This can control the default ground, skybox and image processing setup of your scene.
  44910. */
  44911. export interface IEnvironmentHelperOptions {
  44912. /**
  44913. * Specifies wether or not to create a ground.
  44914. * True by default.
  44915. */
  44916. createGround: boolean;
  44917. /**
  44918. * Specifies the ground size.
  44919. * 15 by default.
  44920. */
  44921. groundSize: number;
  44922. /**
  44923. * The texture used on the ground for the main color.
  44924. * Comes from the BabylonJS CDN by default.
  44925. *
  44926. * Remarks: Can be either a texture or a url.
  44927. */
  44928. groundTexture: string | BaseTexture;
  44929. /**
  44930. * The color mixed in the ground texture by default.
  44931. * BabylonJS clearColor by default.
  44932. */
  44933. groundColor: Color3;
  44934. /**
  44935. * Specifies the ground opacity.
  44936. * 1 by default.
  44937. */
  44938. groundOpacity: number;
  44939. /**
  44940. * Enables the ground to receive shadows.
  44941. * True by default.
  44942. */
  44943. enableGroundShadow: boolean;
  44944. /**
  44945. * Helps preventing the shadow to be fully black on the ground.
  44946. * 0.5 by default.
  44947. */
  44948. groundShadowLevel: number;
  44949. /**
  44950. * Creates a mirror texture attach to the ground.
  44951. * false by default.
  44952. */
  44953. enableGroundMirror: boolean;
  44954. /**
  44955. * Specifies the ground mirror size ratio.
  44956. * 0.3 by default as the default kernel is 64.
  44957. */
  44958. groundMirrorSizeRatio: number;
  44959. /**
  44960. * Specifies the ground mirror blur kernel size.
  44961. * 64 by default.
  44962. */
  44963. groundMirrorBlurKernel: number;
  44964. /**
  44965. * Specifies the ground mirror visibility amount.
  44966. * 1 by default
  44967. */
  44968. groundMirrorAmount: number;
  44969. /**
  44970. * Specifies the ground mirror reflectance weight.
  44971. * This uses the standard weight of the background material to setup the fresnel effect
  44972. * of the mirror.
  44973. * 1 by default.
  44974. */
  44975. groundMirrorFresnelWeight: number;
  44976. /**
  44977. * Specifies the ground mirror Falloff distance.
  44978. * This can helps reducing the size of the reflection.
  44979. * 0 by Default.
  44980. */
  44981. groundMirrorFallOffDistance: number;
  44982. /**
  44983. * Specifies the ground mirror texture type.
  44984. * Unsigned Int by Default.
  44985. */
  44986. groundMirrorTextureType: number;
  44987. /**
  44988. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44989. * the shown objects.
  44990. */
  44991. groundYBias: number;
  44992. /**
  44993. * Specifies wether or not to create a skybox.
  44994. * True by default.
  44995. */
  44996. createSkybox: boolean;
  44997. /**
  44998. * Specifies the skybox size.
  44999. * 20 by default.
  45000. */
  45001. skyboxSize: number;
  45002. /**
  45003. * The texture used on the skybox for the main color.
  45004. * Comes from the BabylonJS CDN by default.
  45005. *
  45006. * Remarks: Can be either a texture or a url.
  45007. */
  45008. skyboxTexture: string | BaseTexture;
  45009. /**
  45010. * The color mixed in the skybox texture by default.
  45011. * BabylonJS clearColor by default.
  45012. */
  45013. skyboxColor: Color3;
  45014. /**
  45015. * The background rotation around the Y axis of the scene.
  45016. * This helps aligning the key lights of your scene with the background.
  45017. * 0 by default.
  45018. */
  45019. backgroundYRotation: number;
  45020. /**
  45021. * Compute automatically the size of the elements to best fit with the scene.
  45022. */
  45023. sizeAuto: boolean;
  45024. /**
  45025. * Default position of the rootMesh if autoSize is not true.
  45026. */
  45027. rootPosition: Vector3;
  45028. /**
  45029. * Sets up the image processing in the scene.
  45030. * true by default.
  45031. */
  45032. setupImageProcessing: boolean;
  45033. /**
  45034. * The texture used as your environment texture in the scene.
  45035. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45036. *
  45037. * Remarks: Can be either a texture or a url.
  45038. */
  45039. environmentTexture: string | BaseTexture;
  45040. /**
  45041. * The value of the exposure to apply to the scene.
  45042. * 0.6 by default if setupImageProcessing is true.
  45043. */
  45044. cameraExposure: number;
  45045. /**
  45046. * The value of the contrast to apply to the scene.
  45047. * 1.6 by default if setupImageProcessing is true.
  45048. */
  45049. cameraContrast: number;
  45050. /**
  45051. * Specifies wether or not tonemapping should be enabled in the scene.
  45052. * true by default if setupImageProcessing is true.
  45053. */
  45054. toneMappingEnabled: boolean;
  45055. }
  45056. /**
  45057. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45058. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45059. * It also helps with the default setup of your imageProcessing configuration.
  45060. */
  45061. export class EnvironmentHelper {
  45062. /**
  45063. * Default ground texture URL.
  45064. */
  45065. private static _groundTextureCDNUrl;
  45066. /**
  45067. * Default skybox texture URL.
  45068. */
  45069. private static _skyboxTextureCDNUrl;
  45070. /**
  45071. * Default environment texture URL.
  45072. */
  45073. private static _environmentTextureCDNUrl;
  45074. /**
  45075. * Creates the default options for the helper.
  45076. */
  45077. private static _getDefaultOptions;
  45078. private _rootMesh;
  45079. /**
  45080. * Gets the root mesh created by the helper.
  45081. */
  45082. readonly rootMesh: Mesh;
  45083. private _skybox;
  45084. /**
  45085. * Gets the skybox created by the helper.
  45086. */
  45087. readonly skybox: Nullable<Mesh>;
  45088. private _skyboxTexture;
  45089. /**
  45090. * Gets the skybox texture created by the helper.
  45091. */
  45092. readonly skyboxTexture: Nullable<BaseTexture>;
  45093. private _skyboxMaterial;
  45094. /**
  45095. * Gets the skybox material created by the helper.
  45096. */
  45097. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45098. private _ground;
  45099. /**
  45100. * Gets the ground mesh created by the helper.
  45101. */
  45102. readonly ground: Nullable<Mesh>;
  45103. private _groundTexture;
  45104. /**
  45105. * Gets the ground texture created by the helper.
  45106. */
  45107. readonly groundTexture: Nullable<BaseTexture>;
  45108. private _groundMirror;
  45109. /**
  45110. * Gets the ground mirror created by the helper.
  45111. */
  45112. readonly groundMirror: Nullable<MirrorTexture>;
  45113. /**
  45114. * Gets the ground mirror render list to helps pushing the meshes
  45115. * you wish in the ground reflection.
  45116. */
  45117. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45118. private _groundMaterial;
  45119. /**
  45120. * Gets the ground material created by the helper.
  45121. */
  45122. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45123. /**
  45124. * Stores the creation options.
  45125. */
  45126. private readonly _scene;
  45127. private _options;
  45128. /**
  45129. * This observable will be notified with any error during the creation of the environment,
  45130. * mainly texture creation errors.
  45131. */
  45132. onErrorObservable: Observable<{
  45133. message?: string;
  45134. exception?: any;
  45135. }>;
  45136. /**
  45137. * constructor
  45138. * @param options Defines the options we want to customize the helper
  45139. * @param scene The scene to add the material to
  45140. */
  45141. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45142. /**
  45143. * Updates the background according to the new options
  45144. * @param options
  45145. */
  45146. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45147. /**
  45148. * Sets the primary color of all the available elements.
  45149. * @param color the main color to affect to the ground and the background
  45150. */
  45151. setMainColor(color: Color3): void;
  45152. /**
  45153. * Setup the image processing according to the specified options.
  45154. */
  45155. private _setupImageProcessing;
  45156. /**
  45157. * Setup the environment texture according to the specified options.
  45158. */
  45159. private _setupEnvironmentTexture;
  45160. /**
  45161. * Setup the background according to the specified options.
  45162. */
  45163. private _setupBackground;
  45164. /**
  45165. * Get the scene sizes according to the setup.
  45166. */
  45167. private _getSceneSize;
  45168. /**
  45169. * Setup the ground according to the specified options.
  45170. */
  45171. private _setupGround;
  45172. /**
  45173. * Setup the ground material according to the specified options.
  45174. */
  45175. private _setupGroundMaterial;
  45176. /**
  45177. * Setup the ground diffuse texture according to the specified options.
  45178. */
  45179. private _setupGroundDiffuseTexture;
  45180. /**
  45181. * Setup the ground mirror texture according to the specified options.
  45182. */
  45183. private _setupGroundMirrorTexture;
  45184. /**
  45185. * Setup the ground to receive the mirror texture.
  45186. */
  45187. private _setupMirrorInGroundMaterial;
  45188. /**
  45189. * Setup the skybox according to the specified options.
  45190. */
  45191. private _setupSkybox;
  45192. /**
  45193. * Setup the skybox material according to the specified options.
  45194. */
  45195. private _setupSkyboxMaterial;
  45196. /**
  45197. * Setup the skybox reflection texture according to the specified options.
  45198. */
  45199. private _setupSkyboxReflectionTexture;
  45200. private _errorHandler;
  45201. /**
  45202. * Dispose all the elements created by the Helper.
  45203. */
  45204. dispose(): void;
  45205. }
  45206. }
  45207. declare module "babylonjs/Helpers/photoDome" {
  45208. import { Observable } from "babylonjs/Misc/observable";
  45209. import { Nullable } from "babylonjs/types";
  45210. import { Scene } from "babylonjs/scene";
  45211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45212. import { Mesh } from "babylonjs/Meshes/mesh";
  45213. import { Texture } from "babylonjs/Materials/Textures/texture";
  45214. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45215. import "babylonjs/Meshes/Builders/sphereBuilder";
  45216. /**
  45217. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45218. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45219. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45220. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45221. */
  45222. export class PhotoDome extends TransformNode {
  45223. private _useDirectMapping;
  45224. /**
  45225. * The texture being displayed on the sphere
  45226. */
  45227. protected _photoTexture: Texture;
  45228. /**
  45229. * Gets or sets the texture being displayed on the sphere
  45230. */
  45231. photoTexture: Texture;
  45232. /**
  45233. * Observable raised when an error occured while loading the 360 image
  45234. */
  45235. onLoadErrorObservable: Observable<string>;
  45236. /**
  45237. * The skybox material
  45238. */
  45239. protected _material: BackgroundMaterial;
  45240. /**
  45241. * The surface used for the skybox
  45242. */
  45243. protected _mesh: Mesh;
  45244. /**
  45245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45246. * Also see the options.resolution property.
  45247. */
  45248. fovMultiplier: number;
  45249. /**
  45250. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45251. * @param name Element's name, child elements will append suffixes for their own names.
  45252. * @param urlsOfPhoto defines the url of the photo to display
  45253. * @param options defines an object containing optional or exposed sub element properties
  45254. * @param onError defines a callback called when an error occured while loading the texture
  45255. */
  45256. constructor(name: string, urlOfPhoto: string, options: {
  45257. resolution?: number;
  45258. size?: number;
  45259. useDirectMapping?: boolean;
  45260. faceForward?: boolean;
  45261. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45262. /**
  45263. * Releases resources associated with this node.
  45264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45266. */
  45267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45268. }
  45269. }
  45270. declare module "babylonjs/Misc/brdfTextureTools" {
  45271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45272. import { Scene } from "babylonjs/scene";
  45273. /**
  45274. * Class used to host texture specific utilities
  45275. */
  45276. export class BRDFTextureTools {
  45277. /**
  45278. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45279. * @param texture the texture to expand.
  45280. */
  45281. private static _ExpandDefaultBRDFTexture;
  45282. /**
  45283. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45284. * @param scene defines the hosting scene
  45285. * @returns the environment BRDF texture
  45286. */
  45287. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45288. private static _environmentBRDFBase64Texture;
  45289. }
  45290. }
  45291. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45292. import { Nullable } from "babylonjs/types";
  45293. import { IAnimatable } from "babylonjs/Misc/tools";
  45294. import { Color3 } from "babylonjs/Maths/math";
  45295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45296. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45297. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45298. import { Engine } from "babylonjs/Engines/engine";
  45299. import { Scene } from "babylonjs/scene";
  45300. /**
  45301. * @hidden
  45302. */
  45303. export interface IMaterialClearCoatDefines {
  45304. CLEARCOAT: boolean;
  45305. CLEARCOAT_DEFAULTIOR: boolean;
  45306. CLEARCOAT_TEXTURE: boolean;
  45307. CLEARCOAT_TEXTUREDIRECTUV: number;
  45308. CLEARCOAT_BUMP: boolean;
  45309. CLEARCOAT_BUMPDIRECTUV: number;
  45310. CLEARCOAT_TINT: boolean;
  45311. CLEARCOAT_TINT_TEXTURE: boolean;
  45312. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45313. /** @hidden */
  45314. _areTexturesDirty: boolean;
  45315. }
  45316. /**
  45317. * Define the code related to the clear coat parameters of the pbr material.
  45318. */
  45319. export class PBRClearCoatConfiguration {
  45320. /**
  45321. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45322. * The default fits with a polyurethane material.
  45323. */
  45324. private static readonly _DefaultIndiceOfRefraction;
  45325. private _isEnabled;
  45326. /**
  45327. * Defines if the clear coat is enabled in the material.
  45328. */
  45329. isEnabled: boolean;
  45330. /**
  45331. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45332. */
  45333. intensity: number;
  45334. /**
  45335. * Defines the clear coat layer roughness.
  45336. */
  45337. roughness: number;
  45338. private _indiceOfRefraction;
  45339. /**
  45340. * Defines the indice of refraction of the clear coat.
  45341. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45342. * The default fits with a polyurethane material.
  45343. * Changing the default value is more performance intensive.
  45344. */
  45345. indiceOfRefraction: number;
  45346. private _texture;
  45347. /**
  45348. * Stores the clear coat values in a texture.
  45349. */
  45350. texture: Nullable<BaseTexture>;
  45351. private _bumpTexture;
  45352. /**
  45353. * Define the clear coat specific bump texture.
  45354. */
  45355. bumpTexture: Nullable<BaseTexture>;
  45356. private _isTintEnabled;
  45357. /**
  45358. * Defines if the clear coat tint is enabled in the material.
  45359. */
  45360. isTintEnabled: boolean;
  45361. /**
  45362. * Defines if the clear coat tint is enabled in the material.
  45363. * This is only use if tint is enabled
  45364. */
  45365. tintColor: Color3;
  45366. /**
  45367. * Defines if the distance at which the tint color should be found in the
  45368. * clear coat media.
  45369. * This is only use if tint is enabled
  45370. */
  45371. tintColorAtDistance: number;
  45372. /**
  45373. * Defines the clear coat layer thickness.
  45374. * This is only use if tint is enabled
  45375. */
  45376. tintThickness: number;
  45377. private _tintTexture;
  45378. /**
  45379. * Stores the clear tint values in a texture.
  45380. * rgb is tint
  45381. * a is a thickness factor
  45382. */
  45383. tintTexture: Nullable<BaseTexture>;
  45384. /** @hidden */
  45385. private _internalMarkAllSubMeshesAsTexturesDirty;
  45386. /** @hidden */
  45387. _markAllSubMeshesAsTexturesDirty(): void;
  45388. /**
  45389. * Instantiate a new istance of clear coat configuration.
  45390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45391. */
  45392. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45393. /**
  45394. * Specifies that the submesh is ready to be used.
  45395. * @param defines the list of "defines" to update.
  45396. * @param scene defines the scene the material belongs to.
  45397. * @param engine defines the engine the material belongs to.
  45398. * @param disableBumpMap defines wether the material disables bump or not.
  45399. * @returns - boolean indicating that the submesh is ready or not.
  45400. */
  45401. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45402. /**
  45403. * Checks to see if a texture is used in the material.
  45404. * @param defines the list of "defines" to update.
  45405. * @param scene defines the scene to the material belongs to.
  45406. */
  45407. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45408. /**
  45409. * Binds the material data.
  45410. * @param uniformBuffer defines the Uniform buffer to fill in.
  45411. * @param scene defines the scene the material belongs to.
  45412. * @param engine defines the engine the material belongs to.
  45413. * @param disableBumpMap defines wether the material disables bump or not.
  45414. * @param isFrozen defines wether the material is frozen or not.
  45415. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45416. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45417. */
  45418. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45419. /**
  45420. * Checks to see if a texture is used in the material.
  45421. * @param texture - Base texture to use.
  45422. * @returns - Boolean specifying if a texture is used in the material.
  45423. */
  45424. hasTexture(texture: BaseTexture): boolean;
  45425. /**
  45426. * Returns an array of the actively used textures.
  45427. * @param activeTextures Array of BaseTextures
  45428. */
  45429. getActiveTextures(activeTextures: BaseTexture[]): void;
  45430. /**
  45431. * Returns the animatable textures.
  45432. * @param animatables Array of animatable textures.
  45433. */
  45434. getAnimatables(animatables: IAnimatable[]): void;
  45435. /**
  45436. * Disposes the resources of the material.
  45437. * @param forceDisposeTextures - Forces the disposal of all textures.
  45438. */
  45439. dispose(forceDisposeTextures?: boolean): void;
  45440. /**
  45441. * Get the current class name of the texture useful for serialization or dynamic coding.
  45442. * @returns "PBRClearCoatConfiguration"
  45443. */
  45444. getClassName(): string;
  45445. /**
  45446. * Add fallbacks to the effect fallbacks list.
  45447. * @param defines defines the Base texture to use.
  45448. * @param fallbacks defines the current fallback list.
  45449. * @param currentRank defines the current fallback rank.
  45450. * @returns the new fallback rank.
  45451. */
  45452. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45453. /**
  45454. * Add the required uniforms to the current list.
  45455. * @param uniforms defines the current uniform list.
  45456. */
  45457. static AddUniforms(uniforms: string[]): void;
  45458. /**
  45459. * Add the required samplers to the current list.
  45460. * @param samplers defines the current sampler list.
  45461. */
  45462. static AddSamplers(samplers: string[]): void;
  45463. /**
  45464. * Add the required uniforms to the current buffer.
  45465. * @param uniformBuffer defines the current uniform buffer.
  45466. */
  45467. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45468. /**
  45469. * Makes a duplicate of the current configuration into another one.
  45470. * @param clearCoatConfiguration define the config where to copy the info
  45471. */
  45472. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45473. /**
  45474. * Serializes this clear coat configuration.
  45475. * @returns - An object with the serialized config.
  45476. */
  45477. serialize(): any;
  45478. /**
  45479. * Parses a Clear Coat Configuration from a serialized object.
  45480. * @param source - Serialized object.
  45481. */
  45482. parse(source: any): void;
  45483. }
  45484. }
  45485. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45486. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45487. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45489. import { Vector2 } from "babylonjs/Maths/math";
  45490. import { Scene } from "babylonjs/scene";
  45491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45492. import { IAnimatable } from "babylonjs/Misc/tools";
  45493. import { Nullable } from "babylonjs/types";
  45494. /**
  45495. * @hidden
  45496. */
  45497. export interface IMaterialAnisotropicDefines {
  45498. ANISOTROPIC: boolean;
  45499. ANISOTROPIC_TEXTURE: boolean;
  45500. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45501. MAINUV1: boolean;
  45502. _areTexturesDirty: boolean;
  45503. _needUVs: boolean;
  45504. }
  45505. /**
  45506. * Define the code related to the anisotropic parameters of the pbr material.
  45507. */
  45508. export class PBRAnisotropicConfiguration {
  45509. private _isEnabled;
  45510. /**
  45511. * Defines if the anisotropy is enabled in the material.
  45512. */
  45513. isEnabled: boolean;
  45514. /**
  45515. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45516. */
  45517. intensity: number;
  45518. /**
  45519. * Defines if the effect is along the tangents, bitangents or in between.
  45520. * By default, the effect is "strectching" the highlights along the tangents.
  45521. */
  45522. direction: Vector2;
  45523. private _texture;
  45524. /**
  45525. * Stores the anisotropy values in a texture.
  45526. * rg is direction (like normal from -1 to 1)
  45527. * b is a intensity
  45528. */
  45529. texture: Nullable<BaseTexture>;
  45530. /** @hidden */
  45531. private _internalMarkAllSubMeshesAsTexturesDirty;
  45532. /** @hidden */
  45533. _markAllSubMeshesAsTexturesDirty(): void;
  45534. /**
  45535. * Instantiate a new istance of anisotropy configuration.
  45536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45537. */
  45538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45539. /**
  45540. * Specifies that the submesh is ready to be used.
  45541. * @param defines the list of "defines" to update.
  45542. * @param scene defines the scene the material belongs to.
  45543. * @returns - boolean indicating that the submesh is ready or not.
  45544. */
  45545. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45546. /**
  45547. * Checks to see if a texture is used in the material.
  45548. * @param defines the list of "defines" to update.
  45549. * @param mesh the mesh we are preparing the defines for.
  45550. * @param scene defines the scene the material belongs to.
  45551. */
  45552. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45553. /**
  45554. * Binds the material data.
  45555. * @param uniformBuffer defines the Uniform buffer to fill in.
  45556. * @param scene defines the scene the material belongs to.
  45557. * @param isFrozen defines wether the material is frozen or not.
  45558. */
  45559. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45560. /**
  45561. * Checks to see if a texture is used in the material.
  45562. * @param texture - Base texture to use.
  45563. * @returns - Boolean specifying if a texture is used in the material.
  45564. */
  45565. hasTexture(texture: BaseTexture): boolean;
  45566. /**
  45567. * Returns an array of the actively used textures.
  45568. * @param activeTextures Array of BaseTextures
  45569. */
  45570. getActiveTextures(activeTextures: BaseTexture[]): void;
  45571. /**
  45572. * Returns the animatable textures.
  45573. * @param animatables Array of animatable textures.
  45574. */
  45575. getAnimatables(animatables: IAnimatable[]): void;
  45576. /**
  45577. * Disposes the resources of the material.
  45578. * @param forceDisposeTextures - Forces the disposal of all textures.
  45579. */
  45580. dispose(forceDisposeTextures?: boolean): void;
  45581. /**
  45582. * Get the current class name of the texture useful for serialization or dynamic coding.
  45583. * @returns "PBRAnisotropicConfiguration"
  45584. */
  45585. getClassName(): string;
  45586. /**
  45587. * Add fallbacks to the effect fallbacks list.
  45588. * @param defines defines the Base texture to use.
  45589. * @param fallbacks defines the current fallback list.
  45590. * @param currentRank defines the current fallback rank.
  45591. * @returns the new fallback rank.
  45592. */
  45593. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45594. /**
  45595. * Add the required uniforms to the current list.
  45596. * @param uniforms defines the current uniform list.
  45597. */
  45598. static AddUniforms(uniforms: string[]): void;
  45599. /**
  45600. * Add the required uniforms to the current buffer.
  45601. * @param uniformBuffer defines the current uniform buffer.
  45602. */
  45603. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45604. /**
  45605. * Add the required samplers to the current list.
  45606. * @param samplers defines the current sampler list.
  45607. */
  45608. static AddSamplers(samplers: string[]): void;
  45609. /**
  45610. * Makes a duplicate of the current configuration into another one.
  45611. * @param anisotropicConfiguration define the config where to copy the info
  45612. */
  45613. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45614. /**
  45615. * Serializes this anisotropy configuration.
  45616. * @returns - An object with the serialized config.
  45617. */
  45618. serialize(): any;
  45619. /**
  45620. * Parses a anisotropy Configuration from a serialized object.
  45621. * @param source - Serialized object.
  45622. */
  45623. parse(source: any): void;
  45624. }
  45625. }
  45626. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45627. /**
  45628. * @hidden
  45629. */
  45630. export interface IMaterialBRDFDefines {
  45631. BRDF_V_HEIGHT_CORRELATED: boolean;
  45632. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45633. /** @hidden */
  45634. _areMiscDirty: boolean;
  45635. }
  45636. /**
  45637. * Define the code related to the BRDF parameters of the pbr material.
  45638. */
  45639. export class PBRBRDFConfiguration {
  45640. /**
  45641. * Default value used for the energy conservation.
  45642. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45643. */
  45644. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45645. /**
  45646. * Default value used for the Smith Visibility Height Correlated mode.
  45647. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45648. */
  45649. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45650. private _useEnergyConservation;
  45651. /**
  45652. * Defines if the material uses energy conservation.
  45653. */
  45654. useEnergyConservation: boolean;
  45655. private _useSmithVisibilityHeightCorrelated;
  45656. /**
  45657. * LEGACY Mode set to false
  45658. * Defines if the material uses height smith correlated visibility term.
  45659. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45660. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45661. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45662. * Not relying on height correlated will also disable energy conservation.
  45663. */
  45664. useSmithVisibilityHeightCorrelated: boolean;
  45665. /** @hidden */
  45666. private _internalMarkAllSubMeshesAsMiscDirty;
  45667. /** @hidden */
  45668. _markAllSubMeshesAsMiscDirty(): void;
  45669. /**
  45670. * Instantiate a new istance of clear coat configuration.
  45671. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45672. */
  45673. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45674. /**
  45675. * Checks to see if a texture is used in the material.
  45676. * @param defines the list of "defines" to update.
  45677. */
  45678. prepareDefines(defines: IMaterialBRDFDefines): void;
  45679. /**
  45680. * Get the current class name of the texture useful for serialization or dynamic coding.
  45681. * @returns "PBRClearCoatConfiguration"
  45682. */
  45683. getClassName(): string;
  45684. /**
  45685. * Makes a duplicate of the current configuration into another one.
  45686. * @param brdfConfiguration define the config where to copy the info
  45687. */
  45688. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45689. /**
  45690. * Serializes this BRDF configuration.
  45691. * @returns - An object with the serialized config.
  45692. */
  45693. serialize(): any;
  45694. /**
  45695. * Parses a BRDF Configuration from a serialized object.
  45696. * @param source - Serialized object.
  45697. */
  45698. parse(source: any): void;
  45699. }
  45700. }
  45701. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45702. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45703. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45704. import { Color3 } from "babylonjs/Maths/math";
  45705. import { Scene } from "babylonjs/scene";
  45706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45707. import { IAnimatable } from "babylonjs/Misc/tools";
  45708. import { Nullable } from "babylonjs/types";
  45709. /**
  45710. * @hidden
  45711. */
  45712. export interface IMaterialSheenDefines {
  45713. SHEEN: boolean;
  45714. SHEEN_TEXTURE: boolean;
  45715. SHEEN_TEXTUREDIRECTUV: number;
  45716. SHEEN_LINKWITHALBEDO: boolean;
  45717. /** @hidden */
  45718. _areTexturesDirty: boolean;
  45719. }
  45720. /**
  45721. * Define the code related to the Sheen parameters of the pbr material.
  45722. */
  45723. export class PBRSheenConfiguration {
  45724. private _isEnabled;
  45725. /**
  45726. * Defines if the material uses sheen.
  45727. */
  45728. isEnabled: boolean;
  45729. private _linkSheenWithAlbedo;
  45730. /**
  45731. * Defines if the sheen is linked to the sheen color.
  45732. */
  45733. linkSheenWithAlbedo: boolean;
  45734. /**
  45735. * Defines the sheen intensity.
  45736. */
  45737. intensity: number;
  45738. /**
  45739. * Defines the sheen color.
  45740. */
  45741. color: Color3;
  45742. private _texture;
  45743. /**
  45744. * Stores the sheen tint values in a texture.
  45745. * rgb is tint
  45746. * a is a intensity
  45747. */
  45748. texture: Nullable<BaseTexture>;
  45749. /** @hidden */
  45750. private _internalMarkAllSubMeshesAsTexturesDirty;
  45751. /** @hidden */
  45752. _markAllSubMeshesAsTexturesDirty(): void;
  45753. /**
  45754. * Instantiate a new istance of clear coat configuration.
  45755. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45756. */
  45757. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45758. /**
  45759. * Specifies that the submesh is ready to be used.
  45760. * @param defines the list of "defines" to update.
  45761. * @param scene defines the scene the material belongs to.
  45762. * @returns - boolean indicating that the submesh is ready or not.
  45763. */
  45764. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45765. /**
  45766. * Checks to see if a texture is used in the material.
  45767. * @param defines the list of "defines" to update.
  45768. * @param scene defines the scene the material belongs to.
  45769. */
  45770. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45771. /**
  45772. * Binds the material data.
  45773. * @param uniformBuffer defines the Uniform buffer to fill in.
  45774. * @param scene defines the scene the material belongs to.
  45775. * @param isFrozen defines wether the material is frozen or not.
  45776. */
  45777. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45778. /**
  45779. * Checks to see if a texture is used in the material.
  45780. * @param texture - Base texture to use.
  45781. * @returns - Boolean specifying if a texture is used in the material.
  45782. */
  45783. hasTexture(texture: BaseTexture): boolean;
  45784. /**
  45785. * Returns an array of the actively used textures.
  45786. * @param activeTextures Array of BaseTextures
  45787. */
  45788. getActiveTextures(activeTextures: BaseTexture[]): void;
  45789. /**
  45790. * Returns the animatable textures.
  45791. * @param animatables Array of animatable textures.
  45792. */
  45793. getAnimatables(animatables: IAnimatable[]): void;
  45794. /**
  45795. * Disposes the resources of the material.
  45796. * @param forceDisposeTextures - Forces the disposal of all textures.
  45797. */
  45798. dispose(forceDisposeTextures?: boolean): void;
  45799. /**
  45800. * Get the current class name of the texture useful for serialization or dynamic coding.
  45801. * @returns "PBRSheenConfiguration"
  45802. */
  45803. getClassName(): string;
  45804. /**
  45805. * Add fallbacks to the effect fallbacks list.
  45806. * @param defines defines the Base texture to use.
  45807. * @param fallbacks defines the current fallback list.
  45808. * @param currentRank defines the current fallback rank.
  45809. * @returns the new fallback rank.
  45810. */
  45811. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45812. /**
  45813. * Add the required uniforms to the current list.
  45814. * @param uniforms defines the current uniform list.
  45815. */
  45816. static AddUniforms(uniforms: string[]): void;
  45817. /**
  45818. * Add the required uniforms to the current buffer.
  45819. * @param uniformBuffer defines the current uniform buffer.
  45820. */
  45821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45822. /**
  45823. * Add the required samplers to the current list.
  45824. * @param samplers defines the current sampler list.
  45825. */
  45826. static AddSamplers(samplers: string[]): void;
  45827. /**
  45828. * Makes a duplicate of the current configuration into another one.
  45829. * @param sheenConfiguration define the config where to copy the info
  45830. */
  45831. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45832. /**
  45833. * Serializes this BRDF configuration.
  45834. * @returns - An object with the serialized config.
  45835. */
  45836. serialize(): any;
  45837. /**
  45838. * Parses a Sheen Configuration from a serialized object.
  45839. * @param source - Serialized object.
  45840. */
  45841. parse(source: any): void;
  45842. }
  45843. }
  45844. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45845. /** @hidden */
  45846. export var pbrFragmentDeclaration: {
  45847. name: string;
  45848. shader: string;
  45849. };
  45850. }
  45851. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45852. /** @hidden */
  45853. export var pbrUboDeclaration: {
  45854. name: string;
  45855. shader: string;
  45856. };
  45857. }
  45858. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45859. /** @hidden */
  45860. export var pbrFragmentExtraDeclaration: {
  45861. name: string;
  45862. shader: string;
  45863. };
  45864. }
  45865. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45866. /** @hidden */
  45867. export var pbrFragmentSamplersDeclaration: {
  45868. name: string;
  45869. shader: string;
  45870. };
  45871. }
  45872. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45873. /** @hidden */
  45874. export var pbrHelperFunctions: {
  45875. name: string;
  45876. shader: string;
  45877. };
  45878. }
  45879. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45880. /** @hidden */
  45881. export var harmonicsFunctions: {
  45882. name: string;
  45883. shader: string;
  45884. };
  45885. }
  45886. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45887. /** @hidden */
  45888. export var pbrDirectLightingSetupFunctions: {
  45889. name: string;
  45890. shader: string;
  45891. };
  45892. }
  45893. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45894. /** @hidden */
  45895. export var pbrDirectLightingFalloffFunctions: {
  45896. name: string;
  45897. shader: string;
  45898. };
  45899. }
  45900. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45901. /** @hidden */
  45902. export var pbrBRDFFunctions: {
  45903. name: string;
  45904. shader: string;
  45905. };
  45906. }
  45907. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45908. /** @hidden */
  45909. export var pbrDirectLightingFunctions: {
  45910. name: string;
  45911. shader: string;
  45912. };
  45913. }
  45914. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45915. /** @hidden */
  45916. export var pbrIBLFunctions: {
  45917. name: string;
  45918. shader: string;
  45919. };
  45920. }
  45921. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45922. /** @hidden */
  45923. export var pbrDebug: {
  45924. name: string;
  45925. shader: string;
  45926. };
  45927. }
  45928. declare module "babylonjs/Shaders/pbr.fragment" {
  45929. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45930. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45931. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45932. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45933. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45934. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45935. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45936. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45937. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45938. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45939. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45940. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45941. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45942. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45943. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45944. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45945. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45946. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45947. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45948. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45949. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45950. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45951. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45952. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45953. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45954. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45955. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45956. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45957. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45958. /** @hidden */
  45959. export var pbrPixelShader: {
  45960. name: string;
  45961. shader: string;
  45962. };
  45963. }
  45964. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45965. /** @hidden */
  45966. export var pbrVertexDeclaration: {
  45967. name: string;
  45968. shader: string;
  45969. };
  45970. }
  45971. declare module "babylonjs/Shaders/pbr.vertex" {
  45972. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45973. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45974. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45975. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45976. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45977. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45978. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45979. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45980. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45981. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45982. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45984. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45985. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45987. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45988. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45989. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45990. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45991. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45992. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45993. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45994. /** @hidden */
  45995. export var pbrVertexShader: {
  45996. name: string;
  45997. shader: string;
  45998. };
  45999. }
  46000. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46001. import { IAnimatable } from "babylonjs/Misc/tools";
  46002. import { Nullable } from "babylonjs/types";
  46003. import { Scene } from "babylonjs/scene";
  46004. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46005. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46007. import { Mesh } from "babylonjs/Meshes/mesh";
  46008. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46009. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46010. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46011. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46012. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46013. import { Material } from "babylonjs/Materials/material";
  46014. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46015. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46017. import "babylonjs/Shaders/pbr.fragment";
  46018. import "babylonjs/Shaders/pbr.vertex";
  46019. /**
  46020. * Manages the defines for the PBR Material.
  46021. * @hidden
  46022. */
  46023. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  46024. PBR: boolean;
  46025. MAINUV1: boolean;
  46026. MAINUV2: boolean;
  46027. UV1: boolean;
  46028. UV2: boolean;
  46029. ALBEDO: boolean;
  46030. ALBEDODIRECTUV: number;
  46031. VERTEXCOLOR: boolean;
  46032. AMBIENT: boolean;
  46033. AMBIENTDIRECTUV: number;
  46034. AMBIENTINGRAYSCALE: boolean;
  46035. OPACITY: boolean;
  46036. VERTEXALPHA: boolean;
  46037. OPACITYDIRECTUV: number;
  46038. OPACITYRGB: boolean;
  46039. ALPHATEST: boolean;
  46040. DEPTHPREPASS: boolean;
  46041. ALPHABLEND: boolean;
  46042. ALPHAFROMALBEDO: boolean;
  46043. ALPHATESTVALUE: string;
  46044. SPECULAROVERALPHA: boolean;
  46045. RADIANCEOVERALPHA: boolean;
  46046. ALPHAFRESNEL: boolean;
  46047. LINEARALPHAFRESNEL: boolean;
  46048. PREMULTIPLYALPHA: boolean;
  46049. EMISSIVE: boolean;
  46050. EMISSIVEDIRECTUV: number;
  46051. REFLECTIVITY: boolean;
  46052. REFLECTIVITYDIRECTUV: number;
  46053. SPECULARTERM: boolean;
  46054. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46055. MICROSURFACEAUTOMATIC: boolean;
  46056. LODBASEDMICROSFURACE: boolean;
  46057. MICROSURFACEMAP: boolean;
  46058. MICROSURFACEMAPDIRECTUV: number;
  46059. METALLICWORKFLOW: boolean;
  46060. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46061. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46062. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46063. AOSTOREINMETALMAPRED: boolean;
  46064. ENVIRONMENTBRDF: boolean;
  46065. ENVIRONMENTBRDF_RGBD: boolean;
  46066. NORMAL: boolean;
  46067. TANGENT: boolean;
  46068. BUMP: boolean;
  46069. BUMPDIRECTUV: number;
  46070. OBJECTSPACE_NORMALMAP: boolean;
  46071. PARALLAX: boolean;
  46072. PARALLAXOCCLUSION: boolean;
  46073. NORMALXYSCALE: boolean;
  46074. LIGHTMAP: boolean;
  46075. LIGHTMAPDIRECTUV: number;
  46076. USELIGHTMAPASSHADOWMAP: boolean;
  46077. GAMMALIGHTMAP: boolean;
  46078. REFLECTION: boolean;
  46079. REFLECTIONMAP_3D: boolean;
  46080. REFLECTIONMAP_SPHERICAL: boolean;
  46081. REFLECTIONMAP_PLANAR: boolean;
  46082. REFLECTIONMAP_CUBIC: boolean;
  46083. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46084. REFLECTIONMAP_PROJECTION: boolean;
  46085. REFLECTIONMAP_SKYBOX: boolean;
  46086. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46087. REFLECTIONMAP_EXPLICIT: boolean;
  46088. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46089. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46090. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46091. INVERTCUBICMAP: boolean;
  46092. USESPHERICALFROMREFLECTIONMAP: boolean;
  46093. USESPHERICALINVERTEX: boolean;
  46094. REFLECTIONMAP_OPPOSITEZ: boolean;
  46095. LODINREFLECTIONALPHA: boolean;
  46096. GAMMAREFLECTION: boolean;
  46097. RGBDREFLECTION: boolean;
  46098. RADIANCEOCCLUSION: boolean;
  46099. HORIZONOCCLUSION: boolean;
  46100. REFRACTION: boolean;
  46101. REFRACTIONMAP_3D: boolean;
  46102. REFRACTIONMAP_OPPOSITEZ: boolean;
  46103. LODINREFRACTIONALPHA: boolean;
  46104. GAMMAREFRACTION: boolean;
  46105. RGBDREFRACTION: boolean;
  46106. LINKREFRACTIONTOTRANSPARENCY: boolean;
  46107. INSTANCES: boolean;
  46108. NUM_BONE_INFLUENCERS: number;
  46109. BonesPerMesh: number;
  46110. BONETEXTURE: boolean;
  46111. NONUNIFORMSCALING: boolean;
  46112. MORPHTARGETS: boolean;
  46113. MORPHTARGETS_NORMAL: boolean;
  46114. MORPHTARGETS_TANGENT: boolean;
  46115. NUM_MORPH_INFLUENCERS: number;
  46116. IMAGEPROCESSING: boolean;
  46117. VIGNETTE: boolean;
  46118. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46119. VIGNETTEBLENDMODEOPAQUE: boolean;
  46120. TONEMAPPING: boolean;
  46121. TONEMAPPING_ACES: boolean;
  46122. CONTRAST: boolean;
  46123. COLORCURVES: boolean;
  46124. COLORGRADING: boolean;
  46125. COLORGRADING3D: boolean;
  46126. SAMPLER3DGREENDEPTH: boolean;
  46127. SAMPLER3DBGRMAP: boolean;
  46128. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46129. EXPOSURE: boolean;
  46130. MULTIVIEW: boolean;
  46131. USEPHYSICALLIGHTFALLOFF: boolean;
  46132. USEGLTFLIGHTFALLOFF: boolean;
  46133. TWOSIDEDLIGHTING: boolean;
  46134. SHADOWFLOAT: boolean;
  46135. CLIPPLANE: boolean;
  46136. CLIPPLANE2: boolean;
  46137. CLIPPLANE3: boolean;
  46138. CLIPPLANE4: boolean;
  46139. POINTSIZE: boolean;
  46140. FOG: boolean;
  46141. LOGARITHMICDEPTH: boolean;
  46142. FORCENORMALFORWARD: boolean;
  46143. SPECULARAA: boolean;
  46144. CLEARCOAT: boolean;
  46145. CLEARCOAT_DEFAULTIOR: boolean;
  46146. CLEARCOAT_TEXTURE: boolean;
  46147. CLEARCOAT_TEXTUREDIRECTUV: number;
  46148. CLEARCOAT_BUMP: boolean;
  46149. CLEARCOAT_BUMPDIRECTUV: number;
  46150. CLEARCOAT_TINT: boolean;
  46151. CLEARCOAT_TINT_TEXTURE: boolean;
  46152. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46153. ANISOTROPIC: boolean;
  46154. ANISOTROPIC_TEXTURE: boolean;
  46155. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46156. BRDF_V_HEIGHT_CORRELATED: boolean;
  46157. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46158. SHEEN: boolean;
  46159. SHEEN_TEXTURE: boolean;
  46160. SHEEN_TEXTUREDIRECTUV: number;
  46161. SHEEN_LINKWITHALBEDO: boolean;
  46162. UNLIT: boolean;
  46163. DEBUGMODE: number;
  46164. /**
  46165. * Initializes the PBR Material defines.
  46166. */
  46167. constructor();
  46168. /**
  46169. * Resets the PBR Material defines.
  46170. */
  46171. reset(): void;
  46172. }
  46173. /**
  46174. * The Physically based material base class of BJS.
  46175. *
  46176. * This offers the main features of a standard PBR material.
  46177. * For more information, please refer to the documentation :
  46178. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46179. */
  46180. export abstract class PBRBaseMaterial extends PushMaterial {
  46181. /**
  46182. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46183. */
  46184. static readonly PBRMATERIAL_OPAQUE: number;
  46185. /**
  46186. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46187. */
  46188. static readonly PBRMATERIAL_ALPHATEST: number;
  46189. /**
  46190. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46191. */
  46192. static readonly PBRMATERIAL_ALPHABLEND: number;
  46193. /**
  46194. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46195. * They are also discarded below the alpha cutoff threshold to improve performances.
  46196. */
  46197. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46198. /**
  46199. * Defines the default value of how much AO map is occluding the analytical lights
  46200. * (point spot...).
  46201. */
  46202. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46203. /**
  46204. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46205. */
  46206. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46207. /**
  46208. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46209. * to enhance interoperability with other engines.
  46210. */
  46211. static readonly LIGHTFALLOFF_GLTF: number;
  46212. /**
  46213. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46214. * to enhance interoperability with other materials.
  46215. */
  46216. static readonly LIGHTFALLOFF_STANDARD: number;
  46217. /**
  46218. * Intensity of the direct lights e.g. the four lights available in your scene.
  46219. * This impacts both the direct diffuse and specular highlights.
  46220. */
  46221. protected _directIntensity: number;
  46222. /**
  46223. * Intensity of the emissive part of the material.
  46224. * This helps controlling the emissive effect without modifying the emissive color.
  46225. */
  46226. protected _emissiveIntensity: number;
  46227. /**
  46228. * Intensity of the environment e.g. how much the environment will light the object
  46229. * either through harmonics for rough material or through the refelction for shiny ones.
  46230. */
  46231. protected _environmentIntensity: number;
  46232. /**
  46233. * This is a special control allowing the reduction of the specular highlights coming from the
  46234. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46235. */
  46236. protected _specularIntensity: number;
  46237. /**
  46238. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46239. */
  46240. private _lightingInfos;
  46241. /**
  46242. * Debug Control allowing disabling the bump map on this material.
  46243. */
  46244. protected _disableBumpMap: boolean;
  46245. /**
  46246. * AKA Diffuse Texture in standard nomenclature.
  46247. */
  46248. protected _albedoTexture: BaseTexture;
  46249. /**
  46250. * AKA Occlusion Texture in other nomenclature.
  46251. */
  46252. protected _ambientTexture: BaseTexture;
  46253. /**
  46254. * AKA Occlusion Texture Intensity in other nomenclature.
  46255. */
  46256. protected _ambientTextureStrength: number;
  46257. /**
  46258. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46259. * 1 means it completely occludes it
  46260. * 0 mean it has no impact
  46261. */
  46262. protected _ambientTextureImpactOnAnalyticalLights: number;
  46263. /**
  46264. * Stores the alpha values in a texture.
  46265. */
  46266. protected _opacityTexture: BaseTexture;
  46267. /**
  46268. * Stores the reflection values in a texture.
  46269. */
  46270. protected _reflectionTexture: BaseTexture;
  46271. /**
  46272. * Stores the refraction values in a texture.
  46273. */
  46274. protected _refractionTexture: BaseTexture;
  46275. /**
  46276. * Stores the emissive values in a texture.
  46277. */
  46278. protected _emissiveTexture: BaseTexture;
  46279. /**
  46280. * AKA Specular texture in other nomenclature.
  46281. */
  46282. protected _reflectivityTexture: BaseTexture;
  46283. /**
  46284. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46285. */
  46286. protected _metallicTexture: BaseTexture;
  46287. /**
  46288. * Specifies the metallic scalar of the metallic/roughness workflow.
  46289. * Can also be used to scale the metalness values of the metallic texture.
  46290. */
  46291. protected _metallic: Nullable<number>;
  46292. /**
  46293. * Specifies the roughness scalar of the metallic/roughness workflow.
  46294. * Can also be used to scale the roughness values of the metallic texture.
  46295. */
  46296. protected _roughness: Nullable<number>;
  46297. /**
  46298. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46299. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46300. */
  46301. protected _microSurfaceTexture: BaseTexture;
  46302. /**
  46303. * Stores surface normal data used to displace a mesh in a texture.
  46304. */
  46305. protected _bumpTexture: BaseTexture;
  46306. /**
  46307. * Stores the pre-calculated light information of a mesh in a texture.
  46308. */
  46309. protected _lightmapTexture: BaseTexture;
  46310. /**
  46311. * The color of a material in ambient lighting.
  46312. */
  46313. protected _ambientColor: Color3;
  46314. /**
  46315. * AKA Diffuse Color in other nomenclature.
  46316. */
  46317. protected _albedoColor: Color3;
  46318. /**
  46319. * AKA Specular Color in other nomenclature.
  46320. */
  46321. protected _reflectivityColor: Color3;
  46322. /**
  46323. * The color applied when light is reflected from a material.
  46324. */
  46325. protected _reflectionColor: Color3;
  46326. /**
  46327. * The color applied when light is emitted from a material.
  46328. */
  46329. protected _emissiveColor: Color3;
  46330. /**
  46331. * AKA Glossiness in other nomenclature.
  46332. */
  46333. protected _microSurface: number;
  46334. /**
  46335. * source material index of refraction (IOR)' / 'destination material IOR.
  46336. */
  46337. protected _indexOfRefraction: number;
  46338. /**
  46339. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46340. */
  46341. protected _invertRefractionY: boolean;
  46342. /**
  46343. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46344. * Materials half opaque for instance using refraction could benefit from this control.
  46345. */
  46346. protected _linkRefractionWithTransparency: boolean;
  46347. /**
  46348. * Specifies that the material will use the light map as a show map.
  46349. */
  46350. protected _useLightmapAsShadowmap: boolean;
  46351. /**
  46352. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46353. * makes the reflect vector face the model (under horizon).
  46354. */
  46355. protected _useHorizonOcclusion: boolean;
  46356. /**
  46357. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46358. * too much the area relying on ambient texture to define their ambient occlusion.
  46359. */
  46360. protected _useRadianceOcclusion: boolean;
  46361. /**
  46362. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46363. */
  46364. protected _useAlphaFromAlbedoTexture: boolean;
  46365. /**
  46366. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46367. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46368. */
  46369. protected _useSpecularOverAlpha: boolean;
  46370. /**
  46371. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46372. */
  46373. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46374. /**
  46375. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46376. */
  46377. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46378. /**
  46379. * Specifies if the metallic texture contains the roughness information in its green channel.
  46380. */
  46381. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46382. /**
  46383. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46384. */
  46385. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46386. /**
  46387. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46388. */
  46389. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46390. /**
  46391. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46392. */
  46393. protected _useAmbientInGrayScale: boolean;
  46394. /**
  46395. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46396. * The material will try to infer what glossiness each pixel should be.
  46397. */
  46398. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46399. /**
  46400. * Defines the falloff type used in this material.
  46401. * It by default is Physical.
  46402. */
  46403. protected _lightFalloff: number;
  46404. /**
  46405. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46406. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46407. */
  46408. protected _useRadianceOverAlpha: boolean;
  46409. /**
  46410. * Allows using an object space normal map (instead of tangent space).
  46411. */
  46412. protected _useObjectSpaceNormalMap: boolean;
  46413. /**
  46414. * Allows using the bump map in parallax mode.
  46415. */
  46416. protected _useParallax: boolean;
  46417. /**
  46418. * Allows using the bump map in parallax occlusion mode.
  46419. */
  46420. protected _useParallaxOcclusion: boolean;
  46421. /**
  46422. * Controls the scale bias of the parallax mode.
  46423. */
  46424. protected _parallaxScaleBias: number;
  46425. /**
  46426. * If sets to true, disables all the lights affecting the material.
  46427. */
  46428. protected _disableLighting: boolean;
  46429. /**
  46430. * Number of Simultaneous lights allowed on the material.
  46431. */
  46432. protected _maxSimultaneousLights: number;
  46433. /**
  46434. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46435. */
  46436. protected _invertNormalMapX: boolean;
  46437. /**
  46438. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46439. */
  46440. protected _invertNormalMapY: boolean;
  46441. /**
  46442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46443. */
  46444. protected _twoSidedLighting: boolean;
  46445. /**
  46446. * Defines the alpha limits in alpha test mode.
  46447. */
  46448. protected _alphaCutOff: number;
  46449. /**
  46450. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46451. */
  46452. protected _forceAlphaTest: boolean;
  46453. /**
  46454. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46455. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46456. */
  46457. protected _useAlphaFresnel: boolean;
  46458. /**
  46459. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46460. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46461. */
  46462. protected _useLinearAlphaFresnel: boolean;
  46463. /**
  46464. * The transparency mode of the material.
  46465. */
  46466. protected _transparencyMode: Nullable<number>;
  46467. /**
  46468. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46469. * from cos thetav and roughness:
  46470. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46471. */
  46472. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46473. /**
  46474. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46475. */
  46476. protected _forceIrradianceInFragment: boolean;
  46477. /**
  46478. * Force normal to face away from face.
  46479. */
  46480. protected _forceNormalForward: boolean;
  46481. /**
  46482. * Enables specular anti aliasing in the PBR shader.
  46483. * It will both interacts on the Geometry for analytical and IBL lighting.
  46484. * It also prefilter the roughness map based on the bump values.
  46485. */
  46486. protected _enableSpecularAntiAliasing: boolean;
  46487. /**
  46488. * Default configuration related to image processing available in the PBR Material.
  46489. */
  46490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46491. /**
  46492. * Keep track of the image processing observer to allow dispose and replace.
  46493. */
  46494. private _imageProcessingObserver;
  46495. /**
  46496. * Attaches a new image processing configuration to the PBR Material.
  46497. * @param configuration
  46498. */
  46499. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46500. /**
  46501. * Stores the available render targets.
  46502. */
  46503. private _renderTargets;
  46504. /**
  46505. * Sets the global ambient color for the material used in lighting calculations.
  46506. */
  46507. private _globalAmbientColor;
  46508. /**
  46509. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46510. */
  46511. private _useLogarithmicDepth;
  46512. /**
  46513. * If set to true, no lighting calculations will be applied.
  46514. */
  46515. private _unlit;
  46516. private _debugMode;
  46517. /**
  46518. * @hidden
  46519. * This is reserved for the inspector.
  46520. * Defines the material debug mode.
  46521. * It helps seeing only some components of the material while troubleshooting.
  46522. */
  46523. debugMode: number;
  46524. /**
  46525. * @hidden
  46526. * This is reserved for the inspector.
  46527. * Specify from where on screen the debug mode should start.
  46528. * The value goes from -1 (full screen) to 1 (not visible)
  46529. * It helps with side by side comparison against the final render
  46530. * This defaults to -1
  46531. */
  46532. private debugLimit;
  46533. /**
  46534. * @hidden
  46535. * This is reserved for the inspector.
  46536. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46537. * You can use the factor to better multiply the final value.
  46538. */
  46539. private debugFactor;
  46540. /**
  46541. * Defines the clear coat layer parameters for the material.
  46542. */
  46543. readonly clearCoat: PBRClearCoatConfiguration;
  46544. /**
  46545. * Defines the anisotropic parameters for the material.
  46546. */
  46547. readonly anisotropy: PBRAnisotropicConfiguration;
  46548. /**
  46549. * Defines the BRDF parameters for the material.
  46550. */
  46551. readonly brdf: PBRBRDFConfiguration;
  46552. /**
  46553. * Defines the Sheen parameters for the material.
  46554. */
  46555. readonly sheen: PBRSheenConfiguration;
  46556. /**
  46557. * Custom callback helping to override the default shader used in the material.
  46558. */
  46559. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46560. /**
  46561. * Instantiates a new PBRMaterial instance.
  46562. *
  46563. * @param name The material name
  46564. * @param scene The scene the material will be use in.
  46565. */
  46566. constructor(name: string, scene: Scene);
  46567. /**
  46568. * Gets a boolean indicating that current material needs to register RTT
  46569. */
  46570. readonly hasRenderTargetTextures: boolean;
  46571. /**
  46572. * Gets the name of the material class.
  46573. */
  46574. getClassName(): string;
  46575. /**
  46576. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46577. */
  46578. /**
  46579. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46580. */
  46581. useLogarithmicDepth: boolean;
  46582. /**
  46583. * Gets the current transparency mode.
  46584. */
  46585. /**
  46586. * Sets the transparency mode of the material.
  46587. *
  46588. * | Value | Type | Description |
  46589. * | ----- | ----------------------------------- | ----------- |
  46590. * | 0 | OPAQUE | |
  46591. * | 1 | ALPHATEST | |
  46592. * | 2 | ALPHABLEND | |
  46593. * | 3 | ALPHATESTANDBLEND | |
  46594. *
  46595. */
  46596. transparencyMode: Nullable<number>;
  46597. /**
  46598. * Returns true if alpha blending should be disabled.
  46599. */
  46600. private readonly _disableAlphaBlending;
  46601. /**
  46602. * Specifies whether or not this material should be rendered in alpha blend mode.
  46603. */
  46604. needAlphaBlending(): boolean;
  46605. /**
  46606. * Specifies if the mesh will require alpha blending.
  46607. * @param mesh - BJS mesh.
  46608. */
  46609. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46610. /**
  46611. * Specifies whether or not this material should be rendered in alpha test mode.
  46612. */
  46613. needAlphaTesting(): boolean;
  46614. /**
  46615. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46616. */
  46617. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46618. /**
  46619. * Gets the texture used for the alpha test.
  46620. */
  46621. getAlphaTestTexture(): BaseTexture;
  46622. /**
  46623. * Specifies that the submesh is ready to be used.
  46624. * @param mesh - BJS mesh.
  46625. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46626. * @param useInstances - Specifies that instances should be used.
  46627. * @returns - boolean indicating that the submesh is ready or not.
  46628. */
  46629. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46630. /**
  46631. * Specifies if the material uses metallic roughness workflow.
  46632. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46633. */
  46634. isMetallicWorkflow(): boolean;
  46635. private _prepareEffect;
  46636. private _prepareDefines;
  46637. /**
  46638. * Force shader compilation
  46639. */
  46640. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46641. clipPlane: boolean;
  46642. }>): void;
  46643. /**
  46644. * Initializes the uniform buffer layout for the shader.
  46645. */
  46646. buildUniformLayout(): void;
  46647. /**
  46648. * Unbinds the textures.
  46649. */
  46650. unbind(): void;
  46651. /**
  46652. * Binds the submesh data.
  46653. * @param world - The world matrix.
  46654. * @param mesh - The BJS mesh.
  46655. * @param subMesh - A submesh of the BJS mesh.
  46656. */
  46657. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46658. /**
  46659. * Returns the animatable textures.
  46660. * @returns - Array of animatable textures.
  46661. */
  46662. getAnimatables(): IAnimatable[];
  46663. /**
  46664. * Returns the texture used for reflections.
  46665. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46666. */
  46667. private _getReflectionTexture;
  46668. /**
  46669. * Returns the texture used for refraction or null if none is used.
  46670. * @returns - Refection texture if present. If no refraction texture and refraction
  46671. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46672. */
  46673. private _getRefractionTexture;
  46674. /**
  46675. * Returns an array of the actively used textures.
  46676. * @returns - Array of BaseTextures
  46677. */
  46678. getActiveTextures(): BaseTexture[];
  46679. /**
  46680. * Checks to see if a texture is used in the material.
  46681. * @param texture - Base texture to use.
  46682. * @returns - Boolean specifying if a texture is used in the material.
  46683. */
  46684. hasTexture(texture: BaseTexture): boolean;
  46685. /**
  46686. * Disposes the resources of the material.
  46687. * @param forceDisposeEffect - Forces the disposal of effects.
  46688. * @param forceDisposeTextures - Forces the disposal of all textures.
  46689. */
  46690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46691. }
  46692. }
  46693. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46694. import { Nullable } from "babylonjs/types";
  46695. import { Scene } from "babylonjs/scene";
  46696. import { Color3 } from "babylonjs/Maths/math";
  46697. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46698. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46700. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46701. /**
  46702. * The Physically based material of BJS.
  46703. *
  46704. * This offers the main features of a standard PBR material.
  46705. * For more information, please refer to the documentation :
  46706. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46707. */
  46708. export class PBRMaterial extends PBRBaseMaterial {
  46709. /**
  46710. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46711. */
  46712. static readonly PBRMATERIAL_OPAQUE: number;
  46713. /**
  46714. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46715. */
  46716. static readonly PBRMATERIAL_ALPHATEST: number;
  46717. /**
  46718. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46719. */
  46720. static readonly PBRMATERIAL_ALPHABLEND: number;
  46721. /**
  46722. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46723. * They are also discarded below the alpha cutoff threshold to improve performances.
  46724. */
  46725. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46726. /**
  46727. * Defines the default value of how much AO map is occluding the analytical lights
  46728. * (point spot...).
  46729. */
  46730. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46731. /**
  46732. * Intensity of the direct lights e.g. the four lights available in your scene.
  46733. * This impacts both the direct diffuse and specular highlights.
  46734. */
  46735. directIntensity: number;
  46736. /**
  46737. * Intensity of the emissive part of the material.
  46738. * This helps controlling the emissive effect without modifying the emissive color.
  46739. */
  46740. emissiveIntensity: number;
  46741. /**
  46742. * Intensity of the environment e.g. how much the environment will light the object
  46743. * either through harmonics for rough material or through the refelction for shiny ones.
  46744. */
  46745. environmentIntensity: number;
  46746. /**
  46747. * This is a special control allowing the reduction of the specular highlights coming from the
  46748. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46749. */
  46750. specularIntensity: number;
  46751. /**
  46752. * Debug Control allowing disabling the bump map on this material.
  46753. */
  46754. disableBumpMap: boolean;
  46755. /**
  46756. * AKA Diffuse Texture in standard nomenclature.
  46757. */
  46758. albedoTexture: BaseTexture;
  46759. /**
  46760. * AKA Occlusion Texture in other nomenclature.
  46761. */
  46762. ambientTexture: BaseTexture;
  46763. /**
  46764. * AKA Occlusion Texture Intensity in other nomenclature.
  46765. */
  46766. ambientTextureStrength: number;
  46767. /**
  46768. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46769. * 1 means it completely occludes it
  46770. * 0 mean it has no impact
  46771. */
  46772. ambientTextureImpactOnAnalyticalLights: number;
  46773. /**
  46774. * Stores the alpha values in a texture.
  46775. */
  46776. opacityTexture: BaseTexture;
  46777. /**
  46778. * Stores the reflection values in a texture.
  46779. */
  46780. reflectionTexture: Nullable<BaseTexture>;
  46781. /**
  46782. * Stores the emissive values in a texture.
  46783. */
  46784. emissiveTexture: BaseTexture;
  46785. /**
  46786. * AKA Specular texture in other nomenclature.
  46787. */
  46788. reflectivityTexture: BaseTexture;
  46789. /**
  46790. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46791. */
  46792. metallicTexture: BaseTexture;
  46793. /**
  46794. * Specifies the metallic scalar of the metallic/roughness workflow.
  46795. * Can also be used to scale the metalness values of the metallic texture.
  46796. */
  46797. metallic: Nullable<number>;
  46798. /**
  46799. * Specifies the roughness scalar of the metallic/roughness workflow.
  46800. * Can also be used to scale the roughness values of the metallic texture.
  46801. */
  46802. roughness: Nullable<number>;
  46803. /**
  46804. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46805. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46806. */
  46807. microSurfaceTexture: BaseTexture;
  46808. /**
  46809. * Stores surface normal data used to displace a mesh in a texture.
  46810. */
  46811. bumpTexture: BaseTexture;
  46812. /**
  46813. * Stores the pre-calculated light information of a mesh in a texture.
  46814. */
  46815. lightmapTexture: BaseTexture;
  46816. /**
  46817. * Stores the refracted light information in a texture.
  46818. */
  46819. refractionTexture: BaseTexture;
  46820. /**
  46821. * The color of a material in ambient lighting.
  46822. */
  46823. ambientColor: Color3;
  46824. /**
  46825. * AKA Diffuse Color in other nomenclature.
  46826. */
  46827. albedoColor: Color3;
  46828. /**
  46829. * AKA Specular Color in other nomenclature.
  46830. */
  46831. reflectivityColor: Color3;
  46832. /**
  46833. * The color reflected from the material.
  46834. */
  46835. reflectionColor: Color3;
  46836. /**
  46837. * The color emitted from the material.
  46838. */
  46839. emissiveColor: Color3;
  46840. /**
  46841. * AKA Glossiness in other nomenclature.
  46842. */
  46843. microSurface: number;
  46844. /**
  46845. * source material index of refraction (IOR)' / 'destination material IOR.
  46846. */
  46847. indexOfRefraction: number;
  46848. /**
  46849. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46850. */
  46851. invertRefractionY: boolean;
  46852. /**
  46853. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46854. * Materials half opaque for instance using refraction could benefit from this control.
  46855. */
  46856. linkRefractionWithTransparency: boolean;
  46857. /**
  46858. * If true, the light map contains occlusion information instead of lighting info.
  46859. */
  46860. useLightmapAsShadowmap: boolean;
  46861. /**
  46862. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46863. */
  46864. useAlphaFromAlbedoTexture: boolean;
  46865. /**
  46866. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46867. */
  46868. forceAlphaTest: boolean;
  46869. /**
  46870. * Defines the alpha limits in alpha test mode.
  46871. */
  46872. alphaCutOff: number;
  46873. /**
  46874. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46875. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46876. */
  46877. useSpecularOverAlpha: boolean;
  46878. /**
  46879. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46880. */
  46881. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46882. /**
  46883. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46884. */
  46885. useRoughnessFromMetallicTextureAlpha: boolean;
  46886. /**
  46887. * Specifies if the metallic texture contains the roughness information in its green channel.
  46888. */
  46889. useRoughnessFromMetallicTextureGreen: boolean;
  46890. /**
  46891. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46892. */
  46893. useMetallnessFromMetallicTextureBlue: boolean;
  46894. /**
  46895. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46896. */
  46897. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46898. /**
  46899. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46900. */
  46901. useAmbientInGrayScale: boolean;
  46902. /**
  46903. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46904. * The material will try to infer what glossiness each pixel should be.
  46905. */
  46906. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46907. /**
  46908. * BJS is using an harcoded light falloff based on a manually sets up range.
  46909. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46910. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46911. */
  46912. /**
  46913. * BJS is using an harcoded light falloff based on a manually sets up range.
  46914. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46915. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46916. */
  46917. usePhysicalLightFalloff: boolean;
  46918. /**
  46919. * In order to support the falloff compatibility with gltf, a special mode has been added
  46920. * to reproduce the gltf light falloff.
  46921. */
  46922. /**
  46923. * In order to support the falloff compatibility with gltf, a special mode has been added
  46924. * to reproduce the gltf light falloff.
  46925. */
  46926. useGLTFLightFalloff: boolean;
  46927. /**
  46928. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46929. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46930. */
  46931. useRadianceOverAlpha: boolean;
  46932. /**
  46933. * Allows using an object space normal map (instead of tangent space).
  46934. */
  46935. useObjectSpaceNormalMap: boolean;
  46936. /**
  46937. * Allows using the bump map in parallax mode.
  46938. */
  46939. useParallax: boolean;
  46940. /**
  46941. * Allows using the bump map in parallax occlusion mode.
  46942. */
  46943. useParallaxOcclusion: boolean;
  46944. /**
  46945. * Controls the scale bias of the parallax mode.
  46946. */
  46947. parallaxScaleBias: number;
  46948. /**
  46949. * If sets to true, disables all the lights affecting the material.
  46950. */
  46951. disableLighting: boolean;
  46952. /**
  46953. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46954. */
  46955. forceIrradianceInFragment: boolean;
  46956. /**
  46957. * Number of Simultaneous lights allowed on the material.
  46958. */
  46959. maxSimultaneousLights: number;
  46960. /**
  46961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46962. */
  46963. invertNormalMapX: boolean;
  46964. /**
  46965. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46966. */
  46967. invertNormalMapY: boolean;
  46968. /**
  46969. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46970. */
  46971. twoSidedLighting: boolean;
  46972. /**
  46973. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46974. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46975. */
  46976. useAlphaFresnel: boolean;
  46977. /**
  46978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46979. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46980. */
  46981. useLinearAlphaFresnel: boolean;
  46982. /**
  46983. * Let user defines the brdf lookup texture used for IBL.
  46984. * A default 8bit version is embedded but you could point at :
  46985. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46986. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46987. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46988. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46989. */
  46990. environmentBRDFTexture: Nullable<BaseTexture>;
  46991. /**
  46992. * Force normal to face away from face.
  46993. */
  46994. forceNormalForward: boolean;
  46995. /**
  46996. * Enables specular anti aliasing in the PBR shader.
  46997. * It will both interacts on the Geometry for analytical and IBL lighting.
  46998. * It also prefilter the roughness map based on the bump values.
  46999. */
  47000. enableSpecularAntiAliasing: boolean;
  47001. /**
  47002. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47003. * makes the reflect vector face the model (under horizon).
  47004. */
  47005. useHorizonOcclusion: boolean;
  47006. /**
  47007. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47008. * too much the area relying on ambient texture to define their ambient occlusion.
  47009. */
  47010. useRadianceOcclusion: boolean;
  47011. /**
  47012. * If set to true, no lighting calculations will be applied.
  47013. */
  47014. unlit: boolean;
  47015. /**
  47016. * Gets the image processing configuration used either in this material.
  47017. */
  47018. /**
  47019. * Sets the Default image processing configuration used either in the this material.
  47020. *
  47021. * If sets to null, the scene one is in use.
  47022. */
  47023. imageProcessingConfiguration: ImageProcessingConfiguration;
  47024. /**
  47025. * Gets wether the color curves effect is enabled.
  47026. */
  47027. /**
  47028. * Sets wether the color curves effect is enabled.
  47029. */
  47030. cameraColorCurvesEnabled: boolean;
  47031. /**
  47032. * Gets wether the color grading effect is enabled.
  47033. */
  47034. /**
  47035. * Gets wether the color grading effect is enabled.
  47036. */
  47037. cameraColorGradingEnabled: boolean;
  47038. /**
  47039. * Gets wether tonemapping is enabled or not.
  47040. */
  47041. /**
  47042. * Sets wether tonemapping is enabled or not
  47043. */
  47044. cameraToneMappingEnabled: boolean;
  47045. /**
  47046. * The camera exposure used on this material.
  47047. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47048. * This corresponds to a photographic exposure.
  47049. */
  47050. /**
  47051. * The camera exposure used on this material.
  47052. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47053. * This corresponds to a photographic exposure.
  47054. */
  47055. cameraExposure: number;
  47056. /**
  47057. * Gets The camera contrast used on this material.
  47058. */
  47059. /**
  47060. * Sets The camera contrast used on this material.
  47061. */
  47062. cameraContrast: number;
  47063. /**
  47064. * Gets the Color Grading 2D Lookup Texture.
  47065. */
  47066. /**
  47067. * Sets the Color Grading 2D Lookup Texture.
  47068. */
  47069. cameraColorGradingTexture: Nullable<BaseTexture>;
  47070. /**
  47071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47073. * 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;
  47074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47075. */
  47076. /**
  47077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47079. * 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;
  47080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47081. */
  47082. cameraColorCurves: Nullable<ColorCurves>;
  47083. /**
  47084. * Instantiates a new PBRMaterial instance.
  47085. *
  47086. * @param name The material name
  47087. * @param scene The scene the material will be use in.
  47088. */
  47089. constructor(name: string, scene: Scene);
  47090. /**
  47091. * Returns the name of this material class.
  47092. */
  47093. getClassName(): string;
  47094. /**
  47095. * Makes a duplicate of the current material.
  47096. * @param name - name to use for the new material.
  47097. */
  47098. clone(name: string): PBRMaterial;
  47099. /**
  47100. * Serializes this PBR Material.
  47101. * @returns - An object with the serialized material.
  47102. */
  47103. serialize(): any;
  47104. /**
  47105. * Parses a PBR Material from a serialized object.
  47106. * @param source - Serialized object.
  47107. * @param scene - BJS scene instance.
  47108. * @param rootUrl - url for the scene object
  47109. * @returns - PBRMaterial
  47110. */
  47111. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47112. }
  47113. }
  47114. declare module "babylonjs/Misc/dds" {
  47115. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47116. import { Engine } from "babylonjs/Engines/engine";
  47117. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47118. import { Nullable } from "babylonjs/types";
  47119. import { Scene } from "babylonjs/scene";
  47120. /**
  47121. * Direct draw surface info
  47122. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47123. */
  47124. export interface DDSInfo {
  47125. /**
  47126. * Width of the texture
  47127. */
  47128. width: number;
  47129. /**
  47130. * Width of the texture
  47131. */
  47132. height: number;
  47133. /**
  47134. * Number of Mipmaps for the texture
  47135. * @see https://en.wikipedia.org/wiki/Mipmap
  47136. */
  47137. mipmapCount: number;
  47138. /**
  47139. * If the textures format is a known fourCC format
  47140. * @see https://www.fourcc.org/
  47141. */
  47142. isFourCC: boolean;
  47143. /**
  47144. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47145. */
  47146. isRGB: boolean;
  47147. /**
  47148. * If the texture is a lumincance format
  47149. */
  47150. isLuminance: boolean;
  47151. /**
  47152. * If this is a cube texture
  47153. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47154. */
  47155. isCube: boolean;
  47156. /**
  47157. * If the texture is a compressed format eg. FOURCC_DXT1
  47158. */
  47159. isCompressed: boolean;
  47160. /**
  47161. * The dxgiFormat of the texture
  47162. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47163. */
  47164. dxgiFormat: number;
  47165. /**
  47166. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47167. */
  47168. textureType: number;
  47169. /**
  47170. * Sphericle polynomial created for the dds texture
  47171. */
  47172. sphericalPolynomial?: SphericalPolynomial;
  47173. }
  47174. /**
  47175. * Class used to provide DDS decompression tools
  47176. */
  47177. export class DDSTools {
  47178. /**
  47179. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47180. */
  47181. static StoreLODInAlphaChannel: boolean;
  47182. /**
  47183. * Gets DDS information from an array buffer
  47184. * @param arrayBuffer defines the array buffer to read data from
  47185. * @returns the DDS information
  47186. */
  47187. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47188. private static _FloatView;
  47189. private static _Int32View;
  47190. private static _ToHalfFloat;
  47191. private static _FromHalfFloat;
  47192. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47193. private static _GetHalfFloatRGBAArrayBuffer;
  47194. private static _GetFloatRGBAArrayBuffer;
  47195. private static _GetFloatAsUIntRGBAArrayBuffer;
  47196. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47197. private static _GetRGBAArrayBuffer;
  47198. private static _ExtractLongWordOrder;
  47199. private static _GetRGBArrayBuffer;
  47200. private static _GetLuminanceArrayBuffer;
  47201. /**
  47202. * Uploads DDS Levels to a Babylon Texture
  47203. * @hidden
  47204. */
  47205. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47206. }
  47207. module "babylonjs/Engines/engine" {
  47208. interface Engine {
  47209. /**
  47210. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47211. * @param rootUrl defines the url where the file to load is located
  47212. * @param scene defines the current scene
  47213. * @param lodScale defines scale to apply to the mip map selection
  47214. * @param lodOffset defines offset to apply to the mip map selection
  47215. * @param onLoad defines an optional callback raised when the texture is loaded
  47216. * @param onError defines an optional callback raised if there is an issue to load the texture
  47217. * @param format defines the format of the data
  47218. * @param forcedExtension defines the extension to use to pick the right loader
  47219. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47220. * @returns the cube texture as an InternalTexture
  47221. */
  47222. 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;
  47223. }
  47224. }
  47225. }
  47226. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47227. import { Nullable } from "babylonjs/types";
  47228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47229. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47230. /**
  47231. * Implementation of the DDS Texture Loader.
  47232. * @hidden
  47233. */
  47234. export class _DDSTextureLoader implements IInternalTextureLoader {
  47235. /**
  47236. * Defines wether the loader supports cascade loading the different faces.
  47237. */
  47238. readonly supportCascades: boolean;
  47239. /**
  47240. * This returns if the loader support the current file information.
  47241. * @param extension defines the file extension of the file being loaded
  47242. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47243. * @param fallback defines the fallback internal texture if any
  47244. * @param isBase64 defines whether the texture is encoded as a base64
  47245. * @param isBuffer defines whether the texture data are stored as a buffer
  47246. * @returns true if the loader can load the specified file
  47247. */
  47248. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47249. /**
  47250. * Transform the url before loading if required.
  47251. * @param rootUrl the url of the texture
  47252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47253. * @returns the transformed texture
  47254. */
  47255. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47256. /**
  47257. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47258. * @param rootUrl the url of the texture
  47259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47260. * @returns the fallback texture
  47261. */
  47262. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47263. /**
  47264. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47265. * @param data contains the texture data
  47266. * @param texture defines the BabylonJS internal texture
  47267. * @param createPolynomials will be true if polynomials have been requested
  47268. * @param onLoad defines the callback to trigger once the texture is ready
  47269. * @param onError defines the callback to trigger in case of error
  47270. */
  47271. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47272. /**
  47273. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47274. * @param data contains the texture data
  47275. * @param texture defines the BabylonJS internal texture
  47276. * @param callback defines the method to call once ready to upload
  47277. */
  47278. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47279. }
  47280. }
  47281. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47282. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47283. /** @hidden */
  47284. export var rgbdEncodePixelShader: {
  47285. name: string;
  47286. shader: string;
  47287. };
  47288. }
  47289. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47290. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47291. /** @hidden */
  47292. export var rgbdDecodePixelShader: {
  47293. name: string;
  47294. shader: string;
  47295. };
  47296. }
  47297. declare module "babylonjs/Misc/environmentTextureTools" {
  47298. import { Nullable } from "babylonjs/types";
  47299. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47300. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47301. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47302. import "babylonjs/Shaders/rgbdEncode.fragment";
  47303. import "babylonjs/Shaders/rgbdDecode.fragment";
  47304. /**
  47305. * Raw texture data and descriptor sufficient for WebGL texture upload
  47306. */
  47307. export interface EnvironmentTextureInfo {
  47308. /**
  47309. * Version of the environment map
  47310. */
  47311. version: number;
  47312. /**
  47313. * Width of image
  47314. */
  47315. width: number;
  47316. /**
  47317. * Irradiance information stored in the file.
  47318. */
  47319. irradiance: any;
  47320. /**
  47321. * Specular information stored in the file.
  47322. */
  47323. specular: any;
  47324. }
  47325. /**
  47326. * Sets of helpers addressing the serialization and deserialization of environment texture
  47327. * stored in a BabylonJS env file.
  47328. * Those files are usually stored as .env files.
  47329. */
  47330. export class EnvironmentTextureTools {
  47331. /**
  47332. * Magic number identifying the env file.
  47333. */
  47334. private static _MagicBytes;
  47335. /**
  47336. * Gets the environment info from an env file.
  47337. * @param data The array buffer containing the .env bytes.
  47338. * @returns the environment file info (the json header) if successfully parsed.
  47339. */
  47340. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47341. /**
  47342. * Creates an environment texture from a loaded cube texture.
  47343. * @param texture defines the cube texture to convert in env file
  47344. * @return a promise containing the environment data if succesfull.
  47345. */
  47346. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47347. /**
  47348. * Creates a JSON representation of the spherical data.
  47349. * @param texture defines the texture containing the polynomials
  47350. * @return the JSON representation of the spherical info
  47351. */
  47352. private static _CreateEnvTextureIrradiance;
  47353. /**
  47354. * Uploads the texture info contained in the env file to the GPU.
  47355. * @param texture defines the internal texture to upload to
  47356. * @param arrayBuffer defines the buffer cotaining the data to load
  47357. * @param info defines the texture info retrieved through the GetEnvInfo method
  47358. * @returns a promise
  47359. */
  47360. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47361. /**
  47362. * Uploads the levels of image data to the GPU.
  47363. * @param texture defines the internal texture to upload to
  47364. * @param imageData defines the array buffer views of image data [mipmap][face]
  47365. * @returns a promise
  47366. */
  47367. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47368. /**
  47369. * Uploads spherical polynomials information to the texture.
  47370. * @param texture defines the texture we are trying to upload the information to
  47371. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47372. */
  47373. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47374. /** @hidden */
  47375. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47376. }
  47377. }
  47378. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47379. import { Nullable } from "babylonjs/types";
  47380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47381. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47382. /**
  47383. * Implementation of the ENV Texture Loader.
  47384. * @hidden
  47385. */
  47386. export class _ENVTextureLoader implements IInternalTextureLoader {
  47387. /**
  47388. * Defines wether the loader supports cascade loading the different faces.
  47389. */
  47390. readonly supportCascades: boolean;
  47391. /**
  47392. * This returns if the loader support the current file information.
  47393. * @param extension defines the file extension of the file being loaded
  47394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47395. * @param fallback defines the fallback internal texture if any
  47396. * @param isBase64 defines whether the texture is encoded as a base64
  47397. * @param isBuffer defines whether the texture data are stored as a buffer
  47398. * @returns true if the loader can load the specified file
  47399. */
  47400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47401. /**
  47402. * Transform the url before loading if required.
  47403. * @param rootUrl the url of the texture
  47404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47405. * @returns the transformed texture
  47406. */
  47407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47408. /**
  47409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47410. * @param rootUrl the url of the texture
  47411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47412. * @returns the fallback texture
  47413. */
  47414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47415. /**
  47416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47417. * @param data contains the texture data
  47418. * @param texture defines the BabylonJS internal texture
  47419. * @param createPolynomials will be true if polynomials have been requested
  47420. * @param onLoad defines the callback to trigger once the texture is ready
  47421. * @param onError defines the callback to trigger in case of error
  47422. */
  47423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47424. /**
  47425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47426. * @param data contains the texture data
  47427. * @param texture defines the BabylonJS internal texture
  47428. * @param callback defines the method to call once ready to upload
  47429. */
  47430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47431. }
  47432. }
  47433. declare module "babylonjs/Misc/khronosTextureContainer" {
  47434. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47435. /**
  47436. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47437. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47438. */
  47439. export class KhronosTextureContainer {
  47440. /** contents of the KTX container file */
  47441. arrayBuffer: any;
  47442. private static HEADER_LEN;
  47443. private static COMPRESSED_2D;
  47444. private static COMPRESSED_3D;
  47445. private static TEX_2D;
  47446. private static TEX_3D;
  47447. /**
  47448. * Gets the openGL type
  47449. */
  47450. glType: number;
  47451. /**
  47452. * Gets the openGL type size
  47453. */
  47454. glTypeSize: number;
  47455. /**
  47456. * Gets the openGL format
  47457. */
  47458. glFormat: number;
  47459. /**
  47460. * Gets the openGL internal format
  47461. */
  47462. glInternalFormat: number;
  47463. /**
  47464. * Gets the base internal format
  47465. */
  47466. glBaseInternalFormat: number;
  47467. /**
  47468. * Gets image width in pixel
  47469. */
  47470. pixelWidth: number;
  47471. /**
  47472. * Gets image height in pixel
  47473. */
  47474. pixelHeight: number;
  47475. /**
  47476. * Gets image depth in pixels
  47477. */
  47478. pixelDepth: number;
  47479. /**
  47480. * Gets the number of array elements
  47481. */
  47482. numberOfArrayElements: number;
  47483. /**
  47484. * Gets the number of faces
  47485. */
  47486. numberOfFaces: number;
  47487. /**
  47488. * Gets the number of mipmap levels
  47489. */
  47490. numberOfMipmapLevels: number;
  47491. /**
  47492. * Gets the bytes of key value data
  47493. */
  47494. bytesOfKeyValueData: number;
  47495. /**
  47496. * Gets the load type
  47497. */
  47498. loadType: number;
  47499. /**
  47500. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47501. */
  47502. isInvalid: boolean;
  47503. /**
  47504. * Creates a new KhronosTextureContainer
  47505. * @param arrayBuffer contents of the KTX container file
  47506. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47507. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47508. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47509. */
  47510. constructor(
  47511. /** contents of the KTX container file */
  47512. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47513. /**
  47514. * Uploads KTX content to a Babylon Texture.
  47515. * It is assumed that the texture has already been created & is currently bound
  47516. * @hidden
  47517. */
  47518. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47519. private _upload2DCompressedLevels;
  47520. }
  47521. }
  47522. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47523. import { Nullable } from "babylonjs/types";
  47524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47526. /**
  47527. * Implementation of the KTX Texture Loader.
  47528. * @hidden
  47529. */
  47530. export class _KTXTextureLoader implements IInternalTextureLoader {
  47531. /**
  47532. * Defines wether the loader supports cascade loading the different faces.
  47533. */
  47534. readonly supportCascades: boolean;
  47535. /**
  47536. * This returns if the loader support the current file information.
  47537. * @param extension defines the file extension of the file being loaded
  47538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47539. * @param fallback defines the fallback internal texture if any
  47540. * @param isBase64 defines whether the texture is encoded as a base64
  47541. * @param isBuffer defines whether the texture data are stored as a buffer
  47542. * @returns true if the loader can load the specified file
  47543. */
  47544. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47545. /**
  47546. * Transform the url before loading if required.
  47547. * @param rootUrl the url of the texture
  47548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47549. * @returns the transformed texture
  47550. */
  47551. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47552. /**
  47553. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47554. * @param rootUrl the url of the texture
  47555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47556. * @returns the fallback texture
  47557. */
  47558. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47559. /**
  47560. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47561. * @param data contains the texture data
  47562. * @param texture defines the BabylonJS internal texture
  47563. * @param createPolynomials will be true if polynomials have been requested
  47564. * @param onLoad defines the callback to trigger once the texture is ready
  47565. * @param onError defines the callback to trigger in case of error
  47566. */
  47567. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47568. /**
  47569. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47570. * @param data contains the texture data
  47571. * @param texture defines the BabylonJS internal texture
  47572. * @param callback defines the method to call once ready to upload
  47573. */
  47574. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47575. }
  47576. }
  47577. declare module "babylonjs/Helpers/sceneHelpers" {
  47578. import { Nullable } from "babylonjs/types";
  47579. import { Mesh } from "babylonjs/Meshes/mesh";
  47580. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47581. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47582. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47583. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47584. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47585. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47586. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47587. import "babylonjs/Meshes/Builders/boxBuilder";
  47588. /** @hidden */
  47589. export var _forceSceneHelpersToBundle: boolean;
  47590. module "babylonjs/scene" {
  47591. interface Scene {
  47592. /**
  47593. * Creates a default light for the scene.
  47594. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47595. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47596. */
  47597. createDefaultLight(replace?: boolean): void;
  47598. /**
  47599. * Creates a default camera for the scene.
  47600. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47601. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47602. * @param replace has default false, when true replaces the active camera in the scene
  47603. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47604. */
  47605. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47606. /**
  47607. * Creates a default camera and a default light.
  47608. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47609. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47610. * @param replace has the default false, when true replaces the active camera/light in the scene
  47611. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47612. */
  47613. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47614. /**
  47615. * Creates a new sky box
  47616. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47617. * @param environmentTexture defines the texture to use as environment texture
  47618. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47619. * @param scale defines the overall scale of the skybox
  47620. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47621. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47622. * @returns a new mesh holding the sky box
  47623. */
  47624. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47625. /**
  47626. * Creates a new environment
  47627. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47628. * @param options defines the options you can use to configure the environment
  47629. * @returns the new EnvironmentHelper
  47630. */
  47631. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47632. /**
  47633. * Creates a new VREXperienceHelper
  47634. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47635. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47636. * @returns a new VREXperienceHelper
  47637. */
  47638. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47639. /**
  47640. * Creates a new XREXperienceHelper
  47641. * @see http://doc.babylonjs.com/how_to/webxr
  47642. * @returns a promise for a new XREXperienceHelper
  47643. */
  47644. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47645. }
  47646. }
  47647. }
  47648. declare module "babylonjs/Helpers/videoDome" {
  47649. import { Scene } from "babylonjs/scene";
  47650. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47651. import { Mesh } from "babylonjs/Meshes/mesh";
  47652. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47653. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47654. import "babylonjs/Meshes/Builders/sphereBuilder";
  47655. /**
  47656. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47657. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47658. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47659. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47660. */
  47661. export class VideoDome extends TransformNode {
  47662. /**
  47663. * Define the video source as a Monoscopic panoramic 360 video.
  47664. */
  47665. static readonly MODE_MONOSCOPIC: number;
  47666. /**
  47667. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47668. */
  47669. static readonly MODE_TOPBOTTOM: number;
  47670. /**
  47671. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47672. */
  47673. static readonly MODE_SIDEBYSIDE: number;
  47674. private _useDirectMapping;
  47675. /**
  47676. * The video texture being displayed on the sphere
  47677. */
  47678. protected _videoTexture: VideoTexture;
  47679. /**
  47680. * Gets the video texture being displayed on the sphere
  47681. */
  47682. readonly videoTexture: VideoTexture;
  47683. /**
  47684. * The skybox material
  47685. */
  47686. protected _material: BackgroundMaterial;
  47687. /**
  47688. * The surface used for the skybox
  47689. */
  47690. protected _mesh: Mesh;
  47691. /**
  47692. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47693. * Also see the options.resolution property.
  47694. */
  47695. fovMultiplier: number;
  47696. private _videoMode;
  47697. /**
  47698. * Gets or set the current video mode for the video. It can be:
  47699. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47700. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47701. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47702. */
  47703. videoMode: number;
  47704. /**
  47705. * Oberserver used in Stereoscopic VR Mode.
  47706. */
  47707. private _onBeforeCameraRenderObserver;
  47708. /**
  47709. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47710. * @param name Element's name, child elements will append suffixes for their own names.
  47711. * @param urlsOrVideo defines the url(s) or the video element to use
  47712. * @param options An object containing optional or exposed sub element properties
  47713. */
  47714. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47715. resolution?: number;
  47716. clickToPlay?: boolean;
  47717. autoPlay?: boolean;
  47718. loop?: boolean;
  47719. size?: number;
  47720. poster?: string;
  47721. faceForward?: boolean;
  47722. useDirectMapping?: boolean;
  47723. }, scene: Scene);
  47724. private _changeVideoMode;
  47725. /**
  47726. * Releases resources associated with this node.
  47727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47729. */
  47730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47731. }
  47732. }
  47733. declare module "babylonjs/Helpers/index" {
  47734. export * from "babylonjs/Helpers/environmentHelper";
  47735. export * from "babylonjs/Helpers/photoDome";
  47736. export * from "babylonjs/Helpers/sceneHelpers";
  47737. export * from "babylonjs/Helpers/videoDome";
  47738. }
  47739. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47740. import { PerfCounter } from "babylonjs/Misc/tools";
  47741. import { IDisposable } from "babylonjs/scene";
  47742. import { Engine } from "babylonjs/Engines/engine";
  47743. /**
  47744. * This class can be used to get instrumentation data from a Babylon engine
  47745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47746. */
  47747. export class EngineInstrumentation implements IDisposable {
  47748. /**
  47749. * Define the instrumented engine.
  47750. */
  47751. engine: Engine;
  47752. private _captureGPUFrameTime;
  47753. private _gpuFrameTimeToken;
  47754. private _gpuFrameTime;
  47755. private _captureShaderCompilationTime;
  47756. private _shaderCompilationTime;
  47757. private _onBeginFrameObserver;
  47758. private _onEndFrameObserver;
  47759. private _onBeforeShaderCompilationObserver;
  47760. private _onAfterShaderCompilationObserver;
  47761. /**
  47762. * Gets the perf counter used for GPU frame time
  47763. */
  47764. readonly gpuFrameTimeCounter: PerfCounter;
  47765. /**
  47766. * Gets the GPU frame time capture status
  47767. */
  47768. /**
  47769. * Enable or disable the GPU frame time capture
  47770. */
  47771. captureGPUFrameTime: boolean;
  47772. /**
  47773. * Gets the perf counter used for shader compilation time
  47774. */
  47775. readonly shaderCompilationTimeCounter: PerfCounter;
  47776. /**
  47777. * Gets the shader compilation time capture status
  47778. */
  47779. /**
  47780. * Enable or disable the shader compilation time capture
  47781. */
  47782. captureShaderCompilationTime: boolean;
  47783. /**
  47784. * Instantiates a new engine instrumentation.
  47785. * This class can be used to get instrumentation data from a Babylon engine
  47786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47787. * @param engine Defines the engine to instrument
  47788. */
  47789. constructor(
  47790. /**
  47791. * Define the instrumented engine.
  47792. */
  47793. engine: Engine);
  47794. /**
  47795. * Dispose and release associated resources.
  47796. */
  47797. dispose(): void;
  47798. }
  47799. }
  47800. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47801. import { PerfCounter } from "babylonjs/Misc/tools";
  47802. import { Scene, IDisposable } from "babylonjs/scene";
  47803. /**
  47804. * This class can be used to get instrumentation data from a Babylon engine
  47805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47806. */
  47807. export class SceneInstrumentation implements IDisposable {
  47808. /**
  47809. * Defines the scene to instrument
  47810. */
  47811. scene: Scene;
  47812. private _captureActiveMeshesEvaluationTime;
  47813. private _activeMeshesEvaluationTime;
  47814. private _captureRenderTargetsRenderTime;
  47815. private _renderTargetsRenderTime;
  47816. private _captureFrameTime;
  47817. private _frameTime;
  47818. private _captureRenderTime;
  47819. private _renderTime;
  47820. private _captureInterFrameTime;
  47821. private _interFrameTime;
  47822. private _captureParticlesRenderTime;
  47823. private _particlesRenderTime;
  47824. private _captureSpritesRenderTime;
  47825. private _spritesRenderTime;
  47826. private _capturePhysicsTime;
  47827. private _physicsTime;
  47828. private _captureAnimationsTime;
  47829. private _animationsTime;
  47830. private _captureCameraRenderTime;
  47831. private _cameraRenderTime;
  47832. private _onBeforeActiveMeshesEvaluationObserver;
  47833. private _onAfterActiveMeshesEvaluationObserver;
  47834. private _onBeforeRenderTargetsRenderObserver;
  47835. private _onAfterRenderTargetsRenderObserver;
  47836. private _onAfterRenderObserver;
  47837. private _onBeforeDrawPhaseObserver;
  47838. private _onAfterDrawPhaseObserver;
  47839. private _onBeforeAnimationsObserver;
  47840. private _onBeforeParticlesRenderingObserver;
  47841. private _onAfterParticlesRenderingObserver;
  47842. private _onBeforeSpritesRenderingObserver;
  47843. private _onAfterSpritesRenderingObserver;
  47844. private _onBeforePhysicsObserver;
  47845. private _onAfterPhysicsObserver;
  47846. private _onAfterAnimationsObserver;
  47847. private _onBeforeCameraRenderObserver;
  47848. private _onAfterCameraRenderObserver;
  47849. /**
  47850. * Gets the perf counter used for active meshes evaluation time
  47851. */
  47852. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47853. /**
  47854. * Gets the active meshes evaluation time capture status
  47855. */
  47856. /**
  47857. * Enable or disable the active meshes evaluation time capture
  47858. */
  47859. captureActiveMeshesEvaluationTime: boolean;
  47860. /**
  47861. * Gets the perf counter used for render targets render time
  47862. */
  47863. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47864. /**
  47865. * Gets the render targets render time capture status
  47866. */
  47867. /**
  47868. * Enable or disable the render targets render time capture
  47869. */
  47870. captureRenderTargetsRenderTime: boolean;
  47871. /**
  47872. * Gets the perf counter used for particles render time
  47873. */
  47874. readonly particlesRenderTimeCounter: PerfCounter;
  47875. /**
  47876. * Gets the particles render time capture status
  47877. */
  47878. /**
  47879. * Enable or disable the particles render time capture
  47880. */
  47881. captureParticlesRenderTime: boolean;
  47882. /**
  47883. * Gets the perf counter used for sprites render time
  47884. */
  47885. readonly spritesRenderTimeCounter: PerfCounter;
  47886. /**
  47887. * Gets the sprites render time capture status
  47888. */
  47889. /**
  47890. * Enable or disable the sprites render time capture
  47891. */
  47892. captureSpritesRenderTime: boolean;
  47893. /**
  47894. * Gets the perf counter used for physics time
  47895. */
  47896. readonly physicsTimeCounter: PerfCounter;
  47897. /**
  47898. * Gets the physics time capture status
  47899. */
  47900. /**
  47901. * Enable or disable the physics time capture
  47902. */
  47903. capturePhysicsTime: boolean;
  47904. /**
  47905. * Gets the perf counter used for animations time
  47906. */
  47907. readonly animationsTimeCounter: PerfCounter;
  47908. /**
  47909. * Gets the animations time capture status
  47910. */
  47911. /**
  47912. * Enable or disable the animations time capture
  47913. */
  47914. captureAnimationsTime: boolean;
  47915. /**
  47916. * Gets the perf counter used for frame time capture
  47917. */
  47918. readonly frameTimeCounter: PerfCounter;
  47919. /**
  47920. * Gets the frame time capture status
  47921. */
  47922. /**
  47923. * Enable or disable the frame time capture
  47924. */
  47925. captureFrameTime: boolean;
  47926. /**
  47927. * Gets the perf counter used for inter-frames time capture
  47928. */
  47929. readonly interFrameTimeCounter: PerfCounter;
  47930. /**
  47931. * Gets the inter-frames time capture status
  47932. */
  47933. /**
  47934. * Enable or disable the inter-frames time capture
  47935. */
  47936. captureInterFrameTime: boolean;
  47937. /**
  47938. * Gets the perf counter used for render time capture
  47939. */
  47940. readonly renderTimeCounter: PerfCounter;
  47941. /**
  47942. * Gets the render time capture status
  47943. */
  47944. /**
  47945. * Enable or disable the render time capture
  47946. */
  47947. captureRenderTime: boolean;
  47948. /**
  47949. * Gets the perf counter used for camera render time capture
  47950. */
  47951. readonly cameraRenderTimeCounter: PerfCounter;
  47952. /**
  47953. * Gets the camera render time capture status
  47954. */
  47955. /**
  47956. * Enable or disable the camera render time capture
  47957. */
  47958. captureCameraRenderTime: boolean;
  47959. /**
  47960. * Gets the perf counter used for draw calls
  47961. */
  47962. readonly drawCallsCounter: PerfCounter;
  47963. /**
  47964. * Gets the perf counter used for texture collisions
  47965. */
  47966. readonly textureCollisionsCounter: PerfCounter;
  47967. /**
  47968. * Instantiates a new scene instrumentation.
  47969. * This class can be used to get instrumentation data from a Babylon engine
  47970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47971. * @param scene Defines the scene to instrument
  47972. */
  47973. constructor(
  47974. /**
  47975. * Defines the scene to instrument
  47976. */
  47977. scene: Scene);
  47978. /**
  47979. * Dispose and release associated resources.
  47980. */
  47981. dispose(): void;
  47982. }
  47983. }
  47984. declare module "babylonjs/Instrumentation/index" {
  47985. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47986. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47987. export * from "babylonjs/Instrumentation/timeToken";
  47988. }
  47989. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47990. /** @hidden */
  47991. export var glowMapGenerationPixelShader: {
  47992. name: string;
  47993. shader: string;
  47994. };
  47995. }
  47996. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47997. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47998. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47999. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48000. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48001. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48002. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48003. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48004. /** @hidden */
  48005. export var glowMapGenerationVertexShader: {
  48006. name: string;
  48007. shader: string;
  48008. };
  48009. }
  48010. declare module "babylonjs/Layers/effectLayer" {
  48011. import { Observable } from "babylonjs/Misc/observable";
  48012. import { Nullable } from "babylonjs/types";
  48013. import { Camera } from "babylonjs/Cameras/camera";
  48014. import { Scene } from "babylonjs/scene";
  48015. import { Color4, ISize } from "babylonjs/Maths/math";
  48016. import { Engine } from "babylonjs/Engines/engine";
  48017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48019. import { Mesh } from "babylonjs/Meshes/mesh";
  48020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48023. import { Effect } from "babylonjs/Materials/effect";
  48024. import { Material } from "babylonjs/Materials/material";
  48025. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48026. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48027. /**
  48028. * Effect layer options. This helps customizing the behaviour
  48029. * of the effect layer.
  48030. */
  48031. export interface IEffectLayerOptions {
  48032. /**
  48033. * Multiplication factor apply to the canvas size to compute the render target size
  48034. * used to generated the objects (the smaller the faster).
  48035. */
  48036. mainTextureRatio: number;
  48037. /**
  48038. * Enforces a fixed size texture to ensure effect stability across devices.
  48039. */
  48040. mainTextureFixedSize?: number;
  48041. /**
  48042. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48043. */
  48044. alphaBlendingMode: number;
  48045. /**
  48046. * The camera attached to the layer.
  48047. */
  48048. camera: Nullable<Camera>;
  48049. /**
  48050. * The rendering group to draw the layer in.
  48051. */
  48052. renderingGroupId: number;
  48053. }
  48054. /**
  48055. * The effect layer Helps adding post process effect blended with the main pass.
  48056. *
  48057. * This can be for instance use to generate glow or higlight effects on the scene.
  48058. *
  48059. * The effect layer class can not be used directly and is intented to inherited from to be
  48060. * customized per effects.
  48061. */
  48062. export abstract class EffectLayer {
  48063. private _vertexBuffers;
  48064. private _indexBuffer;
  48065. private _cachedDefines;
  48066. private _effectLayerMapGenerationEffect;
  48067. private _effectLayerOptions;
  48068. private _mergeEffect;
  48069. protected _scene: Scene;
  48070. protected _engine: Engine;
  48071. protected _maxSize: number;
  48072. protected _mainTextureDesiredSize: ISize;
  48073. protected _mainTexture: RenderTargetTexture;
  48074. protected _shouldRender: boolean;
  48075. protected _postProcesses: PostProcess[];
  48076. protected _textures: BaseTexture[];
  48077. protected _emissiveTextureAndColor: {
  48078. texture: Nullable<BaseTexture>;
  48079. color: Color4;
  48080. };
  48081. /**
  48082. * The name of the layer
  48083. */
  48084. name: string;
  48085. /**
  48086. * The clear color of the texture used to generate the glow map.
  48087. */
  48088. neutralColor: Color4;
  48089. /**
  48090. * Specifies wether the highlight layer is enabled or not.
  48091. */
  48092. isEnabled: boolean;
  48093. /**
  48094. * Gets the camera attached to the layer.
  48095. */
  48096. readonly camera: Nullable<Camera>;
  48097. /**
  48098. * Gets the rendering group id the layer should render in.
  48099. */
  48100. readonly renderingGroupId: number;
  48101. /**
  48102. * An event triggered when the effect layer has been disposed.
  48103. */
  48104. onDisposeObservable: Observable<EffectLayer>;
  48105. /**
  48106. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48107. */
  48108. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48109. /**
  48110. * An event triggered when the generated texture is being merged in the scene.
  48111. */
  48112. onBeforeComposeObservable: Observable<EffectLayer>;
  48113. /**
  48114. * An event triggered when the generated texture has been merged in the scene.
  48115. */
  48116. onAfterComposeObservable: Observable<EffectLayer>;
  48117. /**
  48118. * An event triggered when the efffect layer changes its size.
  48119. */
  48120. onSizeChangedObservable: Observable<EffectLayer>;
  48121. /** @hidden */
  48122. static _SceneComponentInitialization: (scene: Scene) => void;
  48123. /**
  48124. * Instantiates a new effect Layer and references it in the scene.
  48125. * @param name The name of the layer
  48126. * @param scene The scene to use the layer in
  48127. */
  48128. constructor(
  48129. /** The Friendly of the effect in the scene */
  48130. name: string, scene: Scene);
  48131. /**
  48132. * Get the effect name of the layer.
  48133. * @return The effect name
  48134. */
  48135. abstract getEffectName(): string;
  48136. /**
  48137. * Checks for the readiness of the element composing the layer.
  48138. * @param subMesh the mesh to check for
  48139. * @param useInstances specify wether or not to use instances to render the mesh
  48140. * @return true if ready otherwise, false
  48141. */
  48142. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48143. /**
  48144. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48145. * @returns true if the effect requires stencil during the main canvas render pass.
  48146. */
  48147. abstract needStencil(): boolean;
  48148. /**
  48149. * Create the merge effect. This is the shader use to blit the information back
  48150. * to the main canvas at the end of the scene rendering.
  48151. * @returns The effect containing the shader used to merge the effect on the main canvas
  48152. */
  48153. protected abstract _createMergeEffect(): Effect;
  48154. /**
  48155. * Creates the render target textures and post processes used in the effect layer.
  48156. */
  48157. protected abstract _createTextureAndPostProcesses(): void;
  48158. /**
  48159. * Implementation specific of rendering the generating effect on the main canvas.
  48160. * @param effect The effect used to render through
  48161. */
  48162. protected abstract _internalRender(effect: Effect): void;
  48163. /**
  48164. * Sets the required values for both the emissive texture and and the main color.
  48165. */
  48166. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48167. /**
  48168. * Free any resources and references associated to a mesh.
  48169. * Internal use
  48170. * @param mesh The mesh to free.
  48171. */
  48172. abstract _disposeMesh(mesh: Mesh): void;
  48173. /**
  48174. * Serializes this layer (Glow or Highlight for example)
  48175. * @returns a serialized layer object
  48176. */
  48177. abstract serialize?(): any;
  48178. /**
  48179. * Initializes the effect layer with the required options.
  48180. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48181. */
  48182. protected _init(options: Partial<IEffectLayerOptions>): void;
  48183. /**
  48184. * Generates the index buffer of the full screen quad blending to the main canvas.
  48185. */
  48186. private _generateIndexBuffer;
  48187. /**
  48188. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48189. */
  48190. private _genrateVertexBuffer;
  48191. /**
  48192. * Sets the main texture desired size which is the closest power of two
  48193. * of the engine canvas size.
  48194. */
  48195. private _setMainTextureSize;
  48196. /**
  48197. * Creates the main texture for the effect layer.
  48198. */
  48199. protected _createMainTexture(): void;
  48200. /**
  48201. * Adds specific effects defines.
  48202. * @param defines The defines to add specifics to.
  48203. */
  48204. protected _addCustomEffectDefines(defines: string[]): void;
  48205. /**
  48206. * Checks for the readiness of the element composing the layer.
  48207. * @param subMesh the mesh to check for
  48208. * @param useInstances specify wether or not to use instances to render the mesh
  48209. * @param emissiveTexture the associated emissive texture used to generate the glow
  48210. * @return true if ready otherwise, false
  48211. */
  48212. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48213. /**
  48214. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48215. */
  48216. render(): void;
  48217. /**
  48218. * Determine if a given mesh will be used in the current effect.
  48219. * @param mesh mesh to test
  48220. * @returns true if the mesh will be used
  48221. */
  48222. hasMesh(mesh: AbstractMesh): boolean;
  48223. /**
  48224. * Returns true if the layer contains information to display, otherwise false.
  48225. * @returns true if the glow layer should be rendered
  48226. */
  48227. shouldRender(): boolean;
  48228. /**
  48229. * Returns true if the mesh should render, otherwise false.
  48230. * @param mesh The mesh to render
  48231. * @returns true if it should render otherwise false
  48232. */
  48233. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48234. /**
  48235. * Returns true if the mesh can be rendered, otherwise false.
  48236. * @param mesh The mesh to render
  48237. * @param material The material used on the mesh
  48238. * @returns true if it can be rendered otherwise false
  48239. */
  48240. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48241. /**
  48242. * Returns true if the mesh should render, otherwise false.
  48243. * @param mesh The mesh to render
  48244. * @returns true if it should render otherwise false
  48245. */
  48246. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48247. /**
  48248. * Renders the submesh passed in parameter to the generation map.
  48249. */
  48250. protected _renderSubMesh(subMesh: SubMesh): void;
  48251. /**
  48252. * Rebuild the required buffers.
  48253. * @hidden Internal use only.
  48254. */
  48255. _rebuild(): void;
  48256. /**
  48257. * Dispose only the render target textures and post process.
  48258. */
  48259. private _disposeTextureAndPostProcesses;
  48260. /**
  48261. * Dispose the highlight layer and free resources.
  48262. */
  48263. dispose(): void;
  48264. /**
  48265. * Gets the class name of the effect layer
  48266. * @returns the string with the class name of the effect layer
  48267. */
  48268. getClassName(): string;
  48269. /**
  48270. * Creates an effect layer from parsed effect layer data
  48271. * @param parsedEffectLayer defines effect layer data
  48272. * @param scene defines the current scene
  48273. * @param rootUrl defines the root URL containing the effect layer information
  48274. * @returns a parsed effect Layer
  48275. */
  48276. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48277. }
  48278. }
  48279. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48280. import { Scene } from "babylonjs/scene";
  48281. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48282. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48283. import { AbstractScene } from "babylonjs/abstractScene";
  48284. module "babylonjs/abstractScene" {
  48285. interface AbstractScene {
  48286. /**
  48287. * The list of effect layers (highlights/glow) added to the scene
  48288. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48289. * @see http://doc.babylonjs.com/how_to/glow_layer
  48290. */
  48291. effectLayers: Array<EffectLayer>;
  48292. /**
  48293. * Removes the given effect layer from this scene.
  48294. * @param toRemove defines the effect layer to remove
  48295. * @returns the index of the removed effect layer
  48296. */
  48297. removeEffectLayer(toRemove: EffectLayer): number;
  48298. /**
  48299. * Adds the given effect layer to this scene
  48300. * @param newEffectLayer defines the effect layer to add
  48301. */
  48302. addEffectLayer(newEffectLayer: EffectLayer): void;
  48303. }
  48304. }
  48305. /**
  48306. * Defines the layer scene component responsible to manage any effect layers
  48307. * in a given scene.
  48308. */
  48309. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48310. /**
  48311. * The component name helpfull to identify the component in the list of scene components.
  48312. */
  48313. readonly name: string;
  48314. /**
  48315. * The scene the component belongs to.
  48316. */
  48317. scene: Scene;
  48318. private _engine;
  48319. private _renderEffects;
  48320. private _needStencil;
  48321. private _previousStencilState;
  48322. /**
  48323. * Creates a new instance of the component for the given scene
  48324. * @param scene Defines the scene to register the component in
  48325. */
  48326. constructor(scene: Scene);
  48327. /**
  48328. * Registers the component in a given scene
  48329. */
  48330. register(): void;
  48331. /**
  48332. * Rebuilds the elements related to this component in case of
  48333. * context lost for instance.
  48334. */
  48335. rebuild(): void;
  48336. /**
  48337. * Serializes the component data to the specified json object
  48338. * @param serializationObject The object to serialize to
  48339. */
  48340. serialize(serializationObject: any): void;
  48341. /**
  48342. * Adds all the element from the container to the scene
  48343. * @param container the container holding the elements
  48344. */
  48345. addFromContainer(container: AbstractScene): void;
  48346. /**
  48347. * Removes all the elements in the container from the scene
  48348. * @param container contains the elements to remove
  48349. * @param dispose if the removed element should be disposed (default: false)
  48350. */
  48351. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48352. /**
  48353. * Disposes the component and the associated ressources.
  48354. */
  48355. dispose(): void;
  48356. private _isReadyForMesh;
  48357. private _renderMainTexture;
  48358. private _setStencil;
  48359. private _setStencilBack;
  48360. private _draw;
  48361. private _drawCamera;
  48362. private _drawRenderingGroup;
  48363. }
  48364. }
  48365. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48366. /** @hidden */
  48367. export var glowMapMergePixelShader: {
  48368. name: string;
  48369. shader: string;
  48370. };
  48371. }
  48372. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48373. /** @hidden */
  48374. export var glowMapMergeVertexShader: {
  48375. name: string;
  48376. shader: string;
  48377. };
  48378. }
  48379. declare module "babylonjs/Layers/glowLayer" {
  48380. import { Nullable } from "babylonjs/types";
  48381. import { Camera } from "babylonjs/Cameras/camera";
  48382. import { Scene } from "babylonjs/scene";
  48383. import { Color4 } from "babylonjs/Maths/math";
  48384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48386. import { Mesh } from "babylonjs/Meshes/mesh";
  48387. import { Texture } from "babylonjs/Materials/Textures/texture";
  48388. import { Effect } from "babylonjs/Materials/effect";
  48389. import { Material } from "babylonjs/Materials/material";
  48390. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48391. import "babylonjs/Shaders/glowMapMerge.fragment";
  48392. import "babylonjs/Shaders/glowMapMerge.vertex";
  48393. import "babylonjs/Layers/effectLayerSceneComponent";
  48394. module "babylonjs/abstractScene" {
  48395. interface AbstractScene {
  48396. /**
  48397. * Return a the first highlight layer of the scene with a given name.
  48398. * @param name The name of the highlight layer to look for.
  48399. * @return The highlight layer if found otherwise null.
  48400. */
  48401. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48402. }
  48403. }
  48404. /**
  48405. * Glow layer options. This helps customizing the behaviour
  48406. * of the glow layer.
  48407. */
  48408. export interface IGlowLayerOptions {
  48409. /**
  48410. * Multiplication factor apply to the canvas size to compute the render target size
  48411. * used to generated the glowing objects (the smaller the faster).
  48412. */
  48413. mainTextureRatio: number;
  48414. /**
  48415. * Enforces a fixed size texture to ensure resize independant blur.
  48416. */
  48417. mainTextureFixedSize?: number;
  48418. /**
  48419. * How big is the kernel of the blur texture.
  48420. */
  48421. blurKernelSize: number;
  48422. /**
  48423. * The camera attached to the layer.
  48424. */
  48425. camera: Nullable<Camera>;
  48426. /**
  48427. * Enable MSAA by chosing the number of samples.
  48428. */
  48429. mainTextureSamples?: number;
  48430. /**
  48431. * The rendering group to draw the layer in.
  48432. */
  48433. renderingGroupId: number;
  48434. }
  48435. /**
  48436. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48437. *
  48438. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48439. * glowy meshes to your scene.
  48440. *
  48441. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48442. */
  48443. export class GlowLayer extends EffectLayer {
  48444. /**
  48445. * Effect Name of the layer.
  48446. */
  48447. static readonly EffectName: string;
  48448. /**
  48449. * The default blur kernel size used for the glow.
  48450. */
  48451. static DefaultBlurKernelSize: number;
  48452. /**
  48453. * The default texture size ratio used for the glow.
  48454. */
  48455. static DefaultTextureRatio: number;
  48456. /**
  48457. * Sets the kernel size of the blur.
  48458. */
  48459. /**
  48460. * Gets the kernel size of the blur.
  48461. */
  48462. blurKernelSize: number;
  48463. /**
  48464. * Sets the glow intensity.
  48465. */
  48466. /**
  48467. * Gets the glow intensity.
  48468. */
  48469. intensity: number;
  48470. private _options;
  48471. private _intensity;
  48472. private _horizontalBlurPostprocess1;
  48473. private _verticalBlurPostprocess1;
  48474. private _horizontalBlurPostprocess2;
  48475. private _verticalBlurPostprocess2;
  48476. private _blurTexture1;
  48477. private _blurTexture2;
  48478. private _postProcesses1;
  48479. private _postProcesses2;
  48480. private _includedOnlyMeshes;
  48481. private _excludedMeshes;
  48482. /**
  48483. * Callback used to let the user override the color selection on a per mesh basis
  48484. */
  48485. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48486. /**
  48487. * Callback used to let the user override the texture selection on a per mesh basis
  48488. */
  48489. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48490. /**
  48491. * Instantiates a new glow Layer and references it to the scene.
  48492. * @param name The name of the layer
  48493. * @param scene The scene to use the layer in
  48494. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48495. */
  48496. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48497. /**
  48498. * Get the effect name of the layer.
  48499. * @return The effect name
  48500. */
  48501. getEffectName(): string;
  48502. /**
  48503. * Create the merge effect. This is the shader use to blit the information back
  48504. * to the main canvas at the end of the scene rendering.
  48505. */
  48506. protected _createMergeEffect(): Effect;
  48507. /**
  48508. * Creates the render target textures and post processes used in the glow layer.
  48509. */
  48510. protected _createTextureAndPostProcesses(): void;
  48511. /**
  48512. * Checks for the readiness of the element composing the layer.
  48513. * @param subMesh the mesh to check for
  48514. * @param useInstances specify wether or not to use instances to render the mesh
  48515. * @param emissiveTexture the associated emissive texture used to generate the glow
  48516. * @return true if ready otherwise, false
  48517. */
  48518. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48519. /**
  48520. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48521. */
  48522. needStencil(): boolean;
  48523. /**
  48524. * Returns true if the mesh can be rendered, otherwise false.
  48525. * @param mesh The mesh to render
  48526. * @param material The material used on the mesh
  48527. * @returns true if it can be rendered otherwise false
  48528. */
  48529. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48530. /**
  48531. * Implementation specific of rendering the generating effect on the main canvas.
  48532. * @param effect The effect used to render through
  48533. */
  48534. protected _internalRender(effect: Effect): void;
  48535. /**
  48536. * Sets the required values for both the emissive texture and and the main color.
  48537. */
  48538. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48539. /**
  48540. * Returns true if the mesh should render, otherwise false.
  48541. * @param mesh The mesh to render
  48542. * @returns true if it should render otherwise false
  48543. */
  48544. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48545. /**
  48546. * Adds specific effects defines.
  48547. * @param defines The defines to add specifics to.
  48548. */
  48549. protected _addCustomEffectDefines(defines: string[]): void;
  48550. /**
  48551. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48552. * @param mesh The mesh to exclude from the glow layer
  48553. */
  48554. addExcludedMesh(mesh: Mesh): void;
  48555. /**
  48556. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48557. * @param mesh The mesh to remove
  48558. */
  48559. removeExcludedMesh(mesh: Mesh): void;
  48560. /**
  48561. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48562. * @param mesh The mesh to include in the glow layer
  48563. */
  48564. addIncludedOnlyMesh(mesh: Mesh): void;
  48565. /**
  48566. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48567. * @param mesh The mesh to remove
  48568. */
  48569. removeIncludedOnlyMesh(mesh: Mesh): void;
  48570. /**
  48571. * Determine if a given mesh will be used in the glow layer
  48572. * @param mesh The mesh to test
  48573. * @returns true if the mesh will be highlighted by the current glow layer
  48574. */
  48575. hasMesh(mesh: AbstractMesh): boolean;
  48576. /**
  48577. * Free any resources and references associated to a mesh.
  48578. * Internal use
  48579. * @param mesh The mesh to free.
  48580. * @hidden
  48581. */
  48582. _disposeMesh(mesh: Mesh): void;
  48583. /**
  48584. * Gets the class name of the effect layer
  48585. * @returns the string with the class name of the effect layer
  48586. */
  48587. getClassName(): string;
  48588. /**
  48589. * Serializes this glow layer
  48590. * @returns a serialized glow layer object
  48591. */
  48592. serialize(): any;
  48593. /**
  48594. * Creates a Glow Layer from parsed glow layer data
  48595. * @param parsedGlowLayer defines glow layer data
  48596. * @param scene defines the current scene
  48597. * @param rootUrl defines the root URL containing the glow layer information
  48598. * @returns a parsed Glow Layer
  48599. */
  48600. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48601. }
  48602. }
  48603. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48604. /** @hidden */
  48605. export var glowBlurPostProcessPixelShader: {
  48606. name: string;
  48607. shader: string;
  48608. };
  48609. }
  48610. declare module "babylonjs/Layers/highlightLayer" {
  48611. import { Observable } from "babylonjs/Misc/observable";
  48612. import { Nullable } from "babylonjs/types";
  48613. import { Camera } from "babylonjs/Cameras/camera";
  48614. import { Scene } from "babylonjs/scene";
  48615. import { Color3, Color4 } from "babylonjs/Maths/math";
  48616. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48618. import { Mesh } from "babylonjs/Meshes/mesh";
  48619. import { Effect } from "babylonjs/Materials/effect";
  48620. import { Material } from "babylonjs/Materials/material";
  48621. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48622. import "babylonjs/Shaders/glowMapMerge.fragment";
  48623. import "babylonjs/Shaders/glowMapMerge.vertex";
  48624. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48625. module "babylonjs/abstractScene" {
  48626. interface AbstractScene {
  48627. /**
  48628. * Return a the first highlight layer of the scene with a given name.
  48629. * @param name The name of the highlight layer to look for.
  48630. * @return The highlight layer if found otherwise null.
  48631. */
  48632. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48633. }
  48634. }
  48635. /**
  48636. * Highlight layer options. This helps customizing the behaviour
  48637. * of the highlight layer.
  48638. */
  48639. export interface IHighlightLayerOptions {
  48640. /**
  48641. * Multiplication factor apply to the canvas size to compute the render target size
  48642. * used to generated the glowing objects (the smaller the faster).
  48643. */
  48644. mainTextureRatio: number;
  48645. /**
  48646. * Enforces a fixed size texture to ensure resize independant blur.
  48647. */
  48648. mainTextureFixedSize?: number;
  48649. /**
  48650. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48651. * of the picture to blur (the smaller the faster).
  48652. */
  48653. blurTextureSizeRatio: number;
  48654. /**
  48655. * How big in texel of the blur texture is the vertical blur.
  48656. */
  48657. blurVerticalSize: number;
  48658. /**
  48659. * How big in texel of the blur texture is the horizontal blur.
  48660. */
  48661. blurHorizontalSize: number;
  48662. /**
  48663. * Alpha blending mode used to apply the blur. Default is combine.
  48664. */
  48665. alphaBlendingMode: number;
  48666. /**
  48667. * The camera attached to the layer.
  48668. */
  48669. camera: Nullable<Camera>;
  48670. /**
  48671. * Should we display highlight as a solid stroke?
  48672. */
  48673. isStroke?: boolean;
  48674. /**
  48675. * The rendering group to draw the layer in.
  48676. */
  48677. renderingGroupId: number;
  48678. }
  48679. /**
  48680. * The highlight layer Helps adding a glow effect around a mesh.
  48681. *
  48682. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48683. * glowy meshes to your scene.
  48684. *
  48685. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48686. */
  48687. export class HighlightLayer extends EffectLayer {
  48688. name: string;
  48689. /**
  48690. * Effect Name of the highlight layer.
  48691. */
  48692. static readonly EffectName: string;
  48693. /**
  48694. * The neutral color used during the preparation of the glow effect.
  48695. * This is black by default as the blend operation is a blend operation.
  48696. */
  48697. static NeutralColor: Color4;
  48698. /**
  48699. * Stencil value used for glowing meshes.
  48700. */
  48701. static GlowingMeshStencilReference: number;
  48702. /**
  48703. * Stencil value used for the other meshes in the scene.
  48704. */
  48705. static NormalMeshStencilReference: number;
  48706. /**
  48707. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48708. */
  48709. innerGlow: boolean;
  48710. /**
  48711. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48712. */
  48713. outerGlow: boolean;
  48714. /**
  48715. * Specifies the horizontal size of the blur.
  48716. */
  48717. /**
  48718. * Gets the horizontal size of the blur.
  48719. */
  48720. blurHorizontalSize: number;
  48721. /**
  48722. * Specifies the vertical size of the blur.
  48723. */
  48724. /**
  48725. * Gets the vertical size of the blur.
  48726. */
  48727. blurVerticalSize: number;
  48728. /**
  48729. * An event triggered when the highlight layer is being blurred.
  48730. */
  48731. onBeforeBlurObservable: Observable<HighlightLayer>;
  48732. /**
  48733. * An event triggered when the highlight layer has been blurred.
  48734. */
  48735. onAfterBlurObservable: Observable<HighlightLayer>;
  48736. private _instanceGlowingMeshStencilReference;
  48737. private _options;
  48738. private _downSamplePostprocess;
  48739. private _horizontalBlurPostprocess;
  48740. private _verticalBlurPostprocess;
  48741. private _blurTexture;
  48742. private _meshes;
  48743. private _excludedMeshes;
  48744. /**
  48745. * Instantiates a new highlight Layer and references it to the scene..
  48746. * @param name The name of the layer
  48747. * @param scene The scene to use the layer in
  48748. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48749. */
  48750. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48751. /**
  48752. * Get the effect name of the layer.
  48753. * @return The effect name
  48754. */
  48755. getEffectName(): string;
  48756. /**
  48757. * Create the merge effect. This is the shader use to blit the information back
  48758. * to the main canvas at the end of the scene rendering.
  48759. */
  48760. protected _createMergeEffect(): Effect;
  48761. /**
  48762. * Creates the render target textures and post processes used in the highlight layer.
  48763. */
  48764. protected _createTextureAndPostProcesses(): void;
  48765. /**
  48766. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48767. */
  48768. needStencil(): boolean;
  48769. /**
  48770. * Checks for the readiness of the element composing the layer.
  48771. * @param subMesh the mesh to check for
  48772. * @param useInstances specify wether or not to use instances to render the mesh
  48773. * @param emissiveTexture the associated emissive texture used to generate the glow
  48774. * @return true if ready otherwise, false
  48775. */
  48776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48777. /**
  48778. * Implementation specific of rendering the generating effect on the main canvas.
  48779. * @param effect The effect used to render through
  48780. */
  48781. protected _internalRender(effect: Effect): void;
  48782. /**
  48783. * Returns true if the layer contains information to display, otherwise false.
  48784. */
  48785. shouldRender(): boolean;
  48786. /**
  48787. * Returns true if the mesh should render, otherwise false.
  48788. * @param mesh The mesh to render
  48789. * @returns true if it should render otherwise false
  48790. */
  48791. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48792. /**
  48793. * Sets the required values for both the emissive texture and and the main color.
  48794. */
  48795. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48796. /**
  48797. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48798. * @param mesh The mesh to exclude from the highlight layer
  48799. */
  48800. addExcludedMesh(mesh: Mesh): void;
  48801. /**
  48802. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48803. * @param mesh The mesh to highlight
  48804. */
  48805. removeExcludedMesh(mesh: Mesh): void;
  48806. /**
  48807. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48808. * @param mesh mesh to test
  48809. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48810. */
  48811. hasMesh(mesh: AbstractMesh): boolean;
  48812. /**
  48813. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48814. * @param mesh The mesh to highlight
  48815. * @param color The color of the highlight
  48816. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48817. */
  48818. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48819. /**
  48820. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48821. * @param mesh The mesh to highlight
  48822. */
  48823. removeMesh(mesh: Mesh): void;
  48824. /**
  48825. * Force the stencil to the normal expected value for none glowing parts
  48826. */
  48827. private _defaultStencilReference;
  48828. /**
  48829. * Free any resources and references associated to a mesh.
  48830. * Internal use
  48831. * @param mesh The mesh to free.
  48832. * @hidden
  48833. */
  48834. _disposeMesh(mesh: Mesh): void;
  48835. /**
  48836. * Dispose the highlight layer and free resources.
  48837. */
  48838. dispose(): void;
  48839. /**
  48840. * Gets the class name of the effect layer
  48841. * @returns the string with the class name of the effect layer
  48842. */
  48843. getClassName(): string;
  48844. /**
  48845. * Serializes this Highlight layer
  48846. * @returns a serialized Highlight layer object
  48847. */
  48848. serialize(): any;
  48849. /**
  48850. * Creates a Highlight layer from parsed Highlight layer data
  48851. * @param parsedHightlightLayer defines the Highlight layer data
  48852. * @param scene defines the current scene
  48853. * @param rootUrl defines the root URL containing the Highlight layer information
  48854. * @returns a parsed Highlight layer
  48855. */
  48856. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48857. }
  48858. }
  48859. declare module "babylonjs/Layers/index" {
  48860. export * from "babylonjs/Layers/effectLayer";
  48861. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48862. export * from "babylonjs/Layers/glowLayer";
  48863. export * from "babylonjs/Layers/highlightLayer";
  48864. export * from "babylonjs/Layers/layer";
  48865. export * from "babylonjs/Layers/layerSceneComponent";
  48866. }
  48867. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48868. /** @hidden */
  48869. export var lensFlarePixelShader: {
  48870. name: string;
  48871. shader: string;
  48872. };
  48873. }
  48874. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48875. /** @hidden */
  48876. export var lensFlareVertexShader: {
  48877. name: string;
  48878. shader: string;
  48879. };
  48880. }
  48881. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48882. import { Scene } from "babylonjs/scene";
  48883. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48885. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48886. import "babylonjs/Shaders/lensFlare.fragment";
  48887. import "babylonjs/Shaders/lensFlare.vertex";
  48888. /**
  48889. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48890. * It is usually composed of several `lensFlare`.
  48891. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48892. */
  48893. export class LensFlareSystem {
  48894. /**
  48895. * Define the name of the lens flare system
  48896. */
  48897. name: string;
  48898. /**
  48899. * List of lens flares used in this system.
  48900. */
  48901. lensFlares: LensFlare[];
  48902. /**
  48903. * Define a limit from the border the lens flare can be visible.
  48904. */
  48905. borderLimit: number;
  48906. /**
  48907. * Define a viewport border we do not want to see the lens flare in.
  48908. */
  48909. viewportBorder: number;
  48910. /**
  48911. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48912. */
  48913. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48914. /**
  48915. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48916. */
  48917. layerMask: number;
  48918. /**
  48919. * Define the id of the lens flare system in the scene.
  48920. * (equal to name by default)
  48921. */
  48922. id: string;
  48923. private _scene;
  48924. private _emitter;
  48925. private _vertexBuffers;
  48926. private _indexBuffer;
  48927. private _effect;
  48928. private _positionX;
  48929. private _positionY;
  48930. private _isEnabled;
  48931. /** @hidden */
  48932. static _SceneComponentInitialization: (scene: Scene) => void;
  48933. /**
  48934. * Instantiates a lens flare system.
  48935. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48936. * It is usually composed of several `lensFlare`.
  48937. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48938. * @param name Define the name of the lens flare system in the scene
  48939. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48940. * @param scene Define the scene the lens flare system belongs to
  48941. */
  48942. constructor(
  48943. /**
  48944. * Define the name of the lens flare system
  48945. */
  48946. name: string, emitter: any, scene: Scene);
  48947. /**
  48948. * Define if the lens flare system is enabled.
  48949. */
  48950. isEnabled: boolean;
  48951. /**
  48952. * Get the scene the effects belongs to.
  48953. * @returns the scene holding the lens flare system
  48954. */
  48955. getScene(): Scene;
  48956. /**
  48957. * Get the emitter of the lens flare system.
  48958. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48959. * @returns the emitter of the lens flare system
  48960. */
  48961. getEmitter(): any;
  48962. /**
  48963. * Set the emitter of the lens flare system.
  48964. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48965. * @param newEmitter Define the new emitter of the system
  48966. */
  48967. setEmitter(newEmitter: any): void;
  48968. /**
  48969. * Get the lens flare system emitter position.
  48970. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48971. * @returns the position
  48972. */
  48973. getEmitterPosition(): Vector3;
  48974. /**
  48975. * @hidden
  48976. */
  48977. computeEffectivePosition(globalViewport: Viewport): boolean;
  48978. /** @hidden */
  48979. _isVisible(): boolean;
  48980. /**
  48981. * @hidden
  48982. */
  48983. render(): boolean;
  48984. /**
  48985. * Dispose and release the lens flare with its associated resources.
  48986. */
  48987. dispose(): void;
  48988. /**
  48989. * Parse a lens flare system from a JSON repressentation
  48990. * @param parsedLensFlareSystem Define the JSON to parse
  48991. * @param scene Define the scene the parsed system should be instantiated in
  48992. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48993. * @returns the parsed system
  48994. */
  48995. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48996. /**
  48997. * Serialize the current Lens Flare System into a JSON representation.
  48998. * @returns the serialized JSON
  48999. */
  49000. serialize(): any;
  49001. }
  49002. }
  49003. declare module "babylonjs/LensFlares/lensFlare" {
  49004. import { Nullable } from "babylonjs/types";
  49005. import { Color3 } from "babylonjs/Maths/math";
  49006. import { Texture } from "babylonjs/Materials/Textures/texture";
  49007. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49008. /**
  49009. * This represents one of the lens effect in a `lensFlareSystem`.
  49010. * It controls one of the indiviual texture used in the effect.
  49011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49012. */
  49013. export class LensFlare {
  49014. /**
  49015. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49016. */
  49017. size: number;
  49018. /**
  49019. * 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.
  49020. */
  49021. position: number;
  49022. /**
  49023. * Define the lens color.
  49024. */
  49025. color: Color3;
  49026. /**
  49027. * Define the lens texture.
  49028. */
  49029. texture: Nullable<Texture>;
  49030. /**
  49031. * Define the alpha mode to render this particular lens.
  49032. */
  49033. alphaMode: number;
  49034. private _system;
  49035. /**
  49036. * Creates a new Lens Flare.
  49037. * This represents one of the lens effect in a `lensFlareSystem`.
  49038. * It controls one of the indiviual texture used in the effect.
  49039. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49040. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49041. * @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.
  49042. * @param color Define the lens color
  49043. * @param imgUrl Define the lens texture url
  49044. * @param system Define the `lensFlareSystem` this flare is part of
  49045. * @returns The newly created Lens Flare
  49046. */
  49047. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49048. /**
  49049. * Instantiates a new Lens Flare.
  49050. * This represents one of the lens effect in a `lensFlareSystem`.
  49051. * It controls one of the indiviual texture used in the effect.
  49052. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49053. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49054. * @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.
  49055. * @param color Define the lens color
  49056. * @param imgUrl Define the lens texture url
  49057. * @param system Define the `lensFlareSystem` this flare is part of
  49058. */
  49059. constructor(
  49060. /**
  49061. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49062. */
  49063. size: number,
  49064. /**
  49065. * 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.
  49066. */
  49067. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49068. /**
  49069. * Dispose and release the lens flare with its associated resources.
  49070. */
  49071. dispose(): void;
  49072. }
  49073. }
  49074. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49075. import { Nullable } from "babylonjs/types";
  49076. import { Scene } from "babylonjs/scene";
  49077. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49078. import { AbstractScene } from "babylonjs/abstractScene";
  49079. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49080. module "babylonjs/abstractScene" {
  49081. interface AbstractScene {
  49082. /**
  49083. * The list of lens flare system added to the scene
  49084. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49085. */
  49086. lensFlareSystems: Array<LensFlareSystem>;
  49087. /**
  49088. * Removes the given lens flare system from this scene.
  49089. * @param toRemove The lens flare system to remove
  49090. * @returns The index of the removed lens flare system
  49091. */
  49092. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49093. /**
  49094. * Adds the given lens flare system to this scene
  49095. * @param newLensFlareSystem The lens flare system to add
  49096. */
  49097. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49098. /**
  49099. * Gets a lens flare system using its name
  49100. * @param name defines the name to look for
  49101. * @returns the lens flare system or null if not found
  49102. */
  49103. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49104. /**
  49105. * Gets a lens flare system using its id
  49106. * @param id defines the id to look for
  49107. * @returns the lens flare system or null if not found
  49108. */
  49109. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49110. }
  49111. }
  49112. /**
  49113. * Defines the lens flare scene component responsible to manage any lens flares
  49114. * in a given scene.
  49115. */
  49116. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49117. /**
  49118. * The component name helpfull to identify the component in the list of scene components.
  49119. */
  49120. readonly name: string;
  49121. /**
  49122. * The scene the component belongs to.
  49123. */
  49124. scene: Scene;
  49125. /**
  49126. * Creates a new instance of the component for the given scene
  49127. * @param scene Defines the scene to register the component in
  49128. */
  49129. constructor(scene: Scene);
  49130. /**
  49131. * Registers the component in a given scene
  49132. */
  49133. register(): void;
  49134. /**
  49135. * Rebuilds the elements related to this component in case of
  49136. * context lost for instance.
  49137. */
  49138. rebuild(): void;
  49139. /**
  49140. * Adds all the element from the container to the scene
  49141. * @param container the container holding the elements
  49142. */
  49143. addFromContainer(container: AbstractScene): void;
  49144. /**
  49145. * Removes all the elements in the container from the scene
  49146. * @param container contains the elements to remove
  49147. * @param dispose if the removed element should be disposed (default: false)
  49148. */
  49149. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49150. /**
  49151. * Serializes the component data to the specified json object
  49152. * @param serializationObject The object to serialize to
  49153. */
  49154. serialize(serializationObject: any): void;
  49155. /**
  49156. * Disposes the component and the associated ressources.
  49157. */
  49158. dispose(): void;
  49159. private _draw;
  49160. }
  49161. }
  49162. declare module "babylonjs/LensFlares/index" {
  49163. export * from "babylonjs/LensFlares/lensFlare";
  49164. export * from "babylonjs/LensFlares/lensFlareSystem";
  49165. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49166. }
  49167. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49168. import { Scene } from "babylonjs/scene";
  49169. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49170. import { AbstractScene } from "babylonjs/abstractScene";
  49171. /**
  49172. * Defines the shadow generator component responsible to manage any shadow generators
  49173. * in a given scene.
  49174. */
  49175. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49176. /**
  49177. * The component name helpfull to identify the component in the list of scene components.
  49178. */
  49179. readonly name: string;
  49180. /**
  49181. * The scene the component belongs to.
  49182. */
  49183. scene: Scene;
  49184. /**
  49185. * Creates a new instance of the component for the given scene
  49186. * @param scene Defines the scene to register the component in
  49187. */
  49188. constructor(scene: Scene);
  49189. /**
  49190. * Registers the component in a given scene
  49191. */
  49192. register(): void;
  49193. /**
  49194. * Rebuilds the elements related to this component in case of
  49195. * context lost for instance.
  49196. */
  49197. rebuild(): void;
  49198. /**
  49199. * Serializes the component data to the specified json object
  49200. * @param serializationObject The object to serialize to
  49201. */
  49202. serialize(serializationObject: any): void;
  49203. /**
  49204. * Adds all the element from the container to the scene
  49205. * @param container the container holding the elements
  49206. */
  49207. addFromContainer(container: AbstractScene): void;
  49208. /**
  49209. * Removes all the elements in the container from the scene
  49210. * @param container contains the elements to remove
  49211. * @param dispose if the removed element should be disposed (default: false)
  49212. */
  49213. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49214. /**
  49215. * Rebuilds the elements related to this component in case of
  49216. * context lost for instance.
  49217. */
  49218. dispose(): void;
  49219. private _gatherRenderTargets;
  49220. }
  49221. }
  49222. declare module "babylonjs/Lights/Shadows/index" {
  49223. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49224. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49225. }
  49226. declare module "babylonjs/Lights/pointLight" {
  49227. import { Scene } from "babylonjs/scene";
  49228. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49230. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49231. import { Effect } from "babylonjs/Materials/effect";
  49232. /**
  49233. * A point light is a light defined by an unique point in world space.
  49234. * The light is emitted in every direction from this point.
  49235. * A good example of a point light is a standard light bulb.
  49236. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49237. */
  49238. export class PointLight extends ShadowLight {
  49239. private _shadowAngle;
  49240. /**
  49241. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49242. * This specifies what angle the shadow will use to be created.
  49243. *
  49244. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49245. */
  49246. /**
  49247. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49248. * This specifies what angle the shadow will use to be created.
  49249. *
  49250. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49251. */
  49252. shadowAngle: number;
  49253. /**
  49254. * Gets the direction if it has been set.
  49255. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49256. */
  49257. /**
  49258. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49259. */
  49260. direction: Vector3;
  49261. /**
  49262. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49263. * A PointLight emits the light in every direction.
  49264. * It can cast shadows.
  49265. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49266. * ```javascript
  49267. * var pointLight = new PointLight("pl", camera.position, scene);
  49268. * ```
  49269. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49270. * @param name The light friendly name
  49271. * @param position The position of the point light in the scene
  49272. * @param scene The scene the lights belongs to
  49273. */
  49274. constructor(name: string, position: Vector3, scene: Scene);
  49275. /**
  49276. * Returns the string "PointLight"
  49277. * @returns the class name
  49278. */
  49279. getClassName(): string;
  49280. /**
  49281. * Returns the integer 0.
  49282. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49283. */
  49284. getTypeID(): number;
  49285. /**
  49286. * Specifies wether or not the shadowmap should be a cube texture.
  49287. * @returns true if the shadowmap needs to be a cube texture.
  49288. */
  49289. needCube(): boolean;
  49290. /**
  49291. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49292. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49293. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49294. */
  49295. getShadowDirection(faceIndex?: number): Vector3;
  49296. /**
  49297. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49298. * - fov = PI / 2
  49299. * - aspect ratio : 1.0
  49300. * - z-near and far equal to the active camera minZ and maxZ.
  49301. * Returns the PointLight.
  49302. */
  49303. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49304. protected _buildUniformLayout(): void;
  49305. /**
  49306. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49307. * @param effect The effect to update
  49308. * @param lightIndex The index of the light in the effect to update
  49309. * @returns The point light
  49310. */
  49311. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49312. /**
  49313. * Prepares the list of defines specific to the light type.
  49314. * @param defines the list of defines
  49315. * @param lightIndex defines the index of the light for the effect
  49316. */
  49317. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49318. }
  49319. }
  49320. declare module "babylonjs/Lights/index" {
  49321. export * from "babylonjs/Lights/light";
  49322. export * from "babylonjs/Lights/shadowLight";
  49323. export * from "babylonjs/Lights/Shadows/index";
  49324. export * from "babylonjs/Lights/directionalLight";
  49325. export * from "babylonjs/Lights/hemisphericLight";
  49326. export * from "babylonjs/Lights/pointLight";
  49327. export * from "babylonjs/Lights/spotLight";
  49328. }
  49329. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49330. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49331. /**
  49332. * Header information of HDR texture files.
  49333. */
  49334. export interface HDRInfo {
  49335. /**
  49336. * The height of the texture in pixels.
  49337. */
  49338. height: number;
  49339. /**
  49340. * The width of the texture in pixels.
  49341. */
  49342. width: number;
  49343. /**
  49344. * The index of the beginning of the data in the binary file.
  49345. */
  49346. dataPosition: number;
  49347. }
  49348. /**
  49349. * This groups tools to convert HDR texture to native colors array.
  49350. */
  49351. export class HDRTools {
  49352. private static Ldexp;
  49353. private static Rgbe2float;
  49354. private static readStringLine;
  49355. /**
  49356. * Reads header information from an RGBE texture stored in a native array.
  49357. * More information on this format are available here:
  49358. * https://en.wikipedia.org/wiki/RGBE_image_format
  49359. *
  49360. * @param uint8array The binary file stored in native array.
  49361. * @return The header information.
  49362. */
  49363. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49364. /**
  49365. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49366. * This RGBE texture needs to store the information as a panorama.
  49367. *
  49368. * More information on this format are available here:
  49369. * https://en.wikipedia.org/wiki/RGBE_image_format
  49370. *
  49371. * @param buffer The binary file stored in an array buffer.
  49372. * @param size The expected size of the extracted cubemap.
  49373. * @return The Cube Map information.
  49374. */
  49375. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49376. /**
  49377. * Returns the pixels data extracted from an RGBE texture.
  49378. * This pixels will be stored left to right up to down in the R G B order in one array.
  49379. *
  49380. * More information on this format are available here:
  49381. * https://en.wikipedia.org/wiki/RGBE_image_format
  49382. *
  49383. * @param uint8array The binary file stored in an array buffer.
  49384. * @param hdrInfo The header information of the file.
  49385. * @return The pixels data in RGB right to left up to down order.
  49386. */
  49387. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49388. private static RGBE_ReadPixels_RLE;
  49389. }
  49390. }
  49391. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49392. import { Nullable } from "babylonjs/types";
  49393. import { Scene } from "babylonjs/scene";
  49394. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49396. /**
  49397. * This represents a texture coming from an HDR input.
  49398. *
  49399. * The only supported format is currently panorama picture stored in RGBE format.
  49400. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49401. */
  49402. export class HDRCubeTexture extends BaseTexture {
  49403. private static _facesMapping;
  49404. private _generateHarmonics;
  49405. private _noMipmap;
  49406. private _textureMatrix;
  49407. private _size;
  49408. private _onLoad;
  49409. private _onError;
  49410. /**
  49411. * The texture URL.
  49412. */
  49413. url: string;
  49414. /**
  49415. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49416. */
  49417. coordinatesMode: number;
  49418. protected _isBlocking: boolean;
  49419. /**
  49420. * Sets wether or not the texture is blocking during loading.
  49421. */
  49422. /**
  49423. * Gets wether or not the texture is blocking during loading.
  49424. */
  49425. isBlocking: boolean;
  49426. protected _rotationY: number;
  49427. /**
  49428. * Sets texture matrix rotation angle around Y axis in radians.
  49429. */
  49430. /**
  49431. * Gets texture matrix rotation angle around Y axis radians.
  49432. */
  49433. rotationY: number;
  49434. /**
  49435. * Gets or sets the center of the bounding box associated with the cube texture
  49436. * It must define where the camera used to render the texture was set
  49437. */
  49438. boundingBoxPosition: Vector3;
  49439. private _boundingBoxSize;
  49440. /**
  49441. * Gets or sets the size of the bounding box associated with the cube texture
  49442. * When defined, the cubemap will switch to local mode
  49443. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49444. * @example https://www.babylonjs-playground.com/#RNASML
  49445. */
  49446. boundingBoxSize: Vector3;
  49447. /**
  49448. * Instantiates an HDRTexture from the following parameters.
  49449. *
  49450. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49451. * @param scene The scene the texture will be used in
  49452. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49453. * @param noMipmap Forces to not generate the mipmap if true
  49454. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49455. * @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)
  49456. * @param reserved Reserved flag for internal use.
  49457. */
  49458. 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>);
  49459. /**
  49460. * Get the current class name of the texture useful for serialization or dynamic coding.
  49461. * @returns "HDRCubeTexture"
  49462. */
  49463. getClassName(): string;
  49464. /**
  49465. * Occurs when the file is raw .hdr file.
  49466. */
  49467. private loadTexture;
  49468. clone(): HDRCubeTexture;
  49469. delayLoad(): void;
  49470. /**
  49471. * Get the texture reflection matrix used to rotate/transform the reflection.
  49472. * @returns the reflection matrix
  49473. */
  49474. getReflectionTextureMatrix(): Matrix;
  49475. /**
  49476. * Set the texture reflection matrix used to rotate/transform the reflection.
  49477. * @param value Define the reflection matrix to set
  49478. */
  49479. setReflectionTextureMatrix(value: Matrix): void;
  49480. /**
  49481. * Parses a JSON representation of an HDR Texture in order to create the texture
  49482. * @param parsedTexture Define the JSON representation
  49483. * @param scene Define the scene the texture should be created in
  49484. * @param rootUrl Define the root url in case we need to load relative dependencies
  49485. * @returns the newly created texture after parsing
  49486. */
  49487. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49488. serialize(): any;
  49489. }
  49490. }
  49491. declare module "babylonjs/Physics/physicsEngine" {
  49492. import { Nullable } from "babylonjs/types";
  49493. import { Vector3 } from "babylonjs/Maths/math";
  49494. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49495. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49496. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49497. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49498. /**
  49499. * Class used to control physics engine
  49500. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49501. */
  49502. export class PhysicsEngine implements IPhysicsEngine {
  49503. private _physicsPlugin;
  49504. /**
  49505. * Global value used to control the smallest number supported by the simulation
  49506. */
  49507. static Epsilon: number;
  49508. private _impostors;
  49509. private _joints;
  49510. /**
  49511. * Gets the gravity vector used by the simulation
  49512. */
  49513. gravity: Vector3;
  49514. /**
  49515. * Factory used to create the default physics plugin.
  49516. * @returns The default physics plugin
  49517. */
  49518. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49519. /**
  49520. * Creates a new Physics Engine
  49521. * @param gravity defines the gravity vector used by the simulation
  49522. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49523. */
  49524. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49525. /**
  49526. * Sets the gravity vector used by the simulation
  49527. * @param gravity defines the gravity vector to use
  49528. */
  49529. setGravity(gravity: Vector3): void;
  49530. /**
  49531. * Set the time step of the physics engine.
  49532. * Default is 1/60.
  49533. * To slow it down, enter 1/600 for example.
  49534. * To speed it up, 1/30
  49535. * @param newTimeStep defines the new timestep to apply to this world.
  49536. */
  49537. setTimeStep(newTimeStep?: number): void;
  49538. /**
  49539. * Get the time step of the physics engine.
  49540. * @returns the current time step
  49541. */
  49542. getTimeStep(): number;
  49543. /**
  49544. * Release all resources
  49545. */
  49546. dispose(): void;
  49547. /**
  49548. * Gets the name of the current physics plugin
  49549. * @returns the name of the plugin
  49550. */
  49551. getPhysicsPluginName(): string;
  49552. /**
  49553. * Adding a new impostor for the impostor tracking.
  49554. * This will be done by the impostor itself.
  49555. * @param impostor the impostor to add
  49556. */
  49557. addImpostor(impostor: PhysicsImpostor): void;
  49558. /**
  49559. * Remove an impostor from the engine.
  49560. * This impostor and its mesh will not longer be updated by the physics engine.
  49561. * @param impostor the impostor to remove
  49562. */
  49563. removeImpostor(impostor: PhysicsImpostor): void;
  49564. /**
  49565. * Add a joint to the physics engine
  49566. * @param mainImpostor defines the main impostor to which the joint is added.
  49567. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49568. * @param joint defines the joint that will connect both impostors.
  49569. */
  49570. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49571. /**
  49572. * Removes a joint from the simulation
  49573. * @param mainImpostor defines the impostor used with the joint
  49574. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49575. * @param joint defines the joint to remove
  49576. */
  49577. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49578. /**
  49579. * Called by the scene. No need to call it.
  49580. * @param delta defines the timespam between frames
  49581. */
  49582. _step(delta: number): void;
  49583. /**
  49584. * Gets the current plugin used to run the simulation
  49585. * @returns current plugin
  49586. */
  49587. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49588. /**
  49589. * Gets the list of physic impostors
  49590. * @returns an array of PhysicsImpostor
  49591. */
  49592. getImpostors(): Array<PhysicsImpostor>;
  49593. /**
  49594. * Gets the impostor for a physics enabled object
  49595. * @param object defines the object impersonated by the impostor
  49596. * @returns the PhysicsImpostor or null if not found
  49597. */
  49598. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49599. /**
  49600. * Gets the impostor for a physics body object
  49601. * @param body defines physics body used by the impostor
  49602. * @returns the PhysicsImpostor or null if not found
  49603. */
  49604. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49605. /**
  49606. * Does a raycast in the physics world
  49607. * @param from when should the ray start?
  49608. * @param to when should the ray end?
  49609. * @returns PhysicsRaycastResult
  49610. */
  49611. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49612. }
  49613. }
  49614. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49615. import { Nullable } from "babylonjs/types";
  49616. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49618. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49619. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49620. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49621. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49622. /** @hidden */
  49623. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49624. private _useDeltaForWorldStep;
  49625. world: any;
  49626. name: string;
  49627. private _physicsMaterials;
  49628. private _fixedTimeStep;
  49629. private _cannonRaycastResult;
  49630. private _raycastResult;
  49631. private _removeAfterStep;
  49632. BJSCANNON: any;
  49633. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49634. setGravity(gravity: Vector3): void;
  49635. setTimeStep(timeStep: number): void;
  49636. getTimeStep(): number;
  49637. executeStep(delta: number): void;
  49638. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49639. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49640. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49641. private _processChildMeshes;
  49642. removePhysicsBody(impostor: PhysicsImpostor): void;
  49643. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49644. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49645. private _addMaterial;
  49646. private _checkWithEpsilon;
  49647. private _createShape;
  49648. private _createHeightmap;
  49649. private _minus90X;
  49650. private _plus90X;
  49651. private _tmpPosition;
  49652. private _tmpDeltaPosition;
  49653. private _tmpUnityRotation;
  49654. private _updatePhysicsBodyTransformation;
  49655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49657. isSupported(): boolean;
  49658. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49659. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49660. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49661. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49662. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49663. getBodyMass(impostor: PhysicsImpostor): number;
  49664. getBodyFriction(impostor: PhysicsImpostor): number;
  49665. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49666. getBodyRestitution(impostor: PhysicsImpostor): number;
  49667. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49668. sleepBody(impostor: PhysicsImpostor): void;
  49669. wakeUpBody(impostor: PhysicsImpostor): void;
  49670. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49671. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49672. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49673. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49674. getRadius(impostor: PhysicsImpostor): number;
  49675. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49676. dispose(): void;
  49677. private _extendNamespace;
  49678. /**
  49679. * Does a raycast in the physics world
  49680. * @param from when should the ray start?
  49681. * @param to when should the ray end?
  49682. * @returns PhysicsRaycastResult
  49683. */
  49684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49685. }
  49686. }
  49687. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49688. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49689. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49690. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49692. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49693. import { Nullable } from "babylonjs/types";
  49694. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49695. /** @hidden */
  49696. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49697. world: any;
  49698. name: string;
  49699. BJSOIMO: any;
  49700. private _raycastResult;
  49701. constructor(iterations?: number, oimoInjection?: any);
  49702. setGravity(gravity: Vector3): void;
  49703. setTimeStep(timeStep: number): void;
  49704. getTimeStep(): number;
  49705. private _tmpImpostorsArray;
  49706. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49710. private _tmpPositionVector;
  49711. removePhysicsBody(impostor: PhysicsImpostor): void;
  49712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49714. isSupported(): boolean;
  49715. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49716. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49717. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49718. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49719. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49720. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49722. getBodyMass(impostor: PhysicsImpostor): number;
  49723. getBodyFriction(impostor: PhysicsImpostor): number;
  49724. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49725. getBodyRestitution(impostor: PhysicsImpostor): number;
  49726. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49727. sleepBody(impostor: PhysicsImpostor): void;
  49728. wakeUpBody(impostor: PhysicsImpostor): void;
  49729. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49730. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49731. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49732. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49733. getRadius(impostor: PhysicsImpostor): number;
  49734. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49735. dispose(): void;
  49736. /**
  49737. * Does a raycast in the physics world
  49738. * @param from when should the ray start?
  49739. * @param to when should the ray end?
  49740. * @returns PhysicsRaycastResult
  49741. */
  49742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49743. }
  49744. }
  49745. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49746. import { Nullable } from "babylonjs/types";
  49747. import { Scene } from "babylonjs/scene";
  49748. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49749. import { Mesh } from "babylonjs/Meshes/mesh";
  49750. /**
  49751. * Class containing static functions to help procedurally build meshes
  49752. */
  49753. export class RibbonBuilder {
  49754. /**
  49755. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49756. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49757. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49758. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49759. * * 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
  49760. * * 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
  49761. * * 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
  49762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49765. * * 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
  49766. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49767. * * 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
  49768. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49770. * @param name defines the name of the mesh
  49771. * @param options defines the options used to create the mesh
  49772. * @param scene defines the hosting scene
  49773. * @returns the ribbon mesh
  49774. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49776. */
  49777. static CreateRibbon(name: string, options: {
  49778. pathArray: Vector3[][];
  49779. closeArray?: boolean;
  49780. closePath?: boolean;
  49781. offset?: number;
  49782. updatable?: boolean;
  49783. sideOrientation?: number;
  49784. frontUVs?: Vector4;
  49785. backUVs?: Vector4;
  49786. instance?: Mesh;
  49787. invertUV?: boolean;
  49788. uvs?: Vector2[];
  49789. colors?: Color4[];
  49790. }, scene?: Nullable<Scene>): Mesh;
  49791. }
  49792. }
  49793. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49794. import { Nullable } from "babylonjs/types";
  49795. import { Scene } from "babylonjs/scene";
  49796. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49797. import { Mesh } from "babylonjs/Meshes/mesh";
  49798. /**
  49799. * Class containing static functions to help procedurally build meshes
  49800. */
  49801. export class ShapeBuilder {
  49802. /**
  49803. * 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.
  49804. * * 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.
  49805. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49806. * * 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.
  49807. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49808. * * 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
  49809. * * 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
  49810. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49815. * @param name defines the name of the mesh
  49816. * @param options defines the options used to create the mesh
  49817. * @param scene defines the hosting scene
  49818. * @returns the extruded shape mesh
  49819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49821. */
  49822. static ExtrudeShape(name: string, options: {
  49823. shape: Vector3[];
  49824. path: Vector3[];
  49825. scale?: number;
  49826. rotation?: number;
  49827. cap?: number;
  49828. updatable?: boolean;
  49829. sideOrientation?: number;
  49830. frontUVs?: Vector4;
  49831. backUVs?: Vector4;
  49832. instance?: Mesh;
  49833. invertUV?: boolean;
  49834. }, scene?: Nullable<Scene>): Mesh;
  49835. /**
  49836. * Creates an custom extruded shape mesh.
  49837. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49838. * * 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.
  49839. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49840. * * 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
  49841. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49842. * * 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
  49843. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49844. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49845. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49846. * * 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
  49847. * * 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
  49848. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49853. * @param name defines the name of the mesh
  49854. * @param options defines the options used to create the mesh
  49855. * @param scene defines the hosting scene
  49856. * @returns the custom extruded shape mesh
  49857. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49858. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49860. */
  49861. static ExtrudeShapeCustom(name: string, options: {
  49862. shape: Vector3[];
  49863. path: Vector3[];
  49864. scaleFunction?: any;
  49865. rotationFunction?: any;
  49866. ribbonCloseArray?: boolean;
  49867. ribbonClosePath?: boolean;
  49868. cap?: number;
  49869. updatable?: boolean;
  49870. sideOrientation?: number;
  49871. frontUVs?: Vector4;
  49872. backUVs?: Vector4;
  49873. instance?: Mesh;
  49874. invertUV?: boolean;
  49875. }, scene: Scene): Mesh;
  49876. private static _ExtrudeShapeGeneric;
  49877. }
  49878. }
  49879. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  49880. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  49881. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49882. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49883. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49884. import { Nullable } from "babylonjs/types";
  49885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49886. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49887. /**
  49888. * AmmoJS Physics plugin
  49889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49890. * @see https://github.com/kripken/ammo.js/
  49891. */
  49892. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49893. private _useDeltaForWorldStep;
  49894. /**
  49895. * Reference to the Ammo library
  49896. */
  49897. bjsAMMO: any;
  49898. /**
  49899. * Created ammoJS world which physics bodies are added to
  49900. */
  49901. world: any;
  49902. /**
  49903. * Name of the plugin
  49904. */
  49905. name: string;
  49906. private _timeStep;
  49907. private _fixedTimeStep;
  49908. private _maxSteps;
  49909. private _tmpQuaternion;
  49910. private _tmpAmmoTransform;
  49911. private _tmpAmmoQuaternion;
  49912. private _tmpAmmoConcreteContactResultCallback;
  49913. private _collisionConfiguration;
  49914. private _dispatcher;
  49915. private _overlappingPairCache;
  49916. private _solver;
  49917. private _softBodySolver;
  49918. private _tmpAmmoVectorA;
  49919. private _tmpAmmoVectorB;
  49920. private _tmpAmmoVectorC;
  49921. private _tmpAmmoVectorD;
  49922. private _tmpContactCallbackResult;
  49923. private _tmpAmmoVectorRCA;
  49924. private _tmpAmmoVectorRCB;
  49925. private _raycastResult;
  49926. private static readonly DISABLE_COLLISION_FLAG;
  49927. private static readonly KINEMATIC_FLAG;
  49928. private static readonly DISABLE_DEACTIVATION_FLAG;
  49929. /**
  49930. * Initializes the ammoJS plugin
  49931. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49932. * @param ammoInjection can be used to inject your own ammo reference
  49933. */
  49934. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49935. /**
  49936. * Sets the gravity of the physics world (m/(s^2))
  49937. * @param gravity Gravity to set
  49938. */
  49939. setGravity(gravity: Vector3): void;
  49940. /**
  49941. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49942. * @param timeStep timestep to use in seconds
  49943. */
  49944. setTimeStep(timeStep: number): void;
  49945. /**
  49946. * 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)
  49947. * @param fixedTimeStep fixedTimeStep to use in seconds
  49948. */
  49949. setFixedTimeStep(fixedTimeStep: number): void;
  49950. /**
  49951. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49952. * @param maxSteps the maximum number of steps by the physics engine per frame
  49953. */
  49954. setMaxSteps(maxSteps: number): void;
  49955. /**
  49956. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49957. * @returns the current timestep in seconds
  49958. */
  49959. getTimeStep(): number;
  49960. private _isImpostorInContact;
  49961. private _isImpostorPairInContact;
  49962. private _stepSimulation;
  49963. /**
  49964. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49965. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49966. * After the step the babylon meshes are set to the position of the physics imposters
  49967. * @param delta amount of time to step forward
  49968. * @param impostors array of imposters to update before/after the step
  49969. */
  49970. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49971. /**
  49972. * Update babylon mesh to match physics world object
  49973. * @param impostor imposter to match
  49974. */
  49975. private _afterSoftStep;
  49976. /**
  49977. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49978. * @param impostor imposter to match
  49979. */
  49980. private _ropeStep;
  49981. /**
  49982. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49983. * @param impostor imposter to match
  49984. */
  49985. private _softbodyOrClothStep;
  49986. private _tmpVector;
  49987. private _tmpMatrix;
  49988. /**
  49989. * Applies an impulse on the imposter
  49990. * @param impostor imposter to apply impulse to
  49991. * @param force amount of force to be applied to the imposter
  49992. * @param contactPoint the location to apply the impulse on the imposter
  49993. */
  49994. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49995. /**
  49996. * Applies a force on the imposter
  49997. * @param impostor imposter to apply force
  49998. * @param force amount of force to be applied to the imposter
  49999. * @param contactPoint the location to apply the force on the imposter
  50000. */
  50001. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50002. /**
  50003. * Creates a physics body using the plugin
  50004. * @param impostor the imposter to create the physics body on
  50005. */
  50006. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50007. /**
  50008. * Removes the physics body from the imposter and disposes of the body's memory
  50009. * @param impostor imposter to remove the physics body from
  50010. */
  50011. removePhysicsBody(impostor: PhysicsImpostor): void;
  50012. /**
  50013. * Generates a joint
  50014. * @param impostorJoint the imposter joint to create the joint with
  50015. */
  50016. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50017. /**
  50018. * Removes a joint
  50019. * @param impostorJoint the imposter joint to remove the joint from
  50020. */
  50021. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50022. private _addMeshVerts;
  50023. /**
  50024. * Initialise the soft body vertices to match its object's (mesh) vertices
  50025. * Softbody vertices (nodes) are in world space and to match this
  50026. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50027. * @param impostor to create the softbody for
  50028. */
  50029. private _softVertexData;
  50030. /**
  50031. * Create an impostor's soft body
  50032. * @param impostor to create the softbody for
  50033. */
  50034. private _createSoftbody;
  50035. /**
  50036. * Create cloth for an impostor
  50037. * @param impostor to create the softbody for
  50038. */
  50039. private _createCloth;
  50040. /**
  50041. * Create rope for an impostor
  50042. * @param impostor to create the softbody for
  50043. */
  50044. private _createRope;
  50045. private _addHullVerts;
  50046. private _createShape;
  50047. /**
  50048. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50049. * @param impostor imposter containing the physics body and babylon object
  50050. */
  50051. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50052. /**
  50053. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50054. * @param impostor imposter containing the physics body and babylon object
  50055. * @param newPosition new position
  50056. * @param newRotation new rotation
  50057. */
  50058. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50059. /**
  50060. * If this plugin is supported
  50061. * @returns true if its supported
  50062. */
  50063. isSupported(): boolean;
  50064. /**
  50065. * Sets the linear velocity of the physics body
  50066. * @param impostor imposter to set the velocity on
  50067. * @param velocity velocity to set
  50068. */
  50069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50070. /**
  50071. * Sets the angular velocity of the physics body
  50072. * @param impostor imposter to set the velocity on
  50073. * @param velocity velocity to set
  50074. */
  50075. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50076. /**
  50077. * gets the linear velocity
  50078. * @param impostor imposter to get linear velocity from
  50079. * @returns linear velocity
  50080. */
  50081. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50082. /**
  50083. * gets the angular velocity
  50084. * @param impostor imposter to get angular velocity from
  50085. * @returns angular velocity
  50086. */
  50087. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50088. /**
  50089. * Sets the mass of physics body
  50090. * @param impostor imposter to set the mass on
  50091. * @param mass mass to set
  50092. */
  50093. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50094. /**
  50095. * Gets the mass of the physics body
  50096. * @param impostor imposter to get the mass from
  50097. * @returns mass
  50098. */
  50099. getBodyMass(impostor: PhysicsImpostor): number;
  50100. /**
  50101. * Gets friction of the impostor
  50102. * @param impostor impostor to get friction from
  50103. * @returns friction value
  50104. */
  50105. getBodyFriction(impostor: PhysicsImpostor): number;
  50106. /**
  50107. * Sets friction of the impostor
  50108. * @param impostor impostor to set friction on
  50109. * @param friction friction value
  50110. */
  50111. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50112. /**
  50113. * Gets restitution of the impostor
  50114. * @param impostor impostor to get restitution from
  50115. * @returns restitution value
  50116. */
  50117. getBodyRestitution(impostor: PhysicsImpostor): number;
  50118. /**
  50119. * Sets resitution of the impostor
  50120. * @param impostor impostor to set resitution on
  50121. * @param restitution resitution value
  50122. */
  50123. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50124. /**
  50125. * Gets pressure inside the impostor
  50126. * @param impostor impostor to get pressure from
  50127. * @returns pressure value
  50128. */
  50129. getBodyPressure(impostor: PhysicsImpostor): number;
  50130. /**
  50131. * Sets pressure inside a soft body impostor
  50132. * Cloth and rope must remain 0 pressure
  50133. * @param impostor impostor to set pressure on
  50134. * @param pressure pressure value
  50135. */
  50136. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50137. /**
  50138. * Gets stiffness of the impostor
  50139. * @param impostor impostor to get stiffness from
  50140. * @returns pressure value
  50141. */
  50142. getBodyStiffness(impostor: PhysicsImpostor): number;
  50143. /**
  50144. * Sets stiffness of the impostor
  50145. * @param impostor impostor to set stiffness on
  50146. * @param stiffness stiffness value from 0 to 1
  50147. */
  50148. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50149. /**
  50150. * Gets velocityIterations of the impostor
  50151. * @param impostor impostor to get velocity iterations from
  50152. * @returns velocityIterations value
  50153. */
  50154. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50155. /**
  50156. * Sets velocityIterations of the impostor
  50157. * @param impostor impostor to set velocity iterations on
  50158. * @param velocityIterations velocityIterations value
  50159. */
  50160. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50161. /**
  50162. * Gets positionIterations of the impostor
  50163. * @param impostor impostor to get position iterations from
  50164. * @returns positionIterations value
  50165. */
  50166. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50167. /**
  50168. * Sets positionIterations of the impostor
  50169. * @param impostor impostor to set position on
  50170. * @param positionIterations positionIterations value
  50171. */
  50172. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50173. /**
  50174. * Append an anchor to a cloth object
  50175. * @param impostor is the cloth impostor to add anchor to
  50176. * @param otherImpostor is the rigid impostor to anchor to
  50177. * @param width ratio across width from 0 to 1
  50178. * @param height ratio up height from 0 to 1
  50179. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50180. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50181. */
  50182. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50183. /**
  50184. * Append an hook to a rope object
  50185. * @param impostor is the rope impostor to add hook to
  50186. * @param otherImpostor is the rigid impostor to hook to
  50187. * @param length ratio along the rope from 0 to 1
  50188. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50189. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50190. */
  50191. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50192. /**
  50193. * Sleeps the physics body and stops it from being active
  50194. * @param impostor impostor to sleep
  50195. */
  50196. sleepBody(impostor: PhysicsImpostor): void;
  50197. /**
  50198. * Activates the physics body
  50199. * @param impostor impostor to activate
  50200. */
  50201. wakeUpBody(impostor: PhysicsImpostor): void;
  50202. /**
  50203. * Updates the distance parameters of the joint
  50204. * @param joint joint to update
  50205. * @param maxDistance maximum distance of the joint
  50206. * @param minDistance minimum distance of the joint
  50207. */
  50208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50209. /**
  50210. * Sets a motor on the joint
  50211. * @param joint joint to set motor on
  50212. * @param speed speed of the motor
  50213. * @param maxForce maximum force of the motor
  50214. * @param motorIndex index of the motor
  50215. */
  50216. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50217. /**
  50218. * Sets the motors limit
  50219. * @param joint joint to set limit on
  50220. * @param upperLimit upper limit
  50221. * @param lowerLimit lower limit
  50222. */
  50223. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50224. /**
  50225. * Syncs the position and rotation of a mesh with the impostor
  50226. * @param mesh mesh to sync
  50227. * @param impostor impostor to update the mesh with
  50228. */
  50229. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50230. /**
  50231. * Gets the radius of the impostor
  50232. * @param impostor impostor to get radius from
  50233. * @returns the radius
  50234. */
  50235. getRadius(impostor: PhysicsImpostor): number;
  50236. /**
  50237. * Gets the box size of the impostor
  50238. * @param impostor impostor to get box size from
  50239. * @param result the resulting box size
  50240. */
  50241. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50242. /**
  50243. * Disposes of the impostor
  50244. */
  50245. dispose(): void;
  50246. /**
  50247. * Does a raycast in the physics world
  50248. * @param from when should the ray start?
  50249. * @param to when should the ray end?
  50250. * @returns PhysicsRaycastResult
  50251. */
  50252. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50253. }
  50254. }
  50255. declare module "babylonjs/Probes/reflectionProbe" {
  50256. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50257. import { Vector3 } from "babylonjs/Maths/math";
  50258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50259. import { Nullable } from "babylonjs/types";
  50260. import { Scene } from "babylonjs/scene";
  50261. module "babylonjs/abstractScene" {
  50262. interface AbstractScene {
  50263. /**
  50264. * The list of reflection probes added to the scene
  50265. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50266. */
  50267. reflectionProbes: Array<ReflectionProbe>;
  50268. /**
  50269. * Removes the given reflection probe from this scene.
  50270. * @param toRemove The reflection probe to remove
  50271. * @returns The index of the removed reflection probe
  50272. */
  50273. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50274. /**
  50275. * Adds the given reflection probe to this scene.
  50276. * @param newReflectionProbe The reflection probe to add
  50277. */
  50278. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50279. }
  50280. }
  50281. /**
  50282. * Class used to generate realtime reflection / refraction cube textures
  50283. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50284. */
  50285. export class ReflectionProbe {
  50286. /** defines the name of the probe */
  50287. name: string;
  50288. private _scene;
  50289. private _renderTargetTexture;
  50290. private _projectionMatrix;
  50291. private _viewMatrix;
  50292. private _target;
  50293. private _add;
  50294. private _attachedMesh;
  50295. private _invertYAxis;
  50296. /** Gets or sets probe position (center of the cube map) */
  50297. position: Vector3;
  50298. /**
  50299. * Creates a new reflection probe
  50300. * @param name defines the name of the probe
  50301. * @param size defines the texture resolution (for each face)
  50302. * @param scene defines the hosting scene
  50303. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50304. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50305. */
  50306. constructor(
  50307. /** defines the name of the probe */
  50308. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50309. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50310. samples: number;
  50311. /** Gets or sets the refresh rate to use (on every frame by default) */
  50312. refreshRate: number;
  50313. /**
  50314. * Gets the hosting scene
  50315. * @returns a Scene
  50316. */
  50317. getScene(): Scene;
  50318. /** Gets the internal CubeTexture used to render to */
  50319. readonly cubeTexture: RenderTargetTexture;
  50320. /** Gets the list of meshes to render */
  50321. readonly renderList: Nullable<AbstractMesh[]>;
  50322. /**
  50323. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50324. * @param mesh defines the mesh to attach to
  50325. */
  50326. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50327. /**
  50328. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50329. * @param renderingGroupId The rendering group id corresponding to its index
  50330. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50331. */
  50332. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50333. /**
  50334. * Clean all associated resources
  50335. */
  50336. dispose(): void;
  50337. /**
  50338. * Converts the reflection probe information to a readable string for debug purpose.
  50339. * @param fullDetails Supports for multiple levels of logging within scene loading
  50340. * @returns the human readable reflection probe info
  50341. */
  50342. toString(fullDetails?: boolean): string;
  50343. /**
  50344. * Get the class name of the relfection probe.
  50345. * @returns "ReflectionProbe"
  50346. */
  50347. getClassName(): string;
  50348. /**
  50349. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50350. * @returns The JSON representation of the texture
  50351. */
  50352. serialize(): any;
  50353. /**
  50354. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50355. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50356. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50357. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50358. * @returns The parsed reflection probe if successful
  50359. */
  50360. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50361. }
  50362. }
  50363. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50364. /** @hidden */
  50365. export var _BabylonLoaderRegistered: boolean;
  50366. }
  50367. declare module "babylonjs/Loading/Plugins/index" {
  50368. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50369. }
  50370. declare module "babylonjs/Loading/index" {
  50371. export * from "babylonjs/Loading/loadingScreen";
  50372. export * from "babylonjs/Loading/Plugins/index";
  50373. export * from "babylonjs/Loading/sceneLoader";
  50374. export * from "babylonjs/Loading/sceneLoaderFlags";
  50375. }
  50376. declare module "babylonjs/Materials/Background/index" {
  50377. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50378. }
  50379. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50380. import { Scene } from "babylonjs/scene";
  50381. import { Color3 } from "babylonjs/Maths/math";
  50382. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50384. /**
  50385. * The Physically based simple base material of BJS.
  50386. *
  50387. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50388. * It is used as the base class for both the specGloss and metalRough conventions.
  50389. */
  50390. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50391. /**
  50392. * Number of Simultaneous lights allowed on the material.
  50393. */
  50394. maxSimultaneousLights: number;
  50395. /**
  50396. * If sets to true, disables all the lights affecting the material.
  50397. */
  50398. disableLighting: boolean;
  50399. /**
  50400. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50401. */
  50402. environmentTexture: BaseTexture;
  50403. /**
  50404. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50405. */
  50406. invertNormalMapX: boolean;
  50407. /**
  50408. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50409. */
  50410. invertNormalMapY: boolean;
  50411. /**
  50412. * Normal map used in the model.
  50413. */
  50414. normalTexture: BaseTexture;
  50415. /**
  50416. * Emissivie color used to self-illuminate the model.
  50417. */
  50418. emissiveColor: Color3;
  50419. /**
  50420. * Emissivie texture used to self-illuminate the model.
  50421. */
  50422. emissiveTexture: BaseTexture;
  50423. /**
  50424. * Occlusion Channel Strenght.
  50425. */
  50426. occlusionStrength: number;
  50427. /**
  50428. * Occlusion Texture of the material (adding extra occlusion effects).
  50429. */
  50430. occlusionTexture: BaseTexture;
  50431. /**
  50432. * Defines the alpha limits in alpha test mode.
  50433. */
  50434. alphaCutOff: number;
  50435. /**
  50436. * Gets the current double sided mode.
  50437. */
  50438. /**
  50439. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50440. */
  50441. doubleSided: boolean;
  50442. /**
  50443. * Stores the pre-calculated light information of a mesh in a texture.
  50444. */
  50445. lightmapTexture: BaseTexture;
  50446. /**
  50447. * If true, the light map contains occlusion information instead of lighting info.
  50448. */
  50449. useLightmapAsShadowmap: boolean;
  50450. /**
  50451. * Instantiates a new PBRMaterial instance.
  50452. *
  50453. * @param name The material name
  50454. * @param scene The scene the material will be use in.
  50455. */
  50456. constructor(name: string, scene: Scene);
  50457. getClassName(): string;
  50458. }
  50459. }
  50460. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50461. import { Scene } from "babylonjs/scene";
  50462. import { Color3 } from "babylonjs/Maths/math";
  50463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50464. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50465. /**
  50466. * The PBR material of BJS following the metal roughness convention.
  50467. *
  50468. * This fits to the PBR convention in the GLTF definition:
  50469. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50470. */
  50471. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50472. /**
  50473. * The base color has two different interpretations depending on the value of metalness.
  50474. * When the material is a metal, the base color is the specific measured reflectance value
  50475. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50476. * of the material.
  50477. */
  50478. baseColor: Color3;
  50479. /**
  50480. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50481. * well as opacity information in the alpha channel.
  50482. */
  50483. baseTexture: BaseTexture;
  50484. /**
  50485. * Specifies the metallic scalar value of the material.
  50486. * Can also be used to scale the metalness values of the metallic texture.
  50487. */
  50488. metallic: number;
  50489. /**
  50490. * Specifies the roughness scalar value of the material.
  50491. * Can also be used to scale the roughness values of the metallic texture.
  50492. */
  50493. roughness: number;
  50494. /**
  50495. * Texture containing both the metallic value in the B channel and the
  50496. * roughness value in the G channel to keep better precision.
  50497. */
  50498. metallicRoughnessTexture: BaseTexture;
  50499. /**
  50500. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50501. *
  50502. * @param name The material name
  50503. * @param scene The scene the material will be use in.
  50504. */
  50505. constructor(name: string, scene: Scene);
  50506. /**
  50507. * Return the currrent class name of the material.
  50508. */
  50509. getClassName(): string;
  50510. /**
  50511. * Makes a duplicate of the current material.
  50512. * @param name - name to use for the new material.
  50513. */
  50514. clone(name: string): PBRMetallicRoughnessMaterial;
  50515. /**
  50516. * Serialize the material to a parsable JSON object.
  50517. */
  50518. serialize(): any;
  50519. /**
  50520. * Parses a JSON object correponding to the serialize function.
  50521. */
  50522. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50523. }
  50524. }
  50525. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50526. import { Scene } from "babylonjs/scene";
  50527. import { Color3 } from "babylonjs/Maths/math";
  50528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50529. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50530. /**
  50531. * The PBR material of BJS following the specular glossiness convention.
  50532. *
  50533. * This fits to the PBR convention in the GLTF definition:
  50534. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50535. */
  50536. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50537. /**
  50538. * Specifies the diffuse color of the material.
  50539. */
  50540. diffuseColor: Color3;
  50541. /**
  50542. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50543. * channel.
  50544. */
  50545. diffuseTexture: BaseTexture;
  50546. /**
  50547. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50548. */
  50549. specularColor: Color3;
  50550. /**
  50551. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50552. */
  50553. glossiness: number;
  50554. /**
  50555. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50556. */
  50557. specularGlossinessTexture: BaseTexture;
  50558. /**
  50559. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50560. *
  50561. * @param name The material name
  50562. * @param scene The scene the material will be use in.
  50563. */
  50564. constructor(name: string, scene: Scene);
  50565. /**
  50566. * Return the currrent class name of the material.
  50567. */
  50568. getClassName(): string;
  50569. /**
  50570. * Makes a duplicate of the current material.
  50571. * @param name - name to use for the new material.
  50572. */
  50573. clone(name: string): PBRSpecularGlossinessMaterial;
  50574. /**
  50575. * Serialize the material to a parsable JSON object.
  50576. */
  50577. serialize(): any;
  50578. /**
  50579. * Parses a JSON object correponding to the serialize function.
  50580. */
  50581. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50582. }
  50583. }
  50584. declare module "babylonjs/Materials/PBR/index" {
  50585. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50586. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50587. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50588. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50589. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50590. }
  50591. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50592. import { Nullable } from "babylonjs/types";
  50593. import { Scene } from "babylonjs/scene";
  50594. import { Matrix } from "babylonjs/Maths/math";
  50595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50596. /**
  50597. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50598. * It can help converting any input color in a desired output one. This can then be used to create effects
  50599. * from sepia, black and white to sixties or futuristic rendering...
  50600. *
  50601. * The only supported format is currently 3dl.
  50602. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50603. */
  50604. export class ColorGradingTexture extends BaseTexture {
  50605. /**
  50606. * The current texture matrix. (will always be identity in color grading texture)
  50607. */
  50608. private _textureMatrix;
  50609. /**
  50610. * The texture URL.
  50611. */
  50612. url: string;
  50613. /**
  50614. * Empty line regex stored for GC.
  50615. */
  50616. private static _noneEmptyLineRegex;
  50617. private _engine;
  50618. /**
  50619. * Instantiates a ColorGradingTexture from the following parameters.
  50620. *
  50621. * @param url The location of the color gradind data (currently only supporting 3dl)
  50622. * @param scene The scene the texture will be used in
  50623. */
  50624. constructor(url: string, scene: Scene);
  50625. /**
  50626. * Returns the texture matrix used in most of the material.
  50627. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50628. */
  50629. getTextureMatrix(): Matrix;
  50630. /**
  50631. * Occurs when the file being loaded is a .3dl LUT file.
  50632. */
  50633. private load3dlTexture;
  50634. /**
  50635. * Starts the loading process of the texture.
  50636. */
  50637. private loadTexture;
  50638. /**
  50639. * Clones the color gradind texture.
  50640. */
  50641. clone(): ColorGradingTexture;
  50642. /**
  50643. * Called during delayed load for textures.
  50644. */
  50645. delayLoad(): void;
  50646. /**
  50647. * Parses a color grading texture serialized by Babylon.
  50648. * @param parsedTexture The texture information being parsedTexture
  50649. * @param scene The scene to load the texture in
  50650. * @param rootUrl The root url of the data assets to load
  50651. * @return A color gradind texture
  50652. */
  50653. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50654. /**
  50655. * Serializes the LUT texture to json format.
  50656. */
  50657. serialize(): any;
  50658. }
  50659. }
  50660. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50661. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50662. import { Scene } from "babylonjs/scene";
  50663. import { Nullable } from "babylonjs/types";
  50664. /**
  50665. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50666. */
  50667. export class EquiRectangularCubeTexture extends BaseTexture {
  50668. /** The six faces of the cube. */
  50669. private static _FacesMapping;
  50670. private _noMipmap;
  50671. private _onLoad;
  50672. private _onError;
  50673. /** The size of the cubemap. */
  50674. private _size;
  50675. /** The buffer of the image. */
  50676. private _buffer;
  50677. /** The width of the input image. */
  50678. private _width;
  50679. /** The height of the input image. */
  50680. private _height;
  50681. /** The URL to the image. */
  50682. url: string;
  50683. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50684. coordinatesMode: number;
  50685. /**
  50686. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50687. * @param url The location of the image
  50688. * @param scene The scene the texture will be used in
  50689. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50690. * @param noMipmap Forces to not generate the mipmap if true
  50691. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50692. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50693. * @param onLoad — defines a callback called when texture is loaded
  50694. * @param onError — defines a callback called if there is an error
  50695. */
  50696. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50697. /**
  50698. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50699. */
  50700. private loadImage;
  50701. /**
  50702. * Convert the image buffer into a cubemap and create a CubeTexture.
  50703. */
  50704. private loadTexture;
  50705. /**
  50706. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50707. * @param buffer The ArrayBuffer that should be converted.
  50708. * @returns The buffer as Float32Array.
  50709. */
  50710. private getFloat32ArrayFromArrayBuffer;
  50711. /**
  50712. * Get the current class name of the texture useful for serialization or dynamic coding.
  50713. * @returns "EquiRectangularCubeTexture"
  50714. */
  50715. getClassName(): string;
  50716. /**
  50717. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50718. * @returns A clone of the current EquiRectangularCubeTexture.
  50719. */
  50720. clone(): EquiRectangularCubeTexture;
  50721. }
  50722. }
  50723. declare module "babylonjs/Misc/tga" {
  50724. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50725. /**
  50726. * Based on jsTGALoader - Javascript loader for TGA file
  50727. * By Vincent Thibault
  50728. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50729. */
  50730. export class TGATools {
  50731. private static _TYPE_INDEXED;
  50732. private static _TYPE_RGB;
  50733. private static _TYPE_GREY;
  50734. private static _TYPE_RLE_INDEXED;
  50735. private static _TYPE_RLE_RGB;
  50736. private static _TYPE_RLE_GREY;
  50737. private static _ORIGIN_MASK;
  50738. private static _ORIGIN_SHIFT;
  50739. private static _ORIGIN_BL;
  50740. private static _ORIGIN_BR;
  50741. private static _ORIGIN_UL;
  50742. private static _ORIGIN_UR;
  50743. /**
  50744. * Gets the header of a TGA file
  50745. * @param data defines the TGA data
  50746. * @returns the header
  50747. */
  50748. static GetTGAHeader(data: Uint8Array): any;
  50749. /**
  50750. * Uploads TGA content to a Babylon Texture
  50751. * @hidden
  50752. */
  50753. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50754. /** @hidden */
  50755. 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;
  50756. /** @hidden */
  50757. 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;
  50758. /** @hidden */
  50759. 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;
  50760. /** @hidden */
  50761. 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;
  50762. /** @hidden */
  50763. 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;
  50764. /** @hidden */
  50765. 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;
  50766. }
  50767. }
  50768. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  50769. import { Nullable } from "babylonjs/types";
  50770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50771. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50772. /**
  50773. * Implementation of the TGA Texture Loader.
  50774. * @hidden
  50775. */
  50776. export class _TGATextureLoader implements IInternalTextureLoader {
  50777. /**
  50778. * Defines wether the loader supports cascade loading the different faces.
  50779. */
  50780. readonly supportCascades: boolean;
  50781. /**
  50782. * This returns if the loader support the current file information.
  50783. * @param extension defines the file extension of the file being loaded
  50784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50785. * @param fallback defines the fallback internal texture if any
  50786. * @param isBase64 defines whether the texture is encoded as a base64
  50787. * @param isBuffer defines whether the texture data are stored as a buffer
  50788. * @returns true if the loader can load the specified file
  50789. */
  50790. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50791. /**
  50792. * Transform the url before loading if required.
  50793. * @param rootUrl the url of the texture
  50794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50795. * @returns the transformed texture
  50796. */
  50797. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50798. /**
  50799. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50800. * @param rootUrl the url of the texture
  50801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50802. * @returns the fallback texture
  50803. */
  50804. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50805. /**
  50806. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50807. * @param data contains the texture data
  50808. * @param texture defines the BabylonJS internal texture
  50809. * @param createPolynomials will be true if polynomials have been requested
  50810. * @param onLoad defines the callback to trigger once the texture is ready
  50811. * @param onError defines the callback to trigger in case of error
  50812. */
  50813. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50814. /**
  50815. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50816. * @param data contains the texture data
  50817. * @param texture defines the BabylonJS internal texture
  50818. * @param callback defines the method to call once ready to upload
  50819. */
  50820. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50821. }
  50822. }
  50823. declare module "babylonjs/Materials/Textures/Loaders/index" {
  50824. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50825. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50826. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50827. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  50828. }
  50829. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  50830. import { Scene } from "babylonjs/scene";
  50831. import { Texture } from "babylonjs/Materials/Textures/texture";
  50832. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50833. /**
  50834. * 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.
  50835. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50837. */
  50838. export class CustomProceduralTexture extends ProceduralTexture {
  50839. private _animate;
  50840. private _time;
  50841. private _config;
  50842. private _texturePath;
  50843. /**
  50844. * Instantiates a new Custom Procedural Texture.
  50845. * 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.
  50846. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50848. * @param name Define the name of the texture
  50849. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50850. * @param size Define the size of the texture to create
  50851. * @param scene Define the scene the texture belongs to
  50852. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50853. * @param generateMipMaps Define if the texture should creates mip maps or not
  50854. */
  50855. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50856. private _loadJson;
  50857. /**
  50858. * Is the texture ready to be used ? (rendered at least once)
  50859. * @returns true if ready, otherwise, false.
  50860. */
  50861. isReady(): boolean;
  50862. /**
  50863. * Render the texture to its associated render target.
  50864. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50865. */
  50866. render(useCameraPostProcess?: boolean): void;
  50867. /**
  50868. * Update the list of dependant textures samplers in the shader.
  50869. */
  50870. updateTextures(): void;
  50871. /**
  50872. * Update the uniform values of the procedural texture in the shader.
  50873. */
  50874. updateShaderUniforms(): void;
  50875. /**
  50876. * Define if the texture animates or not.
  50877. */
  50878. animate: boolean;
  50879. }
  50880. }
  50881. declare module "babylonjs/Shaders/noise.fragment" {
  50882. /** @hidden */
  50883. export var noisePixelShader: {
  50884. name: string;
  50885. shader: string;
  50886. };
  50887. }
  50888. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  50889. import { Nullable } from "babylonjs/types";
  50890. import { Scene } from "babylonjs/scene";
  50891. import { Texture } from "babylonjs/Materials/Textures/texture";
  50892. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50893. import "babylonjs/Shaders/noise.fragment";
  50894. /**
  50895. * Class used to generate noise procedural textures
  50896. */
  50897. export class NoiseProceduralTexture extends ProceduralTexture {
  50898. private _time;
  50899. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50900. brightness: number;
  50901. /** Defines the number of octaves to process */
  50902. octaves: number;
  50903. /** Defines the level of persistence (0.8 by default) */
  50904. persistence: number;
  50905. /** Gets or sets animation speed factor (default is 1) */
  50906. animationSpeedFactor: number;
  50907. /**
  50908. * Creates a new NoiseProceduralTexture
  50909. * @param name defines the name fo the texture
  50910. * @param size defines the size of the texture (default is 256)
  50911. * @param scene defines the hosting scene
  50912. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50913. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50914. */
  50915. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50916. private _updateShaderUniforms;
  50917. protected _getDefines(): string;
  50918. /** Generate the current state of the procedural texture */
  50919. render(useCameraPostProcess?: boolean): void;
  50920. /**
  50921. * Serializes this noise procedural texture
  50922. * @returns a serialized noise procedural texture object
  50923. */
  50924. serialize(): any;
  50925. /**
  50926. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50927. * @param parsedTexture defines parsed texture data
  50928. * @param scene defines the current scene
  50929. * @param rootUrl defines the root URL containing noise procedural texture information
  50930. * @returns a parsed NoiseProceduralTexture
  50931. */
  50932. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50933. }
  50934. }
  50935. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  50936. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  50937. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  50938. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  50939. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  50940. }
  50941. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  50942. import { Nullable } from "babylonjs/types";
  50943. import { Scene } from "babylonjs/scene";
  50944. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50946. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  50947. /**
  50948. * Raw cube texture where the raw buffers are passed in
  50949. */
  50950. export class RawCubeTexture extends CubeTexture {
  50951. /**
  50952. * Creates a cube texture where the raw buffers are passed in.
  50953. * @param scene defines the scene the texture is attached to
  50954. * @param data defines the array of data to use to create each face
  50955. * @param size defines the size of the textures
  50956. * @param format defines the format of the data
  50957. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50958. * @param generateMipMaps defines if the engine should generate the mip levels
  50959. * @param invertY defines if data must be stored with Y axis inverted
  50960. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50961. * @param compression defines the compression used (null by default)
  50962. */
  50963. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50964. /**
  50965. * Updates the raw cube texture.
  50966. * @param data defines the data to store
  50967. * @param format defines the data format
  50968. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50969. * @param invertY defines if data must be stored with Y axis inverted
  50970. * @param compression defines the compression used (null by default)
  50971. * @param level defines which level of the texture to update
  50972. */
  50973. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50974. /**
  50975. * Updates a raw cube texture with RGBD encoded data.
  50976. * @param data defines the array of data [mipmap][face] to use to create each face
  50977. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50978. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50979. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50980. * @returns a promsie that resolves when the operation is complete
  50981. */
  50982. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50983. /**
  50984. * Clones the raw cube texture.
  50985. * @return a new cube texture
  50986. */
  50987. clone(): CubeTexture;
  50988. /** @hidden */
  50989. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50990. }
  50991. }
  50992. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50993. import { Scene } from "babylonjs/scene";
  50994. import { Texture } from "babylonjs/Materials/Textures/texture";
  50995. /**
  50996. * Class used to store 3D textures containing user data
  50997. */
  50998. export class RawTexture3D extends Texture {
  50999. /** Gets or sets the texture format to use */
  51000. format: number;
  51001. private _engine;
  51002. /**
  51003. * Create a new RawTexture3D
  51004. * @param data defines the data of the texture
  51005. * @param width defines the width of the texture
  51006. * @param height defines the height of the texture
  51007. * @param depth defines the depth of the texture
  51008. * @param format defines the texture format to use
  51009. * @param scene defines the hosting scene
  51010. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51011. * @param invertY defines if texture must be stored with Y axis inverted
  51012. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51013. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51014. */
  51015. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51016. /** Gets or sets the texture format to use */
  51017. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51018. /**
  51019. * Update the texture with new data
  51020. * @param data defines the data to store in the texture
  51021. */
  51022. update(data: ArrayBufferView): void;
  51023. }
  51024. }
  51025. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51026. import { Scene } from "babylonjs/scene";
  51027. import { Plane } from "babylonjs/Maths/math";
  51028. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51029. /**
  51030. * Creates a refraction texture used by refraction channel of the standard material.
  51031. * It is like a mirror but to see through a material.
  51032. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51033. */
  51034. export class RefractionTexture extends RenderTargetTexture {
  51035. /**
  51036. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51037. * 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.
  51038. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51039. */
  51040. refractionPlane: Plane;
  51041. /**
  51042. * Define how deep under the surface we should see.
  51043. */
  51044. depth: number;
  51045. /**
  51046. * Creates a refraction texture used by refraction channel of the standard material.
  51047. * It is like a mirror but to see through a material.
  51048. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51049. * @param name Define the texture name
  51050. * @param size Define the size of the underlying texture
  51051. * @param scene Define the scene the refraction belongs to
  51052. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51053. */
  51054. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51055. /**
  51056. * Clone the refraction texture.
  51057. * @returns the cloned texture
  51058. */
  51059. clone(): RefractionTexture;
  51060. /**
  51061. * Serialize the texture to a JSON representation you could use in Parse later on
  51062. * @returns the serialized JSON representation
  51063. */
  51064. serialize(): any;
  51065. }
  51066. }
  51067. declare module "babylonjs/Materials/Textures/index" {
  51068. export * from "babylonjs/Materials/Textures/baseTexture";
  51069. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51070. export * from "babylonjs/Materials/Textures/cubeTexture";
  51071. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51072. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51073. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51074. export * from "babylonjs/Materials/Textures/internalTexture";
  51075. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51076. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  51077. export * from "babylonjs/Materials/Textures/Loaders/index";
  51078. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51079. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51080. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51081. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51082. export * from "babylonjs/Materials/Textures/rawTexture";
  51083. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51084. export * from "babylonjs/Materials/Textures/refractionTexture";
  51085. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51086. export * from "babylonjs/Materials/Textures/texture";
  51087. export * from "babylonjs/Materials/Textures/videoTexture";
  51088. }
  51089. declare module "babylonjs/Materials/index" {
  51090. export * from "babylonjs/Materials/Background/index";
  51091. export * from "babylonjs/Materials/colorCurves";
  51092. export * from "babylonjs/Materials/effect";
  51093. export * from "babylonjs/Materials/fresnelParameters";
  51094. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51095. export * from "babylonjs/Materials/material";
  51096. export * from "babylonjs/Materials/materialDefines";
  51097. export * from "babylonjs/Materials/materialHelper";
  51098. export * from "babylonjs/Materials/multiMaterial";
  51099. export * from "babylonjs/Materials/PBR/index";
  51100. export * from "babylonjs/Materials/pushMaterial";
  51101. export * from "babylonjs/Materials/shaderMaterial";
  51102. export * from "babylonjs/Materials/standardMaterial";
  51103. export * from "babylonjs/Materials/Textures/index";
  51104. export * from "babylonjs/Materials/uniformBuffer";
  51105. export * from "babylonjs/Materials/materialFlags";
  51106. }
  51107. declare module "babylonjs/Maths/index" {
  51108. export * from "babylonjs/Maths/math.scalar";
  51109. export * from "babylonjs/Maths/math";
  51110. export * from "babylonjs/Maths/sphericalPolynomial";
  51111. }
  51112. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51113. import { IDisposable } from "babylonjs/scene";
  51114. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51115. /**
  51116. * Configuration for Draco compression
  51117. */
  51118. export interface IDracoCompressionConfiguration {
  51119. /**
  51120. * Configuration for the decoder.
  51121. */
  51122. decoder?: {
  51123. /**
  51124. * The url to the WebAssembly module.
  51125. */
  51126. wasmUrl?: string;
  51127. /**
  51128. * The url to the WebAssembly binary.
  51129. */
  51130. wasmBinaryUrl?: string;
  51131. /**
  51132. * The url to the fallback JavaScript module.
  51133. */
  51134. fallbackUrl?: string;
  51135. };
  51136. }
  51137. /**
  51138. * Draco compression (https://google.github.io/draco/)
  51139. *
  51140. * This class wraps the Draco module.
  51141. *
  51142. * **Encoder**
  51143. *
  51144. * The encoder is not currently implemented.
  51145. *
  51146. * **Decoder**
  51147. *
  51148. * 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.
  51149. *
  51150. * To update the configuration, use the following code:
  51151. * ```javascript
  51152. * DracoCompression.Configuration = {
  51153. * decoder: {
  51154. * wasmUrl: "<url to the WebAssembly library>",
  51155. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51156. * fallbackUrl: "<url to the fallback JavaScript library>",
  51157. * }
  51158. * };
  51159. * ```
  51160. *
  51161. * 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.
  51162. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51163. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51164. *
  51165. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51166. * ```javascript
  51167. * var dracoCompression = new DracoCompression();
  51168. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51169. * [VertexBuffer.PositionKind]: 0
  51170. * });
  51171. * ```
  51172. *
  51173. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51174. */
  51175. export class DracoCompression implements IDisposable {
  51176. private static _DecoderModulePromise;
  51177. /**
  51178. * The configuration. Defaults to the following urls:
  51179. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51180. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51181. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51182. */
  51183. static Configuration: IDracoCompressionConfiguration;
  51184. /**
  51185. * Returns true if the decoder is available.
  51186. */
  51187. static readonly DecoderAvailable: boolean;
  51188. /**
  51189. * Constructor
  51190. */
  51191. constructor();
  51192. /**
  51193. * Stop all async operations and release resources.
  51194. */
  51195. dispose(): void;
  51196. /**
  51197. * Decode Draco compressed mesh data to vertex data.
  51198. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51199. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51200. * @returns A promise that resolves with the decoded vertex data
  51201. */
  51202. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51203. [kind: string]: number;
  51204. }): Promise<VertexData>;
  51205. private static _GetDecoderModule;
  51206. private static _LoadScriptAsync;
  51207. private static _LoadFileAsync;
  51208. }
  51209. }
  51210. declare module "babylonjs/Meshes/Compression/index" {
  51211. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51212. }
  51213. declare module "babylonjs/Meshes/csg" {
  51214. import { Nullable } from "babylonjs/types";
  51215. import { Scene } from "babylonjs/scene";
  51216. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51217. import { Mesh } from "babylonjs/Meshes/mesh";
  51218. import { Material } from "babylonjs/Materials/material";
  51219. /**
  51220. * Class for building Constructive Solid Geometry
  51221. */
  51222. export class CSG {
  51223. private polygons;
  51224. /**
  51225. * The world matrix
  51226. */
  51227. matrix: Matrix;
  51228. /**
  51229. * Stores the position
  51230. */
  51231. position: Vector3;
  51232. /**
  51233. * Stores the rotation
  51234. */
  51235. rotation: Vector3;
  51236. /**
  51237. * Stores the rotation quaternion
  51238. */
  51239. rotationQuaternion: Nullable<Quaternion>;
  51240. /**
  51241. * Stores the scaling vector
  51242. */
  51243. scaling: Vector3;
  51244. /**
  51245. * Convert the Mesh to CSG
  51246. * @param mesh The Mesh to convert to CSG
  51247. * @returns A new CSG from the Mesh
  51248. */
  51249. static FromMesh(mesh: Mesh): CSG;
  51250. /**
  51251. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51252. * @param polygons Polygons used to construct a CSG solid
  51253. */
  51254. private static FromPolygons;
  51255. /**
  51256. * Clones, or makes a deep copy, of the CSG
  51257. * @returns A new CSG
  51258. */
  51259. clone(): CSG;
  51260. /**
  51261. * Unions this CSG with another CSG
  51262. * @param csg The CSG to union against this CSG
  51263. * @returns The unioned CSG
  51264. */
  51265. union(csg: CSG): CSG;
  51266. /**
  51267. * Unions this CSG with another CSG in place
  51268. * @param csg The CSG to union against this CSG
  51269. */
  51270. unionInPlace(csg: CSG): void;
  51271. /**
  51272. * Subtracts this CSG with another CSG
  51273. * @param csg The CSG to subtract against this CSG
  51274. * @returns A new CSG
  51275. */
  51276. subtract(csg: CSG): CSG;
  51277. /**
  51278. * Subtracts this CSG with another CSG in place
  51279. * @param csg The CSG to subtact against this CSG
  51280. */
  51281. subtractInPlace(csg: CSG): void;
  51282. /**
  51283. * Intersect this CSG with another CSG
  51284. * @param csg The CSG to intersect against this CSG
  51285. * @returns A new CSG
  51286. */
  51287. intersect(csg: CSG): CSG;
  51288. /**
  51289. * Intersects this CSG with another CSG in place
  51290. * @param csg The CSG to intersect against this CSG
  51291. */
  51292. intersectInPlace(csg: CSG): void;
  51293. /**
  51294. * Return a new CSG solid with solid and empty space switched. This solid is
  51295. * not modified.
  51296. * @returns A new CSG solid with solid and empty space switched
  51297. */
  51298. inverse(): CSG;
  51299. /**
  51300. * Inverses the CSG in place
  51301. */
  51302. inverseInPlace(): void;
  51303. /**
  51304. * This is used to keep meshes transformations so they can be restored
  51305. * when we build back a Babylon Mesh
  51306. * NB : All CSG operations are performed in world coordinates
  51307. * @param csg The CSG to copy the transform attributes from
  51308. * @returns This CSG
  51309. */
  51310. copyTransformAttributes(csg: CSG): CSG;
  51311. /**
  51312. * Build Raw mesh from CSG
  51313. * Coordinates here are in world space
  51314. * @param name The name of the mesh geometry
  51315. * @param scene The Scene
  51316. * @param keepSubMeshes Specifies if the submeshes should be kept
  51317. * @returns A new Mesh
  51318. */
  51319. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51320. /**
  51321. * Build Mesh from CSG taking material and transforms into account
  51322. * @param name The name of the Mesh
  51323. * @param material The material of the Mesh
  51324. * @param scene The Scene
  51325. * @param keepSubMeshes Specifies if submeshes should be kept
  51326. * @returns The new Mesh
  51327. */
  51328. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51329. }
  51330. }
  51331. declare module "babylonjs/Meshes/trailMesh" {
  51332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51333. import { Mesh } from "babylonjs/Meshes/mesh";
  51334. import { Scene } from "babylonjs/scene";
  51335. /**
  51336. * Class used to create a trail following a mesh
  51337. */
  51338. export class TrailMesh extends Mesh {
  51339. private _generator;
  51340. private _autoStart;
  51341. private _running;
  51342. private _diameter;
  51343. private _length;
  51344. private _sectionPolygonPointsCount;
  51345. private _sectionVectors;
  51346. private _sectionNormalVectors;
  51347. private _beforeRenderObserver;
  51348. /**
  51349. * @constructor
  51350. * @param name The value used by scene.getMeshByName() to do a lookup.
  51351. * @param generator The mesh to generate a trail.
  51352. * @param scene The scene to add this mesh to.
  51353. * @param diameter Diameter of trailing mesh. Default is 1.
  51354. * @param length Length of trailing mesh. Default is 60.
  51355. * @param autoStart Automatically start trailing mesh. Default true.
  51356. */
  51357. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51358. /**
  51359. * "TrailMesh"
  51360. * @returns "TrailMesh"
  51361. */
  51362. getClassName(): string;
  51363. private _createMesh;
  51364. /**
  51365. * Start trailing mesh.
  51366. */
  51367. start(): void;
  51368. /**
  51369. * Stop trailing mesh.
  51370. */
  51371. stop(): void;
  51372. /**
  51373. * Update trailing mesh geometry.
  51374. */
  51375. update(): void;
  51376. /**
  51377. * Returns a new TrailMesh object.
  51378. * @param name is a string, the name given to the new mesh
  51379. * @param newGenerator use new generator object for cloned trail mesh
  51380. * @returns a new mesh
  51381. */
  51382. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51383. /**
  51384. * Serializes this trail mesh
  51385. * @param serializationObject object to write serialization to
  51386. */
  51387. serialize(serializationObject: any): void;
  51388. /**
  51389. * Parses a serialized trail mesh
  51390. * @param parsedMesh the serialized mesh
  51391. * @param scene the scene to create the trail mesh in
  51392. * @returns the created trail mesh
  51393. */
  51394. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51395. }
  51396. }
  51397. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51398. import { Vector4 } from "babylonjs/Maths/math";
  51399. import { Mesh } from "babylonjs/Meshes/mesh";
  51400. /**
  51401. * Class containing static functions to help procedurally build meshes
  51402. */
  51403. export class TorusKnotBuilder {
  51404. /**
  51405. * Creates a torus knot mesh
  51406. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51407. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51408. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51409. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51413. * @param name defines the name of the mesh
  51414. * @param options defines the options used to create the mesh
  51415. * @param scene defines the hosting scene
  51416. * @returns the torus knot mesh
  51417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51418. */
  51419. static CreateTorusKnot(name: string, options: {
  51420. radius?: number;
  51421. tube?: number;
  51422. radialSegments?: number;
  51423. tubularSegments?: number;
  51424. p?: number;
  51425. q?: number;
  51426. updatable?: boolean;
  51427. sideOrientation?: number;
  51428. frontUVs?: Vector4;
  51429. backUVs?: Vector4;
  51430. }, scene: any): Mesh;
  51431. }
  51432. }
  51433. declare module "babylonjs/Meshes/polygonMesh" {
  51434. import { Scene } from "babylonjs/scene";
  51435. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51436. import { Mesh } from "babylonjs/Meshes/mesh";
  51437. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51438. /**
  51439. * Polygon
  51440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51441. */
  51442. export class Polygon {
  51443. /**
  51444. * Creates a rectangle
  51445. * @param xmin bottom X coord
  51446. * @param ymin bottom Y coord
  51447. * @param xmax top X coord
  51448. * @param ymax top Y coord
  51449. * @returns points that make the resulting rectation
  51450. */
  51451. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51452. /**
  51453. * Creates a circle
  51454. * @param radius radius of circle
  51455. * @param cx scale in x
  51456. * @param cy scale in y
  51457. * @param numberOfSides number of sides that make up the circle
  51458. * @returns points that make the resulting circle
  51459. */
  51460. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51461. /**
  51462. * Creates a polygon from input string
  51463. * @param input Input polygon data
  51464. * @returns the parsed points
  51465. */
  51466. static Parse(input: string): Vector2[];
  51467. /**
  51468. * Starts building a polygon from x and y coordinates
  51469. * @param x x coordinate
  51470. * @param y y coordinate
  51471. * @returns the started path2
  51472. */
  51473. static StartingAt(x: number, y: number): Path2;
  51474. }
  51475. /**
  51476. * Builds a polygon
  51477. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51478. */
  51479. export class PolygonMeshBuilder {
  51480. private _points;
  51481. private _outlinepoints;
  51482. private _holes;
  51483. private _name;
  51484. private _scene;
  51485. private _epoints;
  51486. private _eholes;
  51487. private _addToepoint;
  51488. /**
  51489. * Babylon reference to the earcut plugin.
  51490. */
  51491. bjsEarcut: any;
  51492. /**
  51493. * Creates a PolygonMeshBuilder
  51494. * @param name name of the builder
  51495. * @param contours Path of the polygon
  51496. * @param scene scene to add to when creating the mesh
  51497. * @param earcutInjection can be used to inject your own earcut reference
  51498. */
  51499. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51500. /**
  51501. * Adds a whole within the polygon
  51502. * @param hole Array of points defining the hole
  51503. * @returns this
  51504. */
  51505. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51506. /**
  51507. * Creates the polygon
  51508. * @param updatable If the mesh should be updatable
  51509. * @param depth The depth of the mesh created
  51510. * @returns the created mesh
  51511. */
  51512. build(updatable?: boolean, depth?: number): Mesh;
  51513. /**
  51514. * Creates the polygon
  51515. * @param depth The depth of the mesh created
  51516. * @returns the created VertexData
  51517. */
  51518. buildVertexData(depth?: number): VertexData;
  51519. /**
  51520. * Adds a side to the polygon
  51521. * @param positions points that make the polygon
  51522. * @param normals normals of the polygon
  51523. * @param uvs uvs of the polygon
  51524. * @param indices indices of the polygon
  51525. * @param bounds bounds of the polygon
  51526. * @param points points of the polygon
  51527. * @param depth depth of the polygon
  51528. * @param flip flip of the polygon
  51529. */
  51530. private addSide;
  51531. }
  51532. }
  51533. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51534. import { Scene } from "babylonjs/scene";
  51535. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51536. import { Mesh } from "babylonjs/Meshes/mesh";
  51537. /**
  51538. * Class containing static functions to help procedurally build meshes
  51539. */
  51540. export class PolygonBuilder {
  51541. /**
  51542. * Creates a polygon mesh
  51543. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51544. * * 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
  51545. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51548. * * Remember you can only change the shape positions, not their number when updating a polygon
  51549. * @param name defines the name of the mesh
  51550. * @param options defines the options used to create the mesh
  51551. * @param scene defines the hosting scene
  51552. * @param earcutInjection can be used to inject your own earcut reference
  51553. * @returns the polygon mesh
  51554. */
  51555. static CreatePolygon(name: string, options: {
  51556. shape: Vector3[];
  51557. holes?: Vector3[][];
  51558. depth?: number;
  51559. faceUV?: Vector4[];
  51560. faceColors?: Color4[];
  51561. updatable?: boolean;
  51562. sideOrientation?: number;
  51563. frontUVs?: Vector4;
  51564. backUVs?: Vector4;
  51565. }, scene: Scene, earcutInjection?: any): Mesh;
  51566. /**
  51567. * Creates an extruded polygon mesh, with depth in the Y direction.
  51568. * * 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)
  51569. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51570. * @param name defines the name of the mesh
  51571. * @param options defines the options used to create the mesh
  51572. * @param scene defines the hosting scene
  51573. * @param earcutInjection can be used to inject your own earcut reference
  51574. * @returns the polygon mesh
  51575. */
  51576. static ExtrudePolygon(name: string, options: {
  51577. shape: Vector3[];
  51578. holes?: Vector3[][];
  51579. depth?: number;
  51580. faceUV?: Vector4[];
  51581. faceColors?: Color4[];
  51582. updatable?: boolean;
  51583. sideOrientation?: number;
  51584. frontUVs?: Vector4;
  51585. backUVs?: Vector4;
  51586. }, scene: Scene, earcutInjection?: any): Mesh;
  51587. }
  51588. }
  51589. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51590. import { Scene } from "babylonjs/scene";
  51591. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51592. import { Mesh } from "babylonjs/Meshes/mesh";
  51593. /**
  51594. * Class containing static functions to help procedurally build meshes
  51595. */
  51596. export class LatheBuilder {
  51597. /**
  51598. * Creates lathe mesh.
  51599. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51600. * * 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
  51601. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51602. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51603. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51604. * * 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
  51605. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51606. * * 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
  51607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51611. * @param name defines the name of the mesh
  51612. * @param options defines the options used to create the mesh
  51613. * @param scene defines the hosting scene
  51614. * @returns the lathe mesh
  51615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51616. */
  51617. static CreateLathe(name: string, options: {
  51618. shape: Vector3[];
  51619. radius?: number;
  51620. tessellation?: number;
  51621. clip?: number;
  51622. arc?: number;
  51623. closed?: boolean;
  51624. updatable?: boolean;
  51625. sideOrientation?: number;
  51626. frontUVs?: Vector4;
  51627. backUVs?: Vector4;
  51628. cap?: number;
  51629. invertUV?: boolean;
  51630. }, scene: Scene): Mesh;
  51631. }
  51632. }
  51633. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51634. import { Scene } from "babylonjs/scene";
  51635. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51636. import { Mesh } from "babylonjs/Meshes/mesh";
  51637. /**
  51638. * Class containing static functions to help procedurally build meshes
  51639. */
  51640. export class TubeBuilder {
  51641. /**
  51642. * Creates a tube mesh.
  51643. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51644. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51645. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51646. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51647. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51648. * * 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)
  51649. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51650. * * 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
  51651. * * 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
  51652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51656. * @param name defines the name of the mesh
  51657. * @param options defines the options used to create the mesh
  51658. * @param scene defines the hosting scene
  51659. * @returns the tube mesh
  51660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51661. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51662. */
  51663. static CreateTube(name: string, options: {
  51664. path: Vector3[];
  51665. radius?: number;
  51666. tessellation?: number;
  51667. radiusFunction?: {
  51668. (i: number, distance: number): number;
  51669. };
  51670. cap?: number;
  51671. arc?: number;
  51672. updatable?: boolean;
  51673. sideOrientation?: number;
  51674. frontUVs?: Vector4;
  51675. backUVs?: Vector4;
  51676. instance?: Mesh;
  51677. invertUV?: boolean;
  51678. }, scene: Scene): Mesh;
  51679. }
  51680. }
  51681. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51682. import { Scene } from "babylonjs/scene";
  51683. import { Vector4 } from "babylonjs/Maths/math";
  51684. import { Mesh } from "babylonjs/Meshes/mesh";
  51685. /**
  51686. * Class containing static functions to help procedurally build meshes
  51687. */
  51688. export class IcoSphereBuilder {
  51689. /**
  51690. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51691. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51692. * * 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`)
  51693. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51694. * * 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
  51695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51698. * @param name defines the name of the mesh
  51699. * @param options defines the options used to create the mesh
  51700. * @param scene defines the hosting scene
  51701. * @returns the icosahedron mesh
  51702. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51703. */
  51704. static CreateIcoSphere(name: string, options: {
  51705. radius?: number;
  51706. radiusX?: number;
  51707. radiusY?: number;
  51708. radiusZ?: number;
  51709. flat?: boolean;
  51710. subdivisions?: number;
  51711. sideOrientation?: number;
  51712. frontUVs?: Vector4;
  51713. backUVs?: Vector4;
  51714. updatable?: boolean;
  51715. }, scene: Scene): Mesh;
  51716. }
  51717. }
  51718. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51719. import { Vector3 } from "babylonjs/Maths/math";
  51720. import { Mesh } from "babylonjs/Meshes/mesh";
  51721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51722. /**
  51723. * Class containing static functions to help procedurally build meshes
  51724. */
  51725. export class DecalBuilder {
  51726. /**
  51727. * Creates a decal mesh.
  51728. * 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
  51729. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51730. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51731. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51732. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51733. * @param name defines the name of the mesh
  51734. * @param sourceMesh defines the mesh where the decal must be applied
  51735. * @param options defines the options used to create the mesh
  51736. * @param scene defines the hosting scene
  51737. * @returns the decal mesh
  51738. * @see https://doc.babylonjs.com/how_to/decals
  51739. */
  51740. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51741. position?: Vector3;
  51742. normal?: Vector3;
  51743. size?: Vector3;
  51744. angle?: number;
  51745. }): Mesh;
  51746. }
  51747. }
  51748. declare module "babylonjs/Meshes/meshBuilder" {
  51749. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  51750. import { Nullable } from "babylonjs/types";
  51751. import { Scene } from "babylonjs/scene";
  51752. import { Mesh } from "babylonjs/Meshes/mesh";
  51753. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51754. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51756. /**
  51757. * Class containing static functions to help procedurally build meshes
  51758. */
  51759. export class MeshBuilder {
  51760. /**
  51761. * Creates a box mesh
  51762. * * The parameter `size` sets the size (float) of each box side (default 1)
  51763. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51764. * * 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)
  51765. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51769. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51770. * @param name defines the name of the mesh
  51771. * @param options defines the options used to create the mesh
  51772. * @param scene defines the hosting scene
  51773. * @returns the box mesh
  51774. */
  51775. static CreateBox(name: string, options: {
  51776. size?: number;
  51777. width?: number;
  51778. height?: number;
  51779. depth?: number;
  51780. faceUV?: Vector4[];
  51781. faceColors?: Color4[];
  51782. sideOrientation?: number;
  51783. frontUVs?: Vector4;
  51784. backUVs?: Vector4;
  51785. updatable?: boolean;
  51786. }, scene?: Nullable<Scene>): Mesh;
  51787. /**
  51788. * Creates a sphere mesh
  51789. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51790. * * 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`)
  51791. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51792. * * 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
  51793. * * 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)
  51794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51797. * @param name defines the name of the mesh
  51798. * @param options defines the options used to create the mesh
  51799. * @param scene defines the hosting scene
  51800. * @returns the sphere mesh
  51801. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51802. */
  51803. static CreateSphere(name: string, options: {
  51804. segments?: number;
  51805. diameter?: number;
  51806. diameterX?: number;
  51807. diameterY?: number;
  51808. diameterZ?: number;
  51809. arc?: number;
  51810. slice?: number;
  51811. sideOrientation?: number;
  51812. frontUVs?: Vector4;
  51813. backUVs?: Vector4;
  51814. updatable?: boolean;
  51815. }, scene: any): Mesh;
  51816. /**
  51817. * Creates a plane polygonal mesh. By default, this is a disc
  51818. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51819. * * 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
  51820. * * 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
  51821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51824. * @param name defines the name of the mesh
  51825. * @param options defines the options used to create the mesh
  51826. * @param scene defines the hosting scene
  51827. * @returns the plane polygonal mesh
  51828. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51829. */
  51830. static CreateDisc(name: string, options: {
  51831. radius?: number;
  51832. tessellation?: number;
  51833. arc?: number;
  51834. updatable?: boolean;
  51835. sideOrientation?: number;
  51836. frontUVs?: Vector4;
  51837. backUVs?: Vector4;
  51838. }, scene?: Nullable<Scene>): Mesh;
  51839. /**
  51840. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51841. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51842. * * 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`)
  51843. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51844. * * 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
  51845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51848. * @param name defines the name of the mesh
  51849. * @param options defines the options used to create the mesh
  51850. * @param scene defines the hosting scene
  51851. * @returns the icosahedron mesh
  51852. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51853. */
  51854. static CreateIcoSphere(name: string, options: {
  51855. radius?: number;
  51856. radiusX?: number;
  51857. radiusY?: number;
  51858. radiusZ?: number;
  51859. flat?: boolean;
  51860. subdivisions?: number;
  51861. sideOrientation?: number;
  51862. frontUVs?: Vector4;
  51863. backUVs?: Vector4;
  51864. updatable?: boolean;
  51865. }, scene: Scene): Mesh;
  51866. /**
  51867. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51868. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51869. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51870. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51871. * * 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
  51872. * * 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
  51873. * * 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
  51874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51877. * * 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
  51878. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51879. * * 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
  51880. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51882. * @param name defines the name of the mesh
  51883. * @param options defines the options used to create the mesh
  51884. * @param scene defines the hosting scene
  51885. * @returns the ribbon mesh
  51886. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51888. */
  51889. static CreateRibbon(name: string, options: {
  51890. pathArray: Vector3[][];
  51891. closeArray?: boolean;
  51892. closePath?: boolean;
  51893. offset?: number;
  51894. updatable?: boolean;
  51895. sideOrientation?: number;
  51896. frontUVs?: Vector4;
  51897. backUVs?: Vector4;
  51898. instance?: Mesh;
  51899. invertUV?: boolean;
  51900. uvs?: Vector2[];
  51901. colors?: Color4[];
  51902. }, scene?: Nullable<Scene>): Mesh;
  51903. /**
  51904. * Creates a cylinder or a cone mesh
  51905. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51906. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51907. * * 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.
  51908. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51909. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51910. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51911. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51912. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51913. * * 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).
  51914. * * 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
  51915. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51916. * * 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
  51917. * * 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.
  51918. * * If `enclose` is false, a ring surface is one element.
  51919. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51920. * * 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
  51921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51924. * @param name defines the name of the mesh
  51925. * @param options defines the options used to create the mesh
  51926. * @param scene defines the hosting scene
  51927. * @returns the cylinder mesh
  51928. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51929. */
  51930. static CreateCylinder(name: string, options: {
  51931. height?: number;
  51932. diameterTop?: number;
  51933. diameterBottom?: number;
  51934. diameter?: number;
  51935. tessellation?: number;
  51936. subdivisions?: number;
  51937. arc?: number;
  51938. faceColors?: Color4[];
  51939. faceUV?: Vector4[];
  51940. updatable?: boolean;
  51941. hasRings?: boolean;
  51942. enclose?: boolean;
  51943. sideOrientation?: number;
  51944. frontUVs?: Vector4;
  51945. backUVs?: Vector4;
  51946. }, scene: any): Mesh;
  51947. /**
  51948. * Creates a torus mesh
  51949. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51950. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51951. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51955. * @param name defines the name of the mesh
  51956. * @param options defines the options used to create the mesh
  51957. * @param scene defines the hosting scene
  51958. * @returns the torus mesh
  51959. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51960. */
  51961. static CreateTorus(name: string, options: {
  51962. diameter?: number;
  51963. thickness?: number;
  51964. tessellation?: number;
  51965. updatable?: boolean;
  51966. sideOrientation?: number;
  51967. frontUVs?: Vector4;
  51968. backUVs?: Vector4;
  51969. }, scene: any): Mesh;
  51970. /**
  51971. * Creates a torus knot mesh
  51972. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51973. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51974. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51975. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51979. * @param name defines the name of the mesh
  51980. * @param options defines the options used to create the mesh
  51981. * @param scene defines the hosting scene
  51982. * @returns the torus knot mesh
  51983. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51984. */
  51985. static CreateTorusKnot(name: string, options: {
  51986. radius?: number;
  51987. tube?: number;
  51988. radialSegments?: number;
  51989. tubularSegments?: number;
  51990. p?: number;
  51991. q?: number;
  51992. updatable?: boolean;
  51993. sideOrientation?: number;
  51994. frontUVs?: Vector4;
  51995. backUVs?: Vector4;
  51996. }, scene: any): Mesh;
  51997. /**
  51998. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51999. * * 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
  52000. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52001. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52002. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52003. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52004. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52005. * * 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
  52006. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52009. * @param name defines the name of the new line system
  52010. * @param options defines the options used to create the line system
  52011. * @param scene defines the hosting scene
  52012. * @returns a new line system mesh
  52013. */
  52014. static CreateLineSystem(name: string, options: {
  52015. lines: Vector3[][];
  52016. updatable?: boolean;
  52017. instance?: Nullable<LinesMesh>;
  52018. colors?: Nullable<Color4[][]>;
  52019. useVertexAlpha?: boolean;
  52020. }, scene: Nullable<Scene>): LinesMesh;
  52021. /**
  52022. * Creates a line mesh
  52023. * 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
  52024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52025. * * The parameter `points` is an array successive Vector3
  52026. * * 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
  52027. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52028. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52029. * * When updating an instance, remember that only point positions can change, not the number of points
  52030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52032. * @param name defines the name of the new line system
  52033. * @param options defines the options used to create the line system
  52034. * @param scene defines the hosting scene
  52035. * @returns a new line mesh
  52036. */
  52037. static CreateLines(name: string, options: {
  52038. points: Vector3[];
  52039. updatable?: boolean;
  52040. instance?: Nullable<LinesMesh>;
  52041. colors?: Color4[];
  52042. useVertexAlpha?: boolean;
  52043. }, scene?: Nullable<Scene>): LinesMesh;
  52044. /**
  52045. * Creates a dashed line mesh
  52046. * * 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
  52047. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52048. * * The parameter `points` is an array successive Vector3
  52049. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52050. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52051. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52052. * * 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
  52053. * * When updating an instance, remember that only point positions can change, not the number of points
  52054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52055. * @param name defines the name of the mesh
  52056. * @param options defines the options used to create the mesh
  52057. * @param scene defines the hosting scene
  52058. * @returns the dashed line mesh
  52059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52060. */
  52061. static CreateDashedLines(name: string, options: {
  52062. points: Vector3[];
  52063. dashSize?: number;
  52064. gapSize?: number;
  52065. dashNb?: number;
  52066. updatable?: boolean;
  52067. instance?: LinesMesh;
  52068. }, scene?: Nullable<Scene>): LinesMesh;
  52069. /**
  52070. * 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.
  52071. * * 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.
  52072. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52073. * * 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.
  52074. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52075. * * 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
  52076. * * 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
  52077. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52082. * @param name defines the name of the mesh
  52083. * @param options defines the options used to create the mesh
  52084. * @param scene defines the hosting scene
  52085. * @returns the extruded shape mesh
  52086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52088. */
  52089. static ExtrudeShape(name: string, options: {
  52090. shape: Vector3[];
  52091. path: Vector3[];
  52092. scale?: number;
  52093. rotation?: number;
  52094. cap?: number;
  52095. updatable?: boolean;
  52096. sideOrientation?: number;
  52097. frontUVs?: Vector4;
  52098. backUVs?: Vector4;
  52099. instance?: Mesh;
  52100. invertUV?: boolean;
  52101. }, scene?: Nullable<Scene>): Mesh;
  52102. /**
  52103. * Creates an custom extruded shape mesh.
  52104. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52105. * * 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.
  52106. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52107. * * 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
  52108. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52109. * * 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
  52110. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52111. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52112. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52113. * * 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
  52114. * * 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
  52115. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52120. * @param name defines the name of the mesh
  52121. * @param options defines the options used to create the mesh
  52122. * @param scene defines the hosting scene
  52123. * @returns the custom extruded shape mesh
  52124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52127. */
  52128. static ExtrudeShapeCustom(name: string, options: {
  52129. shape: Vector3[];
  52130. path: Vector3[];
  52131. scaleFunction?: any;
  52132. rotationFunction?: any;
  52133. ribbonCloseArray?: boolean;
  52134. ribbonClosePath?: boolean;
  52135. cap?: number;
  52136. updatable?: boolean;
  52137. sideOrientation?: number;
  52138. frontUVs?: Vector4;
  52139. backUVs?: Vector4;
  52140. instance?: Mesh;
  52141. invertUV?: boolean;
  52142. }, scene: Scene): Mesh;
  52143. /**
  52144. * Creates lathe mesh.
  52145. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52146. * * 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
  52147. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52148. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52149. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52150. * * 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
  52151. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52152. * * 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
  52153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52155. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52157. * @param name defines the name of the mesh
  52158. * @param options defines the options used to create the mesh
  52159. * @param scene defines the hosting scene
  52160. * @returns the lathe mesh
  52161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52162. */
  52163. static CreateLathe(name: string, options: {
  52164. shape: Vector3[];
  52165. radius?: number;
  52166. tessellation?: number;
  52167. clip?: number;
  52168. arc?: number;
  52169. closed?: boolean;
  52170. updatable?: boolean;
  52171. sideOrientation?: number;
  52172. frontUVs?: Vector4;
  52173. backUVs?: Vector4;
  52174. cap?: number;
  52175. invertUV?: boolean;
  52176. }, scene: Scene): Mesh;
  52177. /**
  52178. * Creates a plane mesh
  52179. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52180. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52181. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52185. * @param name defines the name of the mesh
  52186. * @param options defines the options used to create the mesh
  52187. * @param scene defines the hosting scene
  52188. * @returns the plane mesh
  52189. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52190. */
  52191. static CreatePlane(name: string, options: {
  52192. size?: number;
  52193. width?: number;
  52194. height?: number;
  52195. sideOrientation?: number;
  52196. frontUVs?: Vector4;
  52197. backUVs?: Vector4;
  52198. updatable?: boolean;
  52199. sourcePlane?: Plane;
  52200. }, scene: Scene): Mesh;
  52201. /**
  52202. * Creates a ground mesh
  52203. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52204. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52206. * @param name defines the name of the mesh
  52207. * @param options defines the options used to create the mesh
  52208. * @param scene defines the hosting scene
  52209. * @returns the ground mesh
  52210. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52211. */
  52212. static CreateGround(name: string, options: {
  52213. width?: number;
  52214. height?: number;
  52215. subdivisions?: number;
  52216. subdivisionsX?: number;
  52217. subdivisionsY?: number;
  52218. updatable?: boolean;
  52219. }, scene: any): Mesh;
  52220. /**
  52221. * Creates a tiled ground mesh
  52222. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52223. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52224. * * 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
  52225. * * 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
  52226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52227. * @param name defines the name of the mesh
  52228. * @param options defines the options used to create the mesh
  52229. * @param scene defines the hosting scene
  52230. * @returns the tiled ground mesh
  52231. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52232. */
  52233. static CreateTiledGround(name: string, options: {
  52234. xmin: number;
  52235. zmin: number;
  52236. xmax: number;
  52237. zmax: number;
  52238. subdivisions?: {
  52239. w: number;
  52240. h: number;
  52241. };
  52242. precision?: {
  52243. w: number;
  52244. h: number;
  52245. };
  52246. updatable?: boolean;
  52247. }, scene: Scene): Mesh;
  52248. /**
  52249. * Creates a ground mesh from a height map
  52250. * * The parameter `url` sets the URL of the height map image resource.
  52251. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52252. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52253. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52254. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52255. * * 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.
  52256. * * 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).
  52257. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52259. * @param name defines the name of the mesh
  52260. * @param url defines the url to the height map
  52261. * @param options defines the options used to create the mesh
  52262. * @param scene defines the hosting scene
  52263. * @returns the ground mesh
  52264. * @see https://doc.babylonjs.com/babylon101/height_map
  52265. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52266. */
  52267. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52268. width?: number;
  52269. height?: number;
  52270. subdivisions?: number;
  52271. minHeight?: number;
  52272. maxHeight?: number;
  52273. colorFilter?: Color3;
  52274. alphaFilter?: number;
  52275. updatable?: boolean;
  52276. onReady?: (mesh: GroundMesh) => void;
  52277. }, scene: Scene): GroundMesh;
  52278. /**
  52279. * Creates a polygon mesh
  52280. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52281. * * 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
  52282. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52285. * * Remember you can only change the shape positions, not their number when updating a polygon
  52286. * @param name defines the name of the mesh
  52287. * @param options defines the options used to create the mesh
  52288. * @param scene defines the hosting scene
  52289. * @param earcutInjection can be used to inject your own earcut reference
  52290. * @returns the polygon mesh
  52291. */
  52292. static CreatePolygon(name: string, options: {
  52293. shape: Vector3[];
  52294. holes?: Vector3[][];
  52295. depth?: number;
  52296. faceUV?: Vector4[];
  52297. faceColors?: Color4[];
  52298. updatable?: boolean;
  52299. sideOrientation?: number;
  52300. frontUVs?: Vector4;
  52301. backUVs?: Vector4;
  52302. }, scene: Scene, earcutInjection?: any): Mesh;
  52303. /**
  52304. * Creates an extruded polygon mesh, with depth in the Y direction.
  52305. * * 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)
  52306. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52307. * @param name defines the name of the mesh
  52308. * @param options defines the options used to create the mesh
  52309. * @param scene defines the hosting scene
  52310. * @param earcutInjection can be used to inject your own earcut reference
  52311. * @returns the polygon mesh
  52312. */
  52313. static ExtrudePolygon(name: string, options: {
  52314. shape: Vector3[];
  52315. holes?: Vector3[][];
  52316. depth?: number;
  52317. faceUV?: Vector4[];
  52318. faceColors?: Color4[];
  52319. updatable?: boolean;
  52320. sideOrientation?: number;
  52321. frontUVs?: Vector4;
  52322. backUVs?: Vector4;
  52323. }, scene: Scene, earcutInjection?: any): Mesh;
  52324. /**
  52325. * Creates a tube mesh.
  52326. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52327. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52328. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52329. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52330. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52331. * * 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)
  52332. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52333. * * 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
  52334. * * 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
  52335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52337. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52339. * @param name defines the name of the mesh
  52340. * @param options defines the options used to create the mesh
  52341. * @param scene defines the hosting scene
  52342. * @returns the tube mesh
  52343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52344. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52345. */
  52346. static CreateTube(name: string, options: {
  52347. path: Vector3[];
  52348. radius?: number;
  52349. tessellation?: number;
  52350. radiusFunction?: {
  52351. (i: number, distance: number): number;
  52352. };
  52353. cap?: number;
  52354. arc?: number;
  52355. updatable?: boolean;
  52356. sideOrientation?: number;
  52357. frontUVs?: Vector4;
  52358. backUVs?: Vector4;
  52359. instance?: Mesh;
  52360. invertUV?: boolean;
  52361. }, scene: Scene): Mesh;
  52362. /**
  52363. * Creates a polyhedron mesh
  52364. * * 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
  52365. * * The parameter `size` (positive float, default 1) sets the polygon size
  52366. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52367. * * 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`
  52368. * * 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
  52369. * * 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)`)
  52370. * * 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
  52371. * * 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
  52372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52375. * @param name defines the name of the mesh
  52376. * @param options defines the options used to create the mesh
  52377. * @param scene defines the hosting scene
  52378. * @returns the polyhedron mesh
  52379. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52380. */
  52381. static CreatePolyhedron(name: string, options: {
  52382. type?: number;
  52383. size?: number;
  52384. sizeX?: number;
  52385. sizeY?: number;
  52386. sizeZ?: number;
  52387. custom?: any;
  52388. faceUV?: Vector4[];
  52389. faceColors?: Color4[];
  52390. flat?: boolean;
  52391. updatable?: boolean;
  52392. sideOrientation?: number;
  52393. frontUVs?: Vector4;
  52394. backUVs?: Vector4;
  52395. }, scene: Scene): Mesh;
  52396. /**
  52397. * Creates a decal mesh.
  52398. * 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
  52399. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52400. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52401. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52402. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52403. * @param name defines the name of the mesh
  52404. * @param sourceMesh defines the mesh where the decal must be applied
  52405. * @param options defines the options used to create the mesh
  52406. * @param scene defines the hosting scene
  52407. * @returns the decal mesh
  52408. * @see https://doc.babylonjs.com/how_to/decals
  52409. */
  52410. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52411. position?: Vector3;
  52412. normal?: Vector3;
  52413. size?: Vector3;
  52414. angle?: number;
  52415. }): Mesh;
  52416. }
  52417. }
  52418. declare module "babylonjs/Meshes/meshSimplification" {
  52419. import { Mesh } from "babylonjs/Meshes/mesh";
  52420. /**
  52421. * A simplifier interface for future simplification implementations
  52422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52423. */
  52424. export interface ISimplifier {
  52425. /**
  52426. * Simplification of a given mesh according to the given settings.
  52427. * Since this requires computation, it is assumed that the function runs async.
  52428. * @param settings The settings of the simplification, including quality and distance
  52429. * @param successCallback A callback that will be called after the mesh was simplified.
  52430. * @param errorCallback in case of an error, this callback will be called. optional.
  52431. */
  52432. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52433. }
  52434. /**
  52435. * Expected simplification settings.
  52436. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52437. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52438. */
  52439. export interface ISimplificationSettings {
  52440. /**
  52441. * Gets or sets the expected quality
  52442. */
  52443. quality: number;
  52444. /**
  52445. * Gets or sets the distance when this optimized version should be used
  52446. */
  52447. distance: number;
  52448. /**
  52449. * Gets an already optimized mesh
  52450. */
  52451. optimizeMesh?: boolean;
  52452. }
  52453. /**
  52454. * Class used to specify simplification options
  52455. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52456. */
  52457. export class SimplificationSettings implements ISimplificationSettings {
  52458. /** expected quality */
  52459. quality: number;
  52460. /** distance when this optimized version should be used */
  52461. distance: number;
  52462. /** already optimized mesh */
  52463. optimizeMesh?: boolean | undefined;
  52464. /**
  52465. * Creates a SimplificationSettings
  52466. * @param quality expected quality
  52467. * @param distance distance when this optimized version should be used
  52468. * @param optimizeMesh already optimized mesh
  52469. */
  52470. constructor(
  52471. /** expected quality */
  52472. quality: number,
  52473. /** distance when this optimized version should be used */
  52474. distance: number,
  52475. /** already optimized mesh */
  52476. optimizeMesh?: boolean | undefined);
  52477. }
  52478. /**
  52479. * Interface used to define a simplification task
  52480. */
  52481. export interface ISimplificationTask {
  52482. /**
  52483. * Array of settings
  52484. */
  52485. settings: Array<ISimplificationSettings>;
  52486. /**
  52487. * Simplification type
  52488. */
  52489. simplificationType: SimplificationType;
  52490. /**
  52491. * Mesh to simplify
  52492. */
  52493. mesh: Mesh;
  52494. /**
  52495. * Callback called on success
  52496. */
  52497. successCallback?: () => void;
  52498. /**
  52499. * Defines if parallel processing can be used
  52500. */
  52501. parallelProcessing: boolean;
  52502. }
  52503. /**
  52504. * Queue used to order the simplification tasks
  52505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52506. */
  52507. export class SimplificationQueue {
  52508. private _simplificationArray;
  52509. /**
  52510. * Gets a boolean indicating that the process is still running
  52511. */
  52512. running: boolean;
  52513. /**
  52514. * Creates a new queue
  52515. */
  52516. constructor();
  52517. /**
  52518. * Adds a new simplification task
  52519. * @param task defines a task to add
  52520. */
  52521. addTask(task: ISimplificationTask): void;
  52522. /**
  52523. * Execute next task
  52524. */
  52525. executeNext(): void;
  52526. /**
  52527. * Execute a simplification task
  52528. * @param task defines the task to run
  52529. */
  52530. runSimplification(task: ISimplificationTask): void;
  52531. private getSimplifier;
  52532. }
  52533. /**
  52534. * The implemented types of simplification
  52535. * At the moment only Quadratic Error Decimation is implemented
  52536. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52537. */
  52538. export enum SimplificationType {
  52539. /** Quadratic error decimation */
  52540. QUADRATIC = 0
  52541. }
  52542. }
  52543. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52544. import { Scene } from "babylonjs/scene";
  52545. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52546. import { ISceneComponent } from "babylonjs/sceneComponent";
  52547. module "babylonjs/scene" {
  52548. interface Scene {
  52549. /** @hidden (Backing field) */
  52550. _simplificationQueue: SimplificationQueue;
  52551. /**
  52552. * Gets or sets the simplification queue attached to the scene
  52553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52554. */
  52555. simplificationQueue: SimplificationQueue;
  52556. }
  52557. }
  52558. module "babylonjs/Meshes/mesh" {
  52559. interface Mesh {
  52560. /**
  52561. * Simplify the mesh according to the given array of settings.
  52562. * Function will return immediately and will simplify async
  52563. * @param settings a collection of simplification settings
  52564. * @param parallelProcessing should all levels calculate parallel or one after the other
  52565. * @param simplificationType the type of simplification to run
  52566. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52567. * @returns the current mesh
  52568. */
  52569. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52570. }
  52571. }
  52572. /**
  52573. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52574. * created in a scene
  52575. */
  52576. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52577. /**
  52578. * The component name helpfull to identify the component in the list of scene components.
  52579. */
  52580. readonly name: string;
  52581. /**
  52582. * The scene the component belongs to.
  52583. */
  52584. scene: Scene;
  52585. /**
  52586. * Creates a new instance of the component for the given scene
  52587. * @param scene Defines the scene to register the component in
  52588. */
  52589. constructor(scene: Scene);
  52590. /**
  52591. * Registers the component in a given scene
  52592. */
  52593. register(): void;
  52594. /**
  52595. * Rebuilds the elements related to this component in case of
  52596. * context lost for instance.
  52597. */
  52598. rebuild(): void;
  52599. /**
  52600. * Disposes the component and the associated ressources
  52601. */
  52602. dispose(): void;
  52603. private _beforeCameraUpdate;
  52604. }
  52605. }
  52606. declare module "babylonjs/Meshes/Builders/index" {
  52607. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52608. export * from "babylonjs/Meshes/Builders/discBuilder";
  52609. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52610. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52611. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52612. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52613. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52614. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52615. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52616. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52617. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52618. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52619. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52620. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52621. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52622. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52623. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52624. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52625. }
  52626. declare module "babylonjs/Meshes/index" {
  52627. export * from "babylonjs/Meshes/abstractMesh";
  52628. export * from "babylonjs/Meshes/buffer";
  52629. export * from "babylonjs/Meshes/Compression/index";
  52630. export * from "babylonjs/Meshes/csg";
  52631. export * from "babylonjs/Meshes/geometry";
  52632. export * from "babylonjs/Meshes/groundMesh";
  52633. export * from "babylonjs/Meshes/trailMesh";
  52634. export * from "babylonjs/Meshes/instancedMesh";
  52635. export * from "babylonjs/Meshes/linesMesh";
  52636. export * from "babylonjs/Meshes/mesh";
  52637. export * from "babylonjs/Meshes/mesh.vertexData";
  52638. export * from "babylonjs/Meshes/meshBuilder";
  52639. export * from "babylonjs/Meshes/meshSimplification";
  52640. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52641. export * from "babylonjs/Meshes/polygonMesh";
  52642. export * from "babylonjs/Meshes/subMesh";
  52643. export * from "babylonjs/Meshes/transformNode";
  52644. export * from "babylonjs/Meshes/Builders/index";
  52645. }
  52646. declare module "babylonjs/Morph/index" {
  52647. export * from "babylonjs/Morph/morphTarget";
  52648. export * from "babylonjs/Morph/morphTargetManager";
  52649. }
  52650. declare module "babylonjs/Offline/database" {
  52651. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52652. /**
  52653. * Class used to enable access to IndexedDB
  52654. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52655. */
  52656. export class Database implements IOfflineProvider {
  52657. private _callbackManifestChecked;
  52658. private _currentSceneUrl;
  52659. private _db;
  52660. private _enableSceneOffline;
  52661. private _enableTexturesOffline;
  52662. private _manifestVersionFound;
  52663. private _mustUpdateRessources;
  52664. private _hasReachedQuota;
  52665. private _isSupported;
  52666. private _idbFactory;
  52667. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52668. private static IsUASupportingBlobStorage;
  52669. /**
  52670. * Gets a boolean indicating if Database storate is enabled (off by default)
  52671. */
  52672. static IDBStorageEnabled: boolean;
  52673. /**
  52674. * Gets a boolean indicating if scene must be saved in the database
  52675. */
  52676. readonly enableSceneOffline: boolean;
  52677. /**
  52678. * Gets a boolean indicating if textures must be saved in the database
  52679. */
  52680. readonly enableTexturesOffline: boolean;
  52681. /**
  52682. * Creates a new Database
  52683. * @param urlToScene defines the url to load the scene
  52684. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52685. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52686. */
  52687. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52688. private static _ParseURL;
  52689. private static _ReturnFullUrlLocation;
  52690. private _checkManifestFile;
  52691. /**
  52692. * Open the database and make it available
  52693. * @param successCallback defines the callback to call on success
  52694. * @param errorCallback defines the callback to call on error
  52695. */
  52696. open(successCallback: () => void, errorCallback: () => void): void;
  52697. /**
  52698. * Loads an image from the database
  52699. * @param url defines the url to load from
  52700. * @param image defines the target DOM image
  52701. */
  52702. loadImage(url: string, image: HTMLImageElement): void;
  52703. private _loadImageFromDBAsync;
  52704. private _saveImageIntoDBAsync;
  52705. private _checkVersionFromDB;
  52706. private _loadVersionFromDBAsync;
  52707. private _saveVersionIntoDBAsync;
  52708. /**
  52709. * Loads a file from database
  52710. * @param url defines the URL to load from
  52711. * @param sceneLoaded defines a callback to call on success
  52712. * @param progressCallBack defines a callback to call when progress changed
  52713. * @param errorCallback defines a callback to call on error
  52714. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52715. */
  52716. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52717. private _loadFileAsync;
  52718. private _saveFileAsync;
  52719. /**
  52720. * Validates if xhr data is correct
  52721. * @param xhr defines the request to validate
  52722. * @param dataType defines the expected data type
  52723. * @returns true if data is correct
  52724. */
  52725. private static _ValidateXHRData;
  52726. }
  52727. }
  52728. declare module "babylonjs/Offline/index" {
  52729. export * from "babylonjs/Offline/database";
  52730. export * from "babylonjs/Offline/IOfflineProvider";
  52731. }
  52732. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  52733. /** @hidden */
  52734. export var gpuUpdateParticlesPixelShader: {
  52735. name: string;
  52736. shader: string;
  52737. };
  52738. }
  52739. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  52740. /** @hidden */
  52741. export var gpuUpdateParticlesVertexShader: {
  52742. name: string;
  52743. shader: string;
  52744. };
  52745. }
  52746. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  52747. /** @hidden */
  52748. export var clipPlaneFragmentDeclaration2: {
  52749. name: string;
  52750. shader: string;
  52751. };
  52752. }
  52753. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  52754. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  52755. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52756. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52757. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52758. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52759. /** @hidden */
  52760. export var gpuRenderParticlesPixelShader: {
  52761. name: string;
  52762. shader: string;
  52763. };
  52764. }
  52765. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  52766. /** @hidden */
  52767. export var clipPlaneVertexDeclaration2: {
  52768. name: string;
  52769. shader: string;
  52770. };
  52771. }
  52772. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  52773. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  52774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52775. /** @hidden */
  52776. export var gpuRenderParticlesVertexShader: {
  52777. name: string;
  52778. shader: string;
  52779. };
  52780. }
  52781. declare module "babylonjs/Particles/gpuParticleSystem" {
  52782. import { Nullable } from "babylonjs/types";
  52783. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  52784. import { Observable } from "babylonjs/Misc/observable";
  52785. import { Color4, Color3 } from "babylonjs/Maths/math";
  52786. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52787. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  52788. import { Scene, IDisposable } from "babylonjs/scene";
  52789. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  52790. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  52791. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  52792. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  52793. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  52794. /**
  52795. * This represents a GPU particle system in Babylon
  52796. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52797. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52798. */
  52799. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52800. /**
  52801. * The layer mask we are rendering the particles through.
  52802. */
  52803. layerMask: number;
  52804. private _capacity;
  52805. private _activeCount;
  52806. private _currentActiveCount;
  52807. private _accumulatedCount;
  52808. private _renderEffect;
  52809. private _updateEffect;
  52810. private _buffer0;
  52811. private _buffer1;
  52812. private _spriteBuffer;
  52813. private _updateVAO;
  52814. private _renderVAO;
  52815. private _targetIndex;
  52816. private _sourceBuffer;
  52817. private _targetBuffer;
  52818. private _engine;
  52819. private _currentRenderId;
  52820. private _started;
  52821. private _stopped;
  52822. private _timeDelta;
  52823. private _randomTexture;
  52824. private _randomTexture2;
  52825. private _attributesStrideSize;
  52826. private _updateEffectOptions;
  52827. private _randomTextureSize;
  52828. private _actualFrame;
  52829. private readonly _rawTextureWidth;
  52830. /**
  52831. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52832. */
  52833. static readonly IsSupported: boolean;
  52834. /**
  52835. * An event triggered when the system is disposed.
  52836. */
  52837. onDisposeObservable: Observable<GPUParticleSystem>;
  52838. /**
  52839. * Gets the maximum number of particles active at the same time.
  52840. * @returns The max number of active particles.
  52841. */
  52842. getCapacity(): number;
  52843. /**
  52844. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52845. * to override the particles.
  52846. */
  52847. forceDepthWrite: boolean;
  52848. /**
  52849. * Gets or set the number of active particles
  52850. */
  52851. activeParticleCount: number;
  52852. private _preWarmDone;
  52853. /**
  52854. * Is this system ready to be used/rendered
  52855. * @return true if the system is ready
  52856. */
  52857. isReady(): boolean;
  52858. /**
  52859. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52860. * @returns True if it has been started, otherwise false.
  52861. */
  52862. isStarted(): boolean;
  52863. /**
  52864. * Starts the particle system and begins to emit
  52865. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52866. */
  52867. start(delay?: number): void;
  52868. /**
  52869. * Stops the particle system.
  52870. */
  52871. stop(): void;
  52872. /**
  52873. * Remove all active particles
  52874. */
  52875. reset(): void;
  52876. /**
  52877. * Returns the string "GPUParticleSystem"
  52878. * @returns a string containing the class name
  52879. */
  52880. getClassName(): string;
  52881. private _colorGradientsTexture;
  52882. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52883. /**
  52884. * Adds a new color gradient
  52885. * @param gradient defines the gradient to use (between 0 and 1)
  52886. * @param color1 defines the color to affect to the specified gradient
  52887. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52888. * @returns the current particle system
  52889. */
  52890. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52891. /**
  52892. * Remove a specific color gradient
  52893. * @param gradient defines the gradient to remove
  52894. * @returns the current particle system
  52895. */
  52896. removeColorGradient(gradient: number): GPUParticleSystem;
  52897. private _angularSpeedGradientsTexture;
  52898. private _sizeGradientsTexture;
  52899. private _velocityGradientsTexture;
  52900. private _limitVelocityGradientsTexture;
  52901. private _dragGradientsTexture;
  52902. private _addFactorGradient;
  52903. /**
  52904. * Adds a new size gradient
  52905. * @param gradient defines the gradient to use (between 0 and 1)
  52906. * @param factor defines the size factor to affect to the specified gradient
  52907. * @returns the current particle system
  52908. */
  52909. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52910. /**
  52911. * Remove a specific size gradient
  52912. * @param gradient defines the gradient to remove
  52913. * @returns the current particle system
  52914. */
  52915. removeSizeGradient(gradient: number): GPUParticleSystem;
  52916. /**
  52917. * Adds a new angular speed gradient
  52918. * @param gradient defines the gradient to use (between 0 and 1)
  52919. * @param factor defines the angular speed to affect to the specified gradient
  52920. * @returns the current particle system
  52921. */
  52922. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52923. /**
  52924. * Remove a specific angular speed gradient
  52925. * @param gradient defines the gradient to remove
  52926. * @returns the current particle system
  52927. */
  52928. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52929. /**
  52930. * Adds a new velocity gradient
  52931. * @param gradient defines the gradient to use (between 0 and 1)
  52932. * @param factor defines the velocity to affect to the specified gradient
  52933. * @returns the current particle system
  52934. */
  52935. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52936. /**
  52937. * Remove a specific velocity gradient
  52938. * @param gradient defines the gradient to remove
  52939. * @returns the current particle system
  52940. */
  52941. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52942. /**
  52943. * Adds a new limit velocity gradient
  52944. * @param gradient defines the gradient to use (between 0 and 1)
  52945. * @param factor defines the limit velocity value to affect to the specified gradient
  52946. * @returns the current particle system
  52947. */
  52948. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52949. /**
  52950. * Remove a specific limit velocity gradient
  52951. * @param gradient defines the gradient to remove
  52952. * @returns the current particle system
  52953. */
  52954. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52955. /**
  52956. * Adds a new drag gradient
  52957. * @param gradient defines the gradient to use (between 0 and 1)
  52958. * @param factor defines the drag value to affect to the specified gradient
  52959. * @returns the current particle system
  52960. */
  52961. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52962. /**
  52963. * Remove a specific drag gradient
  52964. * @param gradient defines the gradient to remove
  52965. * @returns the current particle system
  52966. */
  52967. removeDragGradient(gradient: number): GPUParticleSystem;
  52968. /**
  52969. * Not supported by GPUParticleSystem
  52970. * @param gradient defines the gradient to use (between 0 and 1)
  52971. * @param factor defines the emit rate value to affect to the specified gradient
  52972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52973. * @returns the current particle system
  52974. */
  52975. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52976. /**
  52977. * Not supported by GPUParticleSystem
  52978. * @param gradient defines the gradient to remove
  52979. * @returns the current particle system
  52980. */
  52981. removeEmitRateGradient(gradient: number): IParticleSystem;
  52982. /**
  52983. * Not supported by GPUParticleSystem
  52984. * @param gradient defines the gradient to use (between 0 and 1)
  52985. * @param factor defines the start size value to affect to the specified gradient
  52986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52987. * @returns the current particle system
  52988. */
  52989. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52990. /**
  52991. * Not supported by GPUParticleSystem
  52992. * @param gradient defines the gradient to remove
  52993. * @returns the current particle system
  52994. */
  52995. removeStartSizeGradient(gradient: number): IParticleSystem;
  52996. /**
  52997. * Not supported by GPUParticleSystem
  52998. * @param gradient defines the gradient to use (between 0 and 1)
  52999. * @param min defines the color remap minimal range
  53000. * @param max defines the color remap maximal range
  53001. * @returns the current particle system
  53002. */
  53003. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53004. /**
  53005. * Not supported by GPUParticleSystem
  53006. * @param gradient defines the gradient to remove
  53007. * @returns the current particle system
  53008. */
  53009. removeColorRemapGradient(): IParticleSystem;
  53010. /**
  53011. * Not supported by GPUParticleSystem
  53012. * @param gradient defines the gradient to use (between 0 and 1)
  53013. * @param min defines the alpha remap minimal range
  53014. * @param max defines the alpha remap maximal range
  53015. * @returns the current particle system
  53016. */
  53017. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53018. /**
  53019. * Not supported by GPUParticleSystem
  53020. * @param gradient defines the gradient to remove
  53021. * @returns the current particle system
  53022. */
  53023. removeAlphaRemapGradient(): IParticleSystem;
  53024. /**
  53025. * Not supported by GPUParticleSystem
  53026. * @param gradient defines the gradient to use (between 0 and 1)
  53027. * @param color defines the color to affect to the specified gradient
  53028. * @returns the current particle system
  53029. */
  53030. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53031. /**
  53032. * Not supported by GPUParticleSystem
  53033. * @param gradient defines the gradient to remove
  53034. * @returns the current particle system
  53035. */
  53036. removeRampGradient(): IParticleSystem;
  53037. /**
  53038. * Not supported by GPUParticleSystem
  53039. * @returns the list of ramp gradients
  53040. */
  53041. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53042. /**
  53043. * Not supported by GPUParticleSystem
  53044. * Gets or sets a boolean indicating that ramp gradients must be used
  53045. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53046. */
  53047. useRampGradients: boolean;
  53048. /**
  53049. * Not supported by GPUParticleSystem
  53050. * @param gradient defines the gradient to use (between 0 and 1)
  53051. * @param factor defines the life time factor to affect to the specified gradient
  53052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53053. * @returns the current particle system
  53054. */
  53055. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53056. /**
  53057. * Not supported by GPUParticleSystem
  53058. * @param gradient defines the gradient to remove
  53059. * @returns the current particle system
  53060. */
  53061. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53062. /**
  53063. * Instantiates a GPU particle system.
  53064. * 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.
  53065. * @param name The name of the particle system
  53066. * @param options The options used to create the system
  53067. * @param scene The scene the particle system belongs to
  53068. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53069. */
  53070. constructor(name: string, options: Partial<{
  53071. capacity: number;
  53072. randomTextureSize: number;
  53073. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53074. protected _reset(): void;
  53075. private _createUpdateVAO;
  53076. private _createRenderVAO;
  53077. private _initialize;
  53078. /** @hidden */
  53079. _recreateUpdateEffect(): void;
  53080. /** @hidden */
  53081. _recreateRenderEffect(): void;
  53082. /**
  53083. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53084. * @param preWarm defines if we are in the pre-warmimg phase
  53085. */
  53086. animate(preWarm?: boolean): void;
  53087. private _createFactorGradientTexture;
  53088. private _createSizeGradientTexture;
  53089. private _createAngularSpeedGradientTexture;
  53090. private _createVelocityGradientTexture;
  53091. private _createLimitVelocityGradientTexture;
  53092. private _createDragGradientTexture;
  53093. private _createColorGradientTexture;
  53094. /**
  53095. * Renders the particle system in its current state
  53096. * @param preWarm defines if the system should only update the particles but not render them
  53097. * @returns the current number of particles
  53098. */
  53099. render(preWarm?: boolean): number;
  53100. /**
  53101. * Rebuilds the particle system
  53102. */
  53103. rebuild(): void;
  53104. private _releaseBuffers;
  53105. private _releaseVAOs;
  53106. /**
  53107. * Disposes the particle system and free the associated resources
  53108. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53109. */
  53110. dispose(disposeTexture?: boolean): void;
  53111. /**
  53112. * Clones the particle system.
  53113. * @param name The name of the cloned object
  53114. * @param newEmitter The new emitter to use
  53115. * @returns the cloned particle system
  53116. */
  53117. clone(name: string, newEmitter: any): GPUParticleSystem;
  53118. /**
  53119. * Serializes the particle system to a JSON object.
  53120. * @returns the JSON object
  53121. */
  53122. serialize(): any;
  53123. /**
  53124. * Parses a JSON object to create a GPU particle system.
  53125. * @param parsedParticleSystem The JSON object to parse
  53126. * @param scene The scene to create the particle system in
  53127. * @param rootUrl The root url to use to load external dependencies like texture
  53128. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53129. * @returns the parsed GPU particle system
  53130. */
  53131. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53132. }
  53133. }
  53134. declare module "babylonjs/Particles/particleSystemSet" {
  53135. import { Nullable } from "babylonjs/types";
  53136. import { Color3 } from "babylonjs/Maths/math";
  53137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53139. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53140. import { Scene, IDisposable } from "babylonjs/scene";
  53141. /**
  53142. * Represents a set of particle systems working together to create a specific effect
  53143. */
  53144. export class ParticleSystemSet implements IDisposable {
  53145. private _emitterCreationOptions;
  53146. private _emitterNode;
  53147. /**
  53148. * Gets the particle system list
  53149. */
  53150. systems: IParticleSystem[];
  53151. /**
  53152. * Gets the emitter node used with this set
  53153. */
  53154. readonly emitterNode: Nullable<TransformNode>;
  53155. /**
  53156. * Creates a new emitter mesh as a sphere
  53157. * @param options defines the options used to create the sphere
  53158. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53159. * @param scene defines the hosting scene
  53160. */
  53161. setEmitterAsSphere(options: {
  53162. diameter: number;
  53163. segments: number;
  53164. color: Color3;
  53165. }, renderingGroupId: number, scene: Scene): void;
  53166. /**
  53167. * Starts all particle systems of the set
  53168. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53169. */
  53170. start(emitter?: AbstractMesh): void;
  53171. /**
  53172. * Release all associated resources
  53173. */
  53174. dispose(): void;
  53175. /**
  53176. * Serialize the set into a JSON compatible object
  53177. * @returns a JSON compatible representation of the set
  53178. */
  53179. serialize(): any;
  53180. /**
  53181. * Parse a new ParticleSystemSet from a serialized source
  53182. * @param data defines a JSON compatible representation of the set
  53183. * @param scene defines the hosting scene
  53184. * @param gpu defines if we want GPU particles or CPU particles
  53185. * @returns a new ParticleSystemSet
  53186. */
  53187. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53188. }
  53189. }
  53190. declare module "babylonjs/Particles/particleHelper" {
  53191. import { Nullable } from "babylonjs/types";
  53192. import { Scene } from "babylonjs/scene";
  53193. import { Vector3 } from "babylonjs/Maths/math";
  53194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53195. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53196. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53197. /**
  53198. * This class is made for on one-liner static method to help creating particle system set.
  53199. */
  53200. export class ParticleHelper {
  53201. /**
  53202. * Gets or sets base Assets URL
  53203. */
  53204. static BaseAssetsUrl: string;
  53205. /**
  53206. * Create a default particle system that you can tweak
  53207. * @param emitter defines the emitter to use
  53208. * @param capacity defines the system capacity (default is 500 particles)
  53209. * @param scene defines the hosting scene
  53210. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53211. * @returns the new Particle system
  53212. */
  53213. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53214. /**
  53215. * This is the main static method (one-liner) of this helper to create different particle systems
  53216. * @param type This string represents the type to the particle system to create
  53217. * @param scene The scene where the particle system should live
  53218. * @param gpu If the system will use gpu
  53219. * @returns the ParticleSystemSet created
  53220. */
  53221. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53222. /**
  53223. * Static function used to export a particle system to a ParticleSystemSet variable.
  53224. * Please note that the emitter shape is not exported
  53225. * @param systems defines the particle systems to export
  53226. * @returns the created particle system set
  53227. */
  53228. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53229. }
  53230. }
  53231. declare module "babylonjs/Particles/particleSystemComponent" {
  53232. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53233. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53234. import "babylonjs/Shaders/particles.vertex";
  53235. module "babylonjs/Engines/engine" {
  53236. interface Engine {
  53237. /**
  53238. * Create an effect to use with particle systems.
  53239. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53240. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53241. * @param uniformsNames defines a list of attribute names
  53242. * @param samplers defines an array of string used to represent textures
  53243. * @param defines defines the string containing the defines to use to compile the shaders
  53244. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53245. * @param onCompiled defines a function to call when the effect creation is successful
  53246. * @param onError defines a function to call when the effect creation has failed
  53247. * @returns the new Effect
  53248. */
  53249. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53250. }
  53251. }
  53252. module "babylonjs/Meshes/mesh" {
  53253. interface Mesh {
  53254. /**
  53255. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53256. * @returns an array of IParticleSystem
  53257. */
  53258. getEmittedParticleSystems(): IParticleSystem[];
  53259. /**
  53260. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53261. * @returns an array of IParticleSystem
  53262. */
  53263. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53264. }
  53265. }
  53266. /**
  53267. * @hidden
  53268. */
  53269. export var _IDoNeedToBeInTheBuild: number;
  53270. }
  53271. declare module "babylonjs/Particles/index" {
  53272. export * from "babylonjs/Particles/baseParticleSystem";
  53273. export * from "babylonjs/Particles/EmitterTypes/index";
  53274. export * from "babylonjs/Particles/gpuParticleSystem";
  53275. export * from "babylonjs/Particles/IParticleSystem";
  53276. export * from "babylonjs/Particles/particle";
  53277. export * from "babylonjs/Particles/particleHelper";
  53278. export * from "babylonjs/Particles/particleSystem";
  53279. export * from "babylonjs/Particles/particleSystemComponent";
  53280. export * from "babylonjs/Particles/particleSystemSet";
  53281. export * from "babylonjs/Particles/solidParticle";
  53282. export * from "babylonjs/Particles/solidParticleSystem";
  53283. export * from "babylonjs/Particles/subEmitter";
  53284. }
  53285. declare module "babylonjs/Physics/physicsEngineComponent" {
  53286. import { Nullable } from "babylonjs/types";
  53287. import { Observable, Observer } from "babylonjs/Misc/observable";
  53288. import { Vector3 } from "babylonjs/Maths/math";
  53289. import { Mesh } from "babylonjs/Meshes/mesh";
  53290. import { ISceneComponent } from "babylonjs/sceneComponent";
  53291. import { Scene } from "babylonjs/scene";
  53292. import { Node } from "babylonjs/node";
  53293. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53295. module "babylonjs/scene" {
  53296. interface Scene {
  53297. /** @hidden (Backing field) */
  53298. _physicsEngine: Nullable<IPhysicsEngine>;
  53299. /**
  53300. * Gets the current physics engine
  53301. * @returns a IPhysicsEngine or null if none attached
  53302. */
  53303. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53304. /**
  53305. * Enables physics to the current scene
  53306. * @param gravity defines the scene's gravity for the physics engine
  53307. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53308. * @return a boolean indicating if the physics engine was initialized
  53309. */
  53310. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53311. /**
  53312. * Disables and disposes the physics engine associated with the scene
  53313. */
  53314. disablePhysicsEngine(): void;
  53315. /**
  53316. * Gets a boolean indicating if there is an active physics engine
  53317. * @returns a boolean indicating if there is an active physics engine
  53318. */
  53319. isPhysicsEnabled(): boolean;
  53320. /**
  53321. * Deletes a physics compound impostor
  53322. * @param compound defines the compound to delete
  53323. */
  53324. deleteCompoundImpostor(compound: any): void;
  53325. /**
  53326. * An event triggered when physic simulation is about to be run
  53327. */
  53328. onBeforePhysicsObservable: Observable<Scene>;
  53329. /**
  53330. * An event triggered when physic simulation has been done
  53331. */
  53332. onAfterPhysicsObservable: Observable<Scene>;
  53333. }
  53334. }
  53335. module "babylonjs/Meshes/abstractMesh" {
  53336. interface AbstractMesh {
  53337. /** @hidden */
  53338. _physicsImpostor: Nullable<PhysicsImpostor>;
  53339. /**
  53340. * Gets or sets impostor used for physic simulation
  53341. * @see http://doc.babylonjs.com/features/physics_engine
  53342. */
  53343. physicsImpostor: Nullable<PhysicsImpostor>;
  53344. /**
  53345. * Gets the current physics impostor
  53346. * @see http://doc.babylonjs.com/features/physics_engine
  53347. * @returns a physics impostor or null
  53348. */
  53349. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53350. /** Apply a physic impulse to the mesh
  53351. * @param force defines the force to apply
  53352. * @param contactPoint defines where to apply the force
  53353. * @returns the current mesh
  53354. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53355. */
  53356. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53357. /**
  53358. * Creates a physic joint between two meshes
  53359. * @param otherMesh defines the other mesh to use
  53360. * @param pivot1 defines the pivot to use on this mesh
  53361. * @param pivot2 defines the pivot to use on the other mesh
  53362. * @param options defines additional options (can be plugin dependent)
  53363. * @returns the current mesh
  53364. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53365. */
  53366. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53367. /** @hidden */
  53368. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53369. }
  53370. }
  53371. /**
  53372. * Defines the physics engine scene component responsible to manage a physics engine
  53373. */
  53374. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53375. /**
  53376. * The component name helpful to identify the component in the list of scene components.
  53377. */
  53378. readonly name: string;
  53379. /**
  53380. * The scene the component belongs to.
  53381. */
  53382. scene: Scene;
  53383. /**
  53384. * Creates a new instance of the component for the given scene
  53385. * @param scene Defines the scene to register the component in
  53386. */
  53387. constructor(scene: Scene);
  53388. /**
  53389. * Registers the component in a given scene
  53390. */
  53391. register(): void;
  53392. /**
  53393. * Rebuilds the elements related to this component in case of
  53394. * context lost for instance.
  53395. */
  53396. rebuild(): void;
  53397. /**
  53398. * Disposes the component and the associated ressources
  53399. */
  53400. dispose(): void;
  53401. }
  53402. }
  53403. declare module "babylonjs/Physics/physicsHelper" {
  53404. import { Nullable } from "babylonjs/types";
  53405. import { Vector3 } from "babylonjs/Maths/math";
  53406. import { Mesh } from "babylonjs/Meshes/mesh";
  53407. import { Scene } from "babylonjs/scene";
  53408. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53409. /**
  53410. * A helper for physics simulations
  53411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53412. */
  53413. export class PhysicsHelper {
  53414. private _scene;
  53415. private _physicsEngine;
  53416. /**
  53417. * Initializes the Physics helper
  53418. * @param scene Babylon.js scene
  53419. */
  53420. constructor(scene: Scene);
  53421. /**
  53422. * Applies a radial explosion impulse
  53423. * @param origin the origin of the explosion
  53424. * @param radiusOrEventOptions the radius or the options of radial explosion
  53425. * @param strength the explosion strength
  53426. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53427. * @returns A physics radial explosion event, or null
  53428. */
  53429. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53430. /**
  53431. * Applies a radial explosion force
  53432. * @param origin the origin of the explosion
  53433. * @param radiusOrEventOptions the radius or the options of radial explosion
  53434. * @param strength the explosion strength
  53435. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53436. * @returns A physics radial explosion event, or null
  53437. */
  53438. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53439. /**
  53440. * Creates a gravitational field
  53441. * @param origin the origin of the explosion
  53442. * @param radiusOrEventOptions the radius or the options of radial explosion
  53443. * @param strength the explosion strength
  53444. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53445. * @returns A physics gravitational field event, or null
  53446. */
  53447. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53448. /**
  53449. * Creates a physics updraft event
  53450. * @param origin the origin of the updraft
  53451. * @param radiusOrEventOptions the radius or the options of the updraft
  53452. * @param strength the strength of the updraft
  53453. * @param height the height of the updraft
  53454. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53455. * @returns A physics updraft event, or null
  53456. */
  53457. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53458. /**
  53459. * Creates a physics vortex event
  53460. * @param origin the of the vortex
  53461. * @param radiusOrEventOptions the radius or the options of the vortex
  53462. * @param strength the strength of the vortex
  53463. * @param height the height of the vortex
  53464. * @returns a Physics vortex event, or null
  53465. * A physics vortex event or null
  53466. */
  53467. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53468. }
  53469. /**
  53470. * Represents a physics radial explosion event
  53471. */
  53472. class PhysicsRadialExplosionEvent {
  53473. private _scene;
  53474. private _options;
  53475. private _sphere;
  53476. private _dataFetched;
  53477. /**
  53478. * Initializes a radial explosioin event
  53479. * @param _scene BabylonJS scene
  53480. * @param _options The options for the vortex event
  53481. */
  53482. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53483. /**
  53484. * Returns the data related to the radial explosion event (sphere).
  53485. * @returns The radial explosion event data
  53486. */
  53487. getData(): PhysicsRadialExplosionEventData;
  53488. /**
  53489. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53490. * @param impostor A physics imposter
  53491. * @param origin the origin of the explosion
  53492. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53493. */
  53494. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53495. /**
  53496. * Triggers affecterd impostors callbacks
  53497. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53498. */
  53499. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53500. /**
  53501. * Disposes the sphere.
  53502. * @param force Specifies if the sphere should be disposed by force
  53503. */
  53504. dispose(force?: boolean): void;
  53505. /*** Helpers ***/
  53506. private _prepareSphere;
  53507. private _intersectsWithSphere;
  53508. }
  53509. /**
  53510. * Represents a gravitational field event
  53511. */
  53512. class PhysicsGravitationalFieldEvent {
  53513. private _physicsHelper;
  53514. private _scene;
  53515. private _origin;
  53516. private _options;
  53517. private _tickCallback;
  53518. private _sphere;
  53519. private _dataFetched;
  53520. /**
  53521. * Initializes the physics gravitational field event
  53522. * @param _physicsHelper A physics helper
  53523. * @param _scene BabylonJS scene
  53524. * @param _origin The origin position of the gravitational field event
  53525. * @param _options The options for the vortex event
  53526. */
  53527. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53528. /**
  53529. * Returns the data related to the gravitational field event (sphere).
  53530. * @returns A gravitational field event
  53531. */
  53532. getData(): PhysicsGravitationalFieldEventData;
  53533. /**
  53534. * Enables the gravitational field.
  53535. */
  53536. enable(): void;
  53537. /**
  53538. * Disables the gravitational field.
  53539. */
  53540. disable(): void;
  53541. /**
  53542. * Disposes the sphere.
  53543. * @param force The force to dispose from the gravitational field event
  53544. */
  53545. dispose(force?: boolean): void;
  53546. private _tick;
  53547. }
  53548. /**
  53549. * Represents a physics updraft event
  53550. */
  53551. class PhysicsUpdraftEvent {
  53552. private _scene;
  53553. private _origin;
  53554. private _options;
  53555. private _physicsEngine;
  53556. private _originTop;
  53557. private _originDirection;
  53558. private _tickCallback;
  53559. private _cylinder;
  53560. private _cylinderPosition;
  53561. private _dataFetched;
  53562. /**
  53563. * Initializes the physics updraft event
  53564. * @param _scene BabylonJS scene
  53565. * @param _origin The origin position of the updraft
  53566. * @param _options The options for the updraft event
  53567. */
  53568. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53569. /**
  53570. * Returns the data related to the updraft event (cylinder).
  53571. * @returns A physics updraft event
  53572. */
  53573. getData(): PhysicsUpdraftEventData;
  53574. /**
  53575. * Enables the updraft.
  53576. */
  53577. enable(): void;
  53578. /**
  53579. * Disables the updraft.
  53580. */
  53581. disable(): void;
  53582. /**
  53583. * Disposes the cylinder.
  53584. * @param force Specifies if the updraft should be disposed by force
  53585. */
  53586. dispose(force?: boolean): void;
  53587. private getImpostorHitData;
  53588. private _tick;
  53589. /*** Helpers ***/
  53590. private _prepareCylinder;
  53591. private _intersectsWithCylinder;
  53592. }
  53593. /**
  53594. * Represents a physics vortex event
  53595. */
  53596. class PhysicsVortexEvent {
  53597. private _scene;
  53598. private _origin;
  53599. private _options;
  53600. private _physicsEngine;
  53601. private _originTop;
  53602. private _tickCallback;
  53603. private _cylinder;
  53604. private _cylinderPosition;
  53605. private _dataFetched;
  53606. /**
  53607. * Initializes the physics vortex event
  53608. * @param _scene The BabylonJS scene
  53609. * @param _origin The origin position of the vortex
  53610. * @param _options The options for the vortex event
  53611. */
  53612. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53613. /**
  53614. * Returns the data related to the vortex event (cylinder).
  53615. * @returns The physics vortex event data
  53616. */
  53617. getData(): PhysicsVortexEventData;
  53618. /**
  53619. * Enables the vortex.
  53620. */
  53621. enable(): void;
  53622. /**
  53623. * Disables the cortex.
  53624. */
  53625. disable(): void;
  53626. /**
  53627. * Disposes the sphere.
  53628. * @param force
  53629. */
  53630. dispose(force?: boolean): void;
  53631. private getImpostorHitData;
  53632. private _tick;
  53633. /*** Helpers ***/
  53634. private _prepareCylinder;
  53635. private _intersectsWithCylinder;
  53636. }
  53637. /**
  53638. * Options fot the radial explosion event
  53639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53640. */
  53641. export class PhysicsRadialExplosionEventOptions {
  53642. /**
  53643. * The radius of the sphere for the radial explosion.
  53644. */
  53645. radius: number;
  53646. /**
  53647. * The strenth of the explosion.
  53648. */
  53649. strength: number;
  53650. /**
  53651. * The strenght of the force in correspondence to the distance of the affected object
  53652. */
  53653. falloff: PhysicsRadialImpulseFalloff;
  53654. /**
  53655. * Sphere options for the radial explosion.
  53656. */
  53657. sphere: {
  53658. segments: number;
  53659. diameter: number;
  53660. };
  53661. /**
  53662. * Sphere options for the radial explosion.
  53663. */
  53664. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53665. }
  53666. /**
  53667. * Options fot the updraft event
  53668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53669. */
  53670. export class PhysicsUpdraftEventOptions {
  53671. /**
  53672. * The radius of the cylinder for the vortex
  53673. */
  53674. radius: number;
  53675. /**
  53676. * The strenth of the updraft.
  53677. */
  53678. strength: number;
  53679. /**
  53680. * The height of the cylinder for the updraft.
  53681. */
  53682. height: number;
  53683. /**
  53684. * The mode for the the updraft.
  53685. */
  53686. updraftMode: PhysicsUpdraftMode;
  53687. }
  53688. /**
  53689. * Options fot the vortex event
  53690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53691. */
  53692. export class PhysicsVortexEventOptions {
  53693. /**
  53694. * The radius of the cylinder for the vortex
  53695. */
  53696. radius: number;
  53697. /**
  53698. * The strenth of the vortex.
  53699. */
  53700. strength: number;
  53701. /**
  53702. * The height of the cylinder for the vortex.
  53703. */
  53704. height: number;
  53705. /**
  53706. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53707. */
  53708. centripetalForceThreshold: number;
  53709. /**
  53710. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53711. */
  53712. centripetalForceMultiplier: number;
  53713. /**
  53714. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53715. */
  53716. centrifugalForceMultiplier: number;
  53717. /**
  53718. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53719. */
  53720. updraftForceMultiplier: number;
  53721. }
  53722. /**
  53723. * The strenght of the force in correspondence to the distance of the affected object
  53724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53725. */
  53726. export enum PhysicsRadialImpulseFalloff {
  53727. /** Defines that impulse is constant in strength across it's whole radius */
  53728. Constant = 0,
  53729. /** Defines that impulse gets weaker if it's further from the origin */
  53730. Linear = 1
  53731. }
  53732. /**
  53733. * The strength of the force in correspondence to the distance of the affected object
  53734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53735. */
  53736. export enum PhysicsUpdraftMode {
  53737. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53738. Center = 0,
  53739. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53740. Perpendicular = 1
  53741. }
  53742. /**
  53743. * Interface for a physics hit data
  53744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53745. */
  53746. export interface PhysicsHitData {
  53747. /**
  53748. * The force applied at the contact point
  53749. */
  53750. force: Vector3;
  53751. /**
  53752. * The contact point
  53753. */
  53754. contactPoint: Vector3;
  53755. /**
  53756. * The distance from the origin to the contact point
  53757. */
  53758. distanceFromOrigin: number;
  53759. }
  53760. /**
  53761. * Interface for radial explosion event data
  53762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53763. */
  53764. export interface PhysicsRadialExplosionEventData {
  53765. /**
  53766. * A sphere used for the radial explosion event
  53767. */
  53768. sphere: Mesh;
  53769. }
  53770. /**
  53771. * Interface for gravitational field event data
  53772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53773. */
  53774. export interface PhysicsGravitationalFieldEventData {
  53775. /**
  53776. * A sphere mesh used for the gravitational field event
  53777. */
  53778. sphere: Mesh;
  53779. }
  53780. /**
  53781. * Interface for updraft event data
  53782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53783. */
  53784. export interface PhysicsUpdraftEventData {
  53785. /**
  53786. * A cylinder used for the updraft event
  53787. */
  53788. cylinder: Mesh;
  53789. }
  53790. /**
  53791. * Interface for vortex event data
  53792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53793. */
  53794. export interface PhysicsVortexEventData {
  53795. /**
  53796. * A cylinder used for the vortex event
  53797. */
  53798. cylinder: Mesh;
  53799. }
  53800. /**
  53801. * Interface for an affected physics impostor
  53802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53803. */
  53804. export interface PhysicsAffectedImpostorWithData {
  53805. /**
  53806. * The impostor affected by the effect
  53807. */
  53808. impostor: PhysicsImpostor;
  53809. /**
  53810. * The data about the hit/horce from the explosion
  53811. */
  53812. hitData: PhysicsHitData;
  53813. }
  53814. }
  53815. declare module "babylonjs/Physics/Plugins/index" {
  53816. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53817. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53818. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53819. }
  53820. declare module "babylonjs/Physics/index" {
  53821. export * from "babylonjs/Physics/IPhysicsEngine";
  53822. export * from "babylonjs/Physics/physicsEngine";
  53823. export * from "babylonjs/Physics/physicsEngineComponent";
  53824. export * from "babylonjs/Physics/physicsHelper";
  53825. export * from "babylonjs/Physics/physicsImpostor";
  53826. export * from "babylonjs/Physics/physicsJoint";
  53827. export * from "babylonjs/Physics/Plugins/index";
  53828. }
  53829. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53830. /** @hidden */
  53831. export var blackAndWhitePixelShader: {
  53832. name: string;
  53833. shader: string;
  53834. };
  53835. }
  53836. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53838. import { Camera } from "babylonjs/Cameras/camera";
  53839. import { Engine } from "babylonjs/Engines/engine";
  53840. import "babylonjs/Shaders/blackAndWhite.fragment";
  53841. /**
  53842. * Post process used to render in black and white
  53843. */
  53844. export class BlackAndWhitePostProcess extends PostProcess {
  53845. /**
  53846. * Linear about to convert he result to black and white (default: 1)
  53847. */
  53848. degree: number;
  53849. /**
  53850. * Creates a black and white post process
  53851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53852. * @param name The name of the effect.
  53853. * @param options The required width/height ratio to downsize to before computing the render pass.
  53854. * @param camera The camera to apply the render pass to.
  53855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53856. * @param engine The engine which the post process will be applied. (default: current engine)
  53857. * @param reusable If the post process can be reused on the same frame. (default: false)
  53858. */
  53859. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53860. }
  53861. }
  53862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53863. import { Nullable } from "babylonjs/types";
  53864. import { Camera } from "babylonjs/Cameras/camera";
  53865. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53866. import { Engine } from "babylonjs/Engines/engine";
  53867. /**
  53868. * This represents a set of one or more post processes in Babylon.
  53869. * A post process can be used to apply a shader to a texture after it is rendered.
  53870. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53871. */
  53872. export class PostProcessRenderEffect {
  53873. private _postProcesses;
  53874. private _getPostProcesses;
  53875. private _singleInstance;
  53876. private _cameras;
  53877. private _indicesForCamera;
  53878. /**
  53879. * Name of the effect
  53880. * @hidden
  53881. */
  53882. _name: string;
  53883. /**
  53884. * Instantiates a post process render effect.
  53885. * A post process can be used to apply a shader to a texture after it is rendered.
  53886. * @param engine The engine the effect is tied to
  53887. * @param name The name of the effect
  53888. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53889. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53890. */
  53891. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53892. /**
  53893. * Checks if all the post processes in the effect are supported.
  53894. */
  53895. readonly isSupported: boolean;
  53896. /**
  53897. * Updates the current state of the effect
  53898. * @hidden
  53899. */
  53900. _update(): void;
  53901. /**
  53902. * Attaches the effect on cameras
  53903. * @param cameras The camera to attach to.
  53904. * @hidden
  53905. */
  53906. _attachCameras(cameras: Camera): void;
  53907. /**
  53908. * Attaches the effect on cameras
  53909. * @param cameras The camera to attach to.
  53910. * @hidden
  53911. */
  53912. _attachCameras(cameras: Camera[]): void;
  53913. /**
  53914. * Detatches the effect on cameras
  53915. * @param cameras The camera to detatch from.
  53916. * @hidden
  53917. */
  53918. _detachCameras(cameras: Camera): void;
  53919. /**
  53920. * Detatches the effect on cameras
  53921. * @param cameras The camera to detatch from.
  53922. * @hidden
  53923. */
  53924. _detachCameras(cameras: Camera[]): void;
  53925. /**
  53926. * Enables the effect on given cameras
  53927. * @param cameras The camera to enable.
  53928. * @hidden
  53929. */
  53930. _enable(cameras: Camera): void;
  53931. /**
  53932. * Enables the effect on given cameras
  53933. * @param cameras The camera to enable.
  53934. * @hidden
  53935. */
  53936. _enable(cameras: Nullable<Camera[]>): void;
  53937. /**
  53938. * Disables the effect on the given cameras
  53939. * @param cameras The camera to disable.
  53940. * @hidden
  53941. */
  53942. _disable(cameras: Camera): void;
  53943. /**
  53944. * Disables the effect on the given cameras
  53945. * @param cameras The camera to disable.
  53946. * @hidden
  53947. */
  53948. _disable(cameras: Nullable<Camera[]>): void;
  53949. /**
  53950. * Gets a list of the post processes contained in the effect.
  53951. * @param camera The camera to get the post processes on.
  53952. * @returns The list of the post processes in the effect.
  53953. */
  53954. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53955. }
  53956. }
  53957. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53959. /** @hidden */
  53960. export var extractHighlightsPixelShader: {
  53961. name: string;
  53962. shader: string;
  53963. };
  53964. }
  53965. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53966. import { Nullable } from "babylonjs/types";
  53967. import { Camera } from "babylonjs/Cameras/camera";
  53968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53969. import { Engine } from "babylonjs/Engines/engine";
  53970. import "babylonjs/Shaders/extractHighlights.fragment";
  53971. /**
  53972. * 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.
  53973. */
  53974. export class ExtractHighlightsPostProcess extends PostProcess {
  53975. /**
  53976. * The luminance threshold, pixels below this value will be set to black.
  53977. */
  53978. threshold: number;
  53979. /** @hidden */
  53980. _exposure: number;
  53981. /**
  53982. * Post process which has the input texture to be used when performing highlight extraction
  53983. * @hidden
  53984. */
  53985. _inputPostProcess: Nullable<PostProcess>;
  53986. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53987. }
  53988. }
  53989. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53990. /** @hidden */
  53991. export var bloomMergePixelShader: {
  53992. name: string;
  53993. shader: string;
  53994. };
  53995. }
  53996. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53998. import { Nullable } from "babylonjs/types";
  53999. import { Engine } from "babylonjs/Engines/engine";
  54000. import { Camera } from "babylonjs/Cameras/camera";
  54001. import "babylonjs/Shaders/bloomMerge.fragment";
  54002. /**
  54003. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54004. */
  54005. export class BloomMergePostProcess extends PostProcess {
  54006. /** Weight of the bloom to be added to the original input. */
  54007. weight: number;
  54008. /**
  54009. * Creates a new instance of @see BloomMergePostProcess
  54010. * @param name The name of the effect.
  54011. * @param originalFromInput Post process which's input will be used for the merge.
  54012. * @param blurred Blurred highlights post process which's output will be used.
  54013. * @param weight Weight of the bloom to be added to the original input.
  54014. * @param options The required width/height ratio to downsize to before computing the render pass.
  54015. * @param camera The camera to apply the render pass to.
  54016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54017. * @param engine The engine which the post process will be applied. (default: current engine)
  54018. * @param reusable If the post process can be reused on the same frame. (default: false)
  54019. * @param textureType Type of textures used when performing the post process. (default: 0)
  54020. * @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)
  54021. */
  54022. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54023. /** Weight of the bloom to be added to the original input. */
  54024. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54025. }
  54026. }
  54027. declare module "babylonjs/PostProcesses/bloomEffect" {
  54028. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54029. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54030. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54031. import { Camera } from "babylonjs/Cameras/camera";
  54032. import { Scene } from "babylonjs/scene";
  54033. /**
  54034. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54035. */
  54036. export class BloomEffect extends PostProcessRenderEffect {
  54037. private bloomScale;
  54038. /**
  54039. * @hidden Internal
  54040. */
  54041. _effects: Array<PostProcess>;
  54042. /**
  54043. * @hidden Internal
  54044. */
  54045. _downscale: ExtractHighlightsPostProcess;
  54046. private _blurX;
  54047. private _blurY;
  54048. private _merge;
  54049. /**
  54050. * The luminance threshold to find bright areas of the image to bloom.
  54051. */
  54052. threshold: number;
  54053. /**
  54054. * The strength of the bloom.
  54055. */
  54056. weight: number;
  54057. /**
  54058. * Specifies the size of the bloom blur kernel, relative to the final output size
  54059. */
  54060. kernel: number;
  54061. /**
  54062. * Creates a new instance of @see BloomEffect
  54063. * @param scene The scene the effect belongs to.
  54064. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54065. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54066. * @param bloomWeight The the strength of bloom.
  54067. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54068. * @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)
  54069. */
  54070. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54071. /**
  54072. * Disposes each of the internal effects for a given camera.
  54073. * @param camera The camera to dispose the effect on.
  54074. */
  54075. disposeEffects(camera: Camera): void;
  54076. /**
  54077. * @hidden Internal
  54078. */
  54079. _updateEffects(): void;
  54080. /**
  54081. * Internal
  54082. * @returns if all the contained post processes are ready.
  54083. * @hidden
  54084. */
  54085. _isReady(): boolean;
  54086. }
  54087. }
  54088. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54089. /** @hidden */
  54090. export var chromaticAberrationPixelShader: {
  54091. name: string;
  54092. shader: string;
  54093. };
  54094. }
  54095. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54096. import { Vector2 } from "babylonjs/Maths/math";
  54097. import { Nullable } from "babylonjs/types";
  54098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54099. import { Camera } from "babylonjs/Cameras/camera";
  54100. import { Engine } from "babylonjs/Engines/engine";
  54101. import "babylonjs/Shaders/chromaticAberration.fragment";
  54102. /**
  54103. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54104. */
  54105. export class ChromaticAberrationPostProcess extends PostProcess {
  54106. /**
  54107. * The amount of seperation of rgb channels (default: 30)
  54108. */
  54109. aberrationAmount: number;
  54110. /**
  54111. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54112. */
  54113. radialIntensity: number;
  54114. /**
  54115. * 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))
  54116. */
  54117. direction: Vector2;
  54118. /**
  54119. * 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))
  54120. */
  54121. centerPosition: Vector2;
  54122. /**
  54123. * Creates a new instance ChromaticAberrationPostProcess
  54124. * @param name The name of the effect.
  54125. * @param screenWidth The width of the screen to apply the effect on.
  54126. * @param screenHeight The height of the screen to apply the effect on.
  54127. * @param options The required width/height ratio to downsize to before computing the render pass.
  54128. * @param camera The camera to apply the render pass to.
  54129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54130. * @param engine The engine which the post process will be applied. (default: current engine)
  54131. * @param reusable If the post process can be reused on the same frame. (default: false)
  54132. * @param textureType Type of textures used when performing the post process. (default: 0)
  54133. * @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)
  54134. */
  54135. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54136. }
  54137. }
  54138. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54139. /** @hidden */
  54140. export var circleOfConfusionPixelShader: {
  54141. name: string;
  54142. shader: string;
  54143. };
  54144. }
  54145. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54146. import { Nullable } from "babylonjs/types";
  54147. import { Engine } from "babylonjs/Engines/engine";
  54148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54150. import { Camera } from "babylonjs/Cameras/camera";
  54151. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54152. /**
  54153. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54154. */
  54155. export class CircleOfConfusionPostProcess extends PostProcess {
  54156. /**
  54157. * 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.
  54158. */
  54159. lensSize: number;
  54160. /**
  54161. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54162. */
  54163. fStop: number;
  54164. /**
  54165. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54166. */
  54167. focusDistance: number;
  54168. /**
  54169. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54170. */
  54171. focalLength: number;
  54172. private _depthTexture;
  54173. /**
  54174. * Creates a new instance CircleOfConfusionPostProcess
  54175. * @param name The name of the effect.
  54176. * @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.
  54177. * @param options The required width/height ratio to downsize to before computing the render pass.
  54178. * @param camera The camera to apply the render pass to.
  54179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54180. * @param engine The engine which the post process will be applied. (default: current engine)
  54181. * @param reusable If the post process can be reused on the same frame. (default: false)
  54182. * @param textureType Type of textures used when performing the post process. (default: 0)
  54183. * @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)
  54184. */
  54185. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54186. /**
  54187. * 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.
  54188. */
  54189. depthTexture: RenderTargetTexture;
  54190. }
  54191. }
  54192. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54193. /** @hidden */
  54194. export var colorCorrectionPixelShader: {
  54195. name: string;
  54196. shader: string;
  54197. };
  54198. }
  54199. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54200. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54201. import { Engine } from "babylonjs/Engines/engine";
  54202. import { Camera } from "babylonjs/Cameras/camera";
  54203. import "babylonjs/Shaders/colorCorrection.fragment";
  54204. /**
  54205. *
  54206. * This post-process allows the modification of rendered colors by using
  54207. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54208. *
  54209. * The object needs to be provided an url to a texture containing the color
  54210. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54211. * Use an image editing software to tweak the LUT to match your needs.
  54212. *
  54213. * For an example of a color LUT, see here:
  54214. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54215. * For explanations on color grading, see here:
  54216. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54217. *
  54218. */
  54219. export class ColorCorrectionPostProcess extends PostProcess {
  54220. private _colorTableTexture;
  54221. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54222. }
  54223. }
  54224. declare module "babylonjs/Shaders/convolution.fragment" {
  54225. /** @hidden */
  54226. export var convolutionPixelShader: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54233. import { Nullable } from "babylonjs/types";
  54234. import { Camera } from "babylonjs/Cameras/camera";
  54235. import { Engine } from "babylonjs/Engines/engine";
  54236. import "babylonjs/Shaders/convolution.fragment";
  54237. /**
  54238. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54239. * input texture to perform effects such as edge detection or sharpening
  54240. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54241. */
  54242. export class ConvolutionPostProcess extends PostProcess {
  54243. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54244. kernel: number[];
  54245. /**
  54246. * Creates a new instance ConvolutionPostProcess
  54247. * @param name The name of the effect.
  54248. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54249. * @param options The required width/height ratio to downsize to before computing the render pass.
  54250. * @param camera The camera to apply the render pass to.
  54251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54252. * @param engine The engine which the post process will be applied. (default: current engine)
  54253. * @param reusable If the post process can be reused on the same frame. (default: false)
  54254. * @param textureType Type of textures used when performing the post process. (default: 0)
  54255. */
  54256. constructor(name: string,
  54257. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54258. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54259. /**
  54260. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54261. */
  54262. static EdgeDetect0Kernel: number[];
  54263. /**
  54264. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54265. */
  54266. static EdgeDetect1Kernel: number[];
  54267. /**
  54268. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54269. */
  54270. static EdgeDetect2Kernel: number[];
  54271. /**
  54272. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54273. */
  54274. static SharpenKernel: number[];
  54275. /**
  54276. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54277. */
  54278. static EmbossKernel: number[];
  54279. /**
  54280. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54281. */
  54282. static GaussianKernel: number[];
  54283. }
  54284. }
  54285. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54286. import { Nullable } from "babylonjs/types";
  54287. import { Vector2 } from "babylonjs/Maths/math";
  54288. import { Camera } from "babylonjs/Cameras/camera";
  54289. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54290. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54291. import { Engine } from "babylonjs/Engines/engine";
  54292. import { Scene } from "babylonjs/scene";
  54293. /**
  54294. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54295. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54296. * based on samples that have a large difference in distance than the center pixel.
  54297. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54298. */
  54299. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54300. direction: Vector2;
  54301. /**
  54302. * Creates a new instance CircleOfConfusionPostProcess
  54303. * @param name The name of the effect.
  54304. * @param scene The scene the effect belongs to.
  54305. * @param direction The direction the blur should be applied.
  54306. * @param kernel The size of the kernel used to blur.
  54307. * @param options The required width/height ratio to downsize to before computing the render pass.
  54308. * @param camera The camera to apply the render pass to.
  54309. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54310. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54312. * @param engine The engine which the post process will be applied. (default: current engine)
  54313. * @param reusable If the post process can be reused on the same frame. (default: false)
  54314. * @param textureType Type of textures used when performing the post process. (default: 0)
  54315. * @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)
  54316. */
  54317. 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);
  54318. }
  54319. }
  54320. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54321. /** @hidden */
  54322. export var depthOfFieldMergePixelShader: {
  54323. name: string;
  54324. shader: string;
  54325. };
  54326. }
  54327. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54328. import { Nullable } from "babylonjs/types";
  54329. import { Camera } from "babylonjs/Cameras/camera";
  54330. import { Effect } from "babylonjs/Materials/effect";
  54331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54332. import { Engine } from "babylonjs/Engines/engine";
  54333. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54334. /**
  54335. * Options to be set when merging outputs from the default pipeline.
  54336. */
  54337. export class DepthOfFieldMergePostProcessOptions {
  54338. /**
  54339. * The original image to merge on top of
  54340. */
  54341. originalFromInput: PostProcess;
  54342. /**
  54343. * Parameters to perform the merge of the depth of field effect
  54344. */
  54345. depthOfField?: {
  54346. circleOfConfusion: PostProcess;
  54347. blurSteps: Array<PostProcess>;
  54348. };
  54349. /**
  54350. * Parameters to perform the merge of bloom effect
  54351. */
  54352. bloom?: {
  54353. blurred: PostProcess;
  54354. weight: number;
  54355. };
  54356. }
  54357. /**
  54358. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54359. */
  54360. export class DepthOfFieldMergePostProcess extends PostProcess {
  54361. private blurSteps;
  54362. /**
  54363. * Creates a new instance of DepthOfFieldMergePostProcess
  54364. * @param name The name of the effect.
  54365. * @param originalFromInput Post process which's input will be used for the merge.
  54366. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54367. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54368. * @param options The required width/height ratio to downsize to before computing the render pass.
  54369. * @param camera The camera to apply the render pass to.
  54370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54371. * @param engine The engine which the post process will be applied. (default: current engine)
  54372. * @param reusable If the post process can be reused on the same frame. (default: false)
  54373. * @param textureType Type of textures used when performing the post process. (default: 0)
  54374. * @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)
  54375. */
  54376. 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);
  54377. /**
  54378. * Updates the effect with the current post process compile time values and recompiles the shader.
  54379. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54380. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54381. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54382. * @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
  54383. * @param onCompiled Called when the shader has been compiled.
  54384. * @param onError Called if there is an error when compiling a shader.
  54385. */
  54386. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54387. }
  54388. }
  54389. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54390. import { Nullable } from "babylonjs/types";
  54391. import { Camera } from "babylonjs/Cameras/camera";
  54392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54393. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54394. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54395. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54396. import { Scene } from "babylonjs/scene";
  54397. /**
  54398. * Specifies the level of max blur that should be applied when using the depth of field effect
  54399. */
  54400. export enum DepthOfFieldEffectBlurLevel {
  54401. /**
  54402. * Subtle blur
  54403. */
  54404. Low = 0,
  54405. /**
  54406. * Medium blur
  54407. */
  54408. Medium = 1,
  54409. /**
  54410. * Large blur
  54411. */
  54412. High = 2
  54413. }
  54414. /**
  54415. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54416. */
  54417. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54418. private _circleOfConfusion;
  54419. /**
  54420. * @hidden Internal, blurs from high to low
  54421. */
  54422. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54423. private _depthOfFieldBlurY;
  54424. private _dofMerge;
  54425. /**
  54426. * @hidden Internal post processes in depth of field effect
  54427. */
  54428. _effects: Array<PostProcess>;
  54429. /**
  54430. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54431. */
  54432. focalLength: number;
  54433. /**
  54434. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54435. */
  54436. fStop: number;
  54437. /**
  54438. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54439. */
  54440. focusDistance: number;
  54441. /**
  54442. * 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.
  54443. */
  54444. lensSize: number;
  54445. /**
  54446. * Creates a new instance DepthOfFieldEffect
  54447. * @param scene The scene the effect belongs to.
  54448. * @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.
  54449. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54450. * @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)
  54451. */
  54452. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54453. /**
  54454. * 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.
  54455. */
  54456. depthTexture: RenderTargetTexture;
  54457. /**
  54458. * Disposes each of the internal effects for a given camera.
  54459. * @param camera The camera to dispose the effect on.
  54460. */
  54461. disposeEffects(camera: Camera): void;
  54462. /**
  54463. * @hidden Internal
  54464. */
  54465. _updateEffects(): void;
  54466. /**
  54467. * Internal
  54468. * @returns if all the contained post processes are ready.
  54469. * @hidden
  54470. */
  54471. _isReady(): boolean;
  54472. }
  54473. }
  54474. declare module "babylonjs/Shaders/displayPass.fragment" {
  54475. /** @hidden */
  54476. export var displayPassPixelShader: {
  54477. name: string;
  54478. shader: string;
  54479. };
  54480. }
  54481. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54482. import { Nullable } from "babylonjs/types";
  54483. import { Camera } from "babylonjs/Cameras/camera";
  54484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54485. import { Engine } from "babylonjs/Engines/engine";
  54486. import "babylonjs/Shaders/displayPass.fragment";
  54487. /**
  54488. * DisplayPassPostProcess which produces an output the same as it's input
  54489. */
  54490. export class DisplayPassPostProcess extends PostProcess {
  54491. /**
  54492. * Creates the DisplayPassPostProcess
  54493. * @param name The name of the effect.
  54494. * @param options The required width/height ratio to downsize to before computing the render pass.
  54495. * @param camera The camera to apply the render pass to.
  54496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54497. * @param engine The engine which the post process will be applied. (default: current engine)
  54498. * @param reusable If the post process can be reused on the same frame. (default: false)
  54499. */
  54500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54501. }
  54502. }
  54503. declare module "babylonjs/Shaders/filter.fragment" {
  54504. /** @hidden */
  54505. export var filterPixelShader: {
  54506. name: string;
  54507. shader: string;
  54508. };
  54509. }
  54510. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54511. import { Nullable } from "babylonjs/types";
  54512. import { Matrix } from "babylonjs/Maths/math";
  54513. import { Camera } from "babylonjs/Cameras/camera";
  54514. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54515. import { Engine } from "babylonjs/Engines/engine";
  54516. import "babylonjs/Shaders/filter.fragment";
  54517. /**
  54518. * Applies a kernel filter to the image
  54519. */
  54520. export class FilterPostProcess extends PostProcess {
  54521. /** The matrix to be applied to the image */
  54522. kernelMatrix: Matrix;
  54523. /**
  54524. *
  54525. * @param name The name of the effect.
  54526. * @param kernelMatrix The matrix to be applied to the image
  54527. * @param options The required width/height ratio to downsize to before computing the render pass.
  54528. * @param camera The camera to apply the render pass to.
  54529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54530. * @param engine The engine which the post process will be applied. (default: current engine)
  54531. * @param reusable If the post process can be reused on the same frame. (default: false)
  54532. */
  54533. constructor(name: string,
  54534. /** The matrix to be applied to the image */
  54535. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54536. }
  54537. }
  54538. declare module "babylonjs/Shaders/fxaa.fragment" {
  54539. /** @hidden */
  54540. export var fxaaPixelShader: {
  54541. name: string;
  54542. shader: string;
  54543. };
  54544. }
  54545. declare module "babylonjs/Shaders/fxaa.vertex" {
  54546. /** @hidden */
  54547. export var fxaaVertexShader: {
  54548. name: string;
  54549. shader: string;
  54550. };
  54551. }
  54552. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54553. import { Nullable } from "babylonjs/types";
  54554. import { Camera } from "babylonjs/Cameras/camera";
  54555. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54556. import { Engine } from "babylonjs/Engines/engine";
  54557. import "babylonjs/Shaders/fxaa.fragment";
  54558. import "babylonjs/Shaders/fxaa.vertex";
  54559. /**
  54560. * Fxaa post process
  54561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54562. */
  54563. export class FxaaPostProcess extends PostProcess {
  54564. /** @hidden */
  54565. texelWidth: number;
  54566. /** @hidden */
  54567. texelHeight: number;
  54568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54569. private _getDefines;
  54570. }
  54571. }
  54572. declare module "babylonjs/Shaders/grain.fragment" {
  54573. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54574. /** @hidden */
  54575. export var grainPixelShader: {
  54576. name: string;
  54577. shader: string;
  54578. };
  54579. }
  54580. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54581. import { Nullable } from "babylonjs/types";
  54582. import { Camera } from "babylonjs/Cameras/camera";
  54583. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54584. import { Engine } from "babylonjs/Engines/engine";
  54585. import "babylonjs/Shaders/grain.fragment";
  54586. /**
  54587. * The GrainPostProcess adds noise to the image at mid luminance levels
  54588. */
  54589. export class GrainPostProcess extends PostProcess {
  54590. /**
  54591. * The intensity of the grain added (default: 30)
  54592. */
  54593. intensity: number;
  54594. /**
  54595. * If the grain should be randomized on every frame
  54596. */
  54597. animated: boolean;
  54598. /**
  54599. * Creates a new instance of @see GrainPostProcess
  54600. * @param name The name of the effect.
  54601. * @param options The required width/height ratio to downsize to before computing the render pass.
  54602. * @param camera The camera to apply the render pass to.
  54603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54604. * @param engine The engine which the post process will be applied. (default: current engine)
  54605. * @param reusable If the post process can be reused on the same frame. (default: false)
  54606. * @param textureType Type of textures used when performing the post process. (default: 0)
  54607. * @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)
  54608. */
  54609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54610. }
  54611. }
  54612. declare module "babylonjs/Shaders/highlights.fragment" {
  54613. /** @hidden */
  54614. export var highlightsPixelShader: {
  54615. name: string;
  54616. shader: string;
  54617. };
  54618. }
  54619. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54620. import { Nullable } from "babylonjs/types";
  54621. import { Camera } from "babylonjs/Cameras/camera";
  54622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54623. import { Engine } from "babylonjs/Engines/engine";
  54624. import "babylonjs/Shaders/highlights.fragment";
  54625. /**
  54626. * Extracts highlights from the image
  54627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54628. */
  54629. export class HighlightsPostProcess extends PostProcess {
  54630. /**
  54631. * Extracts highlights from the image
  54632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54633. * @param name The name of the effect.
  54634. * @param options The required width/height ratio to downsize to before computing the render pass.
  54635. * @param camera The camera to apply the render pass to.
  54636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54637. * @param engine The engine which the post process will be applied. (default: current engine)
  54638. * @param reusable If the post process can be reused on the same frame. (default: false)
  54639. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54640. */
  54641. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54642. }
  54643. }
  54644. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54645. /** @hidden */
  54646. export var mrtFragmentDeclaration: {
  54647. name: string;
  54648. shader: string;
  54649. };
  54650. }
  54651. declare module "babylonjs/Shaders/geometry.fragment" {
  54652. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54653. /** @hidden */
  54654. export var geometryPixelShader: {
  54655. name: string;
  54656. shader: string;
  54657. };
  54658. }
  54659. declare module "babylonjs/Shaders/geometry.vertex" {
  54660. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54661. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54662. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54663. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54664. /** @hidden */
  54665. export var geometryVertexShader: {
  54666. name: string;
  54667. shader: string;
  54668. };
  54669. }
  54670. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54671. import { Matrix } from "babylonjs/Maths/math";
  54672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54673. import { Mesh } from "babylonjs/Meshes/mesh";
  54674. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54675. import { Effect } from "babylonjs/Materials/effect";
  54676. import { Scene } from "babylonjs/scene";
  54677. import "babylonjs/Shaders/geometry.fragment";
  54678. import "babylonjs/Shaders/geometry.vertex";
  54679. /**
  54680. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54681. */
  54682. export class GeometryBufferRenderer {
  54683. /**
  54684. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54685. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54686. */
  54687. static readonly POSITION_TEXTURE_TYPE: number;
  54688. /**
  54689. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54690. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54691. */
  54692. static readonly VELOCITY_TEXTURE_TYPE: number;
  54693. /**
  54694. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54695. * in order to compute objects velocities when enableVelocity is set to "true"
  54696. * @hidden
  54697. */
  54698. _previousTransformationMatrices: {
  54699. [index: number]: Matrix;
  54700. };
  54701. private _scene;
  54702. private _multiRenderTarget;
  54703. private _ratio;
  54704. private _enablePosition;
  54705. private _enableVelocity;
  54706. private _positionIndex;
  54707. private _velocityIndex;
  54708. protected _effect: Effect;
  54709. protected _cachedDefines: string;
  54710. /**
  54711. * Set the render list (meshes to be rendered) used in the G buffer.
  54712. */
  54713. renderList: Mesh[];
  54714. /**
  54715. * Gets wether or not G buffer are supported by the running hardware.
  54716. * This requires draw buffer supports
  54717. */
  54718. readonly isSupported: boolean;
  54719. /**
  54720. * Returns the index of the given texture type in the G-Buffer textures array
  54721. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54722. * @returns the index of the given texture type in the G-Buffer textures array
  54723. */
  54724. getTextureIndex(textureType: number): number;
  54725. /**
  54726. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54727. */
  54728. /**
  54729. * Sets whether or not objects positions are enabled for the G buffer.
  54730. */
  54731. enablePosition: boolean;
  54732. /**
  54733. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54734. */
  54735. /**
  54736. * Sets wether or not objects velocities are enabled for the G buffer.
  54737. */
  54738. enableVelocity: boolean;
  54739. /**
  54740. * Gets the scene associated with the buffer.
  54741. */
  54742. readonly scene: Scene;
  54743. /**
  54744. * Gets the ratio used by the buffer during its creation.
  54745. * How big is the buffer related to the main canvas.
  54746. */
  54747. readonly ratio: number;
  54748. /** @hidden */
  54749. static _SceneComponentInitialization: (scene: Scene) => void;
  54750. /**
  54751. * Creates a new G Buffer for the scene
  54752. * @param scene The scene the buffer belongs to
  54753. * @param ratio How big is the buffer related to the main canvas.
  54754. */
  54755. constructor(scene: Scene, ratio?: number);
  54756. /**
  54757. * Checks wether everything is ready to render a submesh to the G buffer.
  54758. * @param subMesh the submesh to check readiness for
  54759. * @param useInstances is the mesh drawn using instance or not
  54760. * @returns true if ready otherwise false
  54761. */
  54762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54763. /**
  54764. * Gets the current underlying G Buffer.
  54765. * @returns the buffer
  54766. */
  54767. getGBuffer(): MultiRenderTarget;
  54768. /**
  54769. * Gets the number of samples used to render the buffer (anti aliasing).
  54770. */
  54771. /**
  54772. * Sets the number of samples used to render the buffer (anti aliasing).
  54773. */
  54774. samples: number;
  54775. /**
  54776. * Disposes the renderer and frees up associated resources.
  54777. */
  54778. dispose(): void;
  54779. protected _createRenderTargets(): void;
  54780. }
  54781. }
  54782. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54783. import { Nullable } from "babylonjs/types";
  54784. import { Scene } from "babylonjs/scene";
  54785. import { ISceneComponent } from "babylonjs/sceneComponent";
  54786. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54787. module "babylonjs/scene" {
  54788. interface Scene {
  54789. /** @hidden (Backing field) */
  54790. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54791. /**
  54792. * Gets or Sets the current geometry buffer associated to the scene.
  54793. */
  54794. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54795. /**
  54796. * Enables a GeometryBufferRender and associates it with the scene
  54797. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54798. * @returns the GeometryBufferRenderer
  54799. */
  54800. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54801. /**
  54802. * Disables the GeometryBufferRender associated with the scene
  54803. */
  54804. disableGeometryBufferRenderer(): void;
  54805. }
  54806. }
  54807. /**
  54808. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54809. * in several rendering techniques.
  54810. */
  54811. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54812. /**
  54813. * The component name helpful to identify the component in the list of scene components.
  54814. */
  54815. readonly name: string;
  54816. /**
  54817. * The scene the component belongs to.
  54818. */
  54819. scene: Scene;
  54820. /**
  54821. * Creates a new instance of the component for the given scene
  54822. * @param scene Defines the scene to register the component in
  54823. */
  54824. constructor(scene: Scene);
  54825. /**
  54826. * Registers the component in a given scene
  54827. */
  54828. register(): void;
  54829. /**
  54830. * Rebuilds the elements related to this component in case of
  54831. * context lost for instance.
  54832. */
  54833. rebuild(): void;
  54834. /**
  54835. * Disposes the component and the associated ressources
  54836. */
  54837. dispose(): void;
  54838. private _gatherRenderTargets;
  54839. }
  54840. }
  54841. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54842. /** @hidden */
  54843. export var motionBlurPixelShader: {
  54844. name: string;
  54845. shader: string;
  54846. };
  54847. }
  54848. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54849. import { Nullable } from "babylonjs/types";
  54850. import { Camera } from "babylonjs/Cameras/camera";
  54851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54852. import { Scene } from "babylonjs/scene";
  54853. import "babylonjs/Animations/animatable";
  54854. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54855. import "babylonjs/Shaders/motionBlur.fragment";
  54856. import { Engine } from "babylonjs/Engines/engine";
  54857. /**
  54858. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54859. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54860. * As an example, all you have to do is to create the post-process:
  54861. * var mb = new BABYLON.MotionBlurPostProcess(
  54862. * 'mb', // The name of the effect.
  54863. * scene, // The scene containing the objects to blur according to their velocity.
  54864. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54865. * camera // The camera to apply the render pass to.
  54866. * );
  54867. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54868. */
  54869. export class MotionBlurPostProcess extends PostProcess {
  54870. /**
  54871. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54872. */
  54873. motionStrength: number;
  54874. /**
  54875. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54876. */
  54877. /**
  54878. * Sets the number of iterations to be used for motion blur quality
  54879. */
  54880. motionBlurSamples: number;
  54881. private _motionBlurSamples;
  54882. private _geometryBufferRenderer;
  54883. /**
  54884. * Creates a new instance MotionBlurPostProcess
  54885. * @param name The name of the effect.
  54886. * @param scene The scene containing the objects to blur according to their velocity.
  54887. * @param options The required width/height ratio to downsize to before computing the render pass.
  54888. * @param camera The camera to apply the render pass to.
  54889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54890. * @param engine The engine which the post process will be applied. (default: current engine)
  54891. * @param reusable If the post process can be reused on the same frame. (default: false)
  54892. * @param textureType Type of textures used when performing the post process. (default: 0)
  54893. * @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)
  54894. */
  54895. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54896. /**
  54897. * Disposes the post process.
  54898. * @param camera The camera to dispose the post process on.
  54899. */
  54900. dispose(camera?: Camera): void;
  54901. }
  54902. }
  54903. declare module "babylonjs/Shaders/refraction.fragment" {
  54904. /** @hidden */
  54905. export var refractionPixelShader: {
  54906. name: string;
  54907. shader: string;
  54908. };
  54909. }
  54910. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54911. import { Color3 } from "babylonjs/Maths/math";
  54912. import { Camera } from "babylonjs/Cameras/camera";
  54913. import { Texture } from "babylonjs/Materials/Textures/texture";
  54914. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54915. import { Engine } from "babylonjs/Engines/engine";
  54916. import "babylonjs/Shaders/refraction.fragment";
  54917. /**
  54918. * Post process which applies a refractin texture
  54919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54920. */
  54921. export class RefractionPostProcess extends PostProcess {
  54922. /** the base color of the refraction (used to taint the rendering) */
  54923. color: Color3;
  54924. /** simulated refraction depth */
  54925. depth: number;
  54926. /** the coefficient of the base color (0 to remove base color tainting) */
  54927. colorLevel: number;
  54928. private _refTexture;
  54929. private _ownRefractionTexture;
  54930. /**
  54931. * Gets or sets the refraction texture
  54932. * Please note that you are responsible for disposing the texture if you set it manually
  54933. */
  54934. refractionTexture: Texture;
  54935. /**
  54936. * Initializes the RefractionPostProcess
  54937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54938. * @param name The name of the effect.
  54939. * @param refractionTextureUrl Url of the refraction texture to use
  54940. * @param color the base color of the refraction (used to taint the rendering)
  54941. * @param depth simulated refraction depth
  54942. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54943. * @param camera The camera to apply the render pass to.
  54944. * @param options The required width/height ratio to downsize to before computing the render pass.
  54945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54946. * @param engine The engine which the post process will be applied. (default: current engine)
  54947. * @param reusable If the post process can be reused on the same frame. (default: false)
  54948. */
  54949. constructor(name: string, refractionTextureUrl: string,
  54950. /** the base color of the refraction (used to taint the rendering) */
  54951. color: Color3,
  54952. /** simulated refraction depth */
  54953. depth: number,
  54954. /** the coefficient of the base color (0 to remove base color tainting) */
  54955. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54956. /**
  54957. * Disposes of the post process
  54958. * @param camera Camera to dispose post process on
  54959. */
  54960. dispose(camera: Camera): void;
  54961. }
  54962. }
  54963. declare module "babylonjs/Shaders/sharpen.fragment" {
  54964. /** @hidden */
  54965. export var sharpenPixelShader: {
  54966. name: string;
  54967. shader: string;
  54968. };
  54969. }
  54970. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54971. import { Nullable } from "babylonjs/types";
  54972. import { Camera } from "babylonjs/Cameras/camera";
  54973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54974. import "babylonjs/Shaders/sharpen.fragment";
  54975. import { Engine } from "babylonjs/Engines/engine";
  54976. /**
  54977. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54978. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54979. */
  54980. export class SharpenPostProcess extends PostProcess {
  54981. /**
  54982. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54983. */
  54984. colorAmount: number;
  54985. /**
  54986. * How much sharpness should be applied (default: 0.3)
  54987. */
  54988. edgeAmount: number;
  54989. /**
  54990. * Creates a new instance ConvolutionPostProcess
  54991. * @param name The name of the effect.
  54992. * @param options The required width/height ratio to downsize to before computing the render pass.
  54993. * @param camera The camera to apply the render pass to.
  54994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54995. * @param engine The engine which the post process will be applied. (default: current engine)
  54996. * @param reusable If the post process can be reused on the same frame. (default: false)
  54997. * @param textureType Type of textures used when performing the post process. (default: 0)
  54998. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  54999. */
  55000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55001. }
  55002. }
  55003. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55004. import { Nullable } from "babylonjs/types";
  55005. import { Camera } from "babylonjs/Cameras/camera";
  55006. import { Engine } from "babylonjs/Engines/engine";
  55007. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55008. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55009. /**
  55010. * PostProcessRenderPipeline
  55011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55012. */
  55013. export class PostProcessRenderPipeline {
  55014. private engine;
  55015. private _renderEffects;
  55016. private _renderEffectsForIsolatedPass;
  55017. /**
  55018. * List of inspectable custom properties (used by the Inspector)
  55019. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55020. */
  55021. inspectableCustomProperties: IInspectable[];
  55022. /**
  55023. * @hidden
  55024. */
  55025. protected _cameras: Camera[];
  55026. /** @hidden */
  55027. _name: string;
  55028. /**
  55029. * Gets pipeline name
  55030. */
  55031. readonly name: string;
  55032. /**
  55033. * Initializes a PostProcessRenderPipeline
  55034. * @param engine engine to add the pipeline to
  55035. * @param name name of the pipeline
  55036. */
  55037. constructor(engine: Engine, name: string);
  55038. /**
  55039. * Gets the class name
  55040. * @returns "PostProcessRenderPipeline"
  55041. */
  55042. getClassName(): string;
  55043. /**
  55044. * If all the render effects in the pipeline are supported
  55045. */
  55046. readonly isSupported: boolean;
  55047. /**
  55048. * Adds an effect to the pipeline
  55049. * @param renderEffect the effect to add
  55050. */
  55051. addEffect(renderEffect: PostProcessRenderEffect): void;
  55052. /** @hidden */
  55053. _rebuild(): void;
  55054. /** @hidden */
  55055. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55056. /** @hidden */
  55057. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55058. /** @hidden */
  55059. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55060. /** @hidden */
  55061. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55062. /** @hidden */
  55063. _attachCameras(cameras: Camera, unique: boolean): void;
  55064. /** @hidden */
  55065. _attachCameras(cameras: Camera[], unique: boolean): void;
  55066. /** @hidden */
  55067. _detachCameras(cameras: Camera): void;
  55068. /** @hidden */
  55069. _detachCameras(cameras: Nullable<Camera[]>): void;
  55070. /** @hidden */
  55071. _update(): void;
  55072. /** @hidden */
  55073. _reset(): void;
  55074. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55075. /**
  55076. * Disposes of the pipeline
  55077. */
  55078. dispose(): void;
  55079. }
  55080. }
  55081. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55082. import { Camera } from "babylonjs/Cameras/camera";
  55083. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55084. /**
  55085. * PostProcessRenderPipelineManager class
  55086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55087. */
  55088. export class PostProcessRenderPipelineManager {
  55089. private _renderPipelines;
  55090. /**
  55091. * Initializes a PostProcessRenderPipelineManager
  55092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55093. */
  55094. constructor();
  55095. /**
  55096. * Gets the list of supported render pipelines
  55097. */
  55098. readonly supportedPipelines: PostProcessRenderPipeline[];
  55099. /**
  55100. * Adds a pipeline to the manager
  55101. * @param renderPipeline The pipeline to add
  55102. */
  55103. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55104. /**
  55105. * Attaches a camera to the pipeline
  55106. * @param renderPipelineName The name of the pipeline to attach to
  55107. * @param cameras the camera to attach
  55108. * @param unique if the camera can be attached multiple times to the pipeline
  55109. */
  55110. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55111. /**
  55112. * Detaches a camera from the pipeline
  55113. * @param renderPipelineName The name of the pipeline to detach from
  55114. * @param cameras the camera to detach
  55115. */
  55116. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55117. /**
  55118. * Enables an effect by name on a pipeline
  55119. * @param renderPipelineName the name of the pipeline to enable the effect in
  55120. * @param renderEffectName the name of the effect to enable
  55121. * @param cameras the cameras that the effect should be enabled on
  55122. */
  55123. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55124. /**
  55125. * Disables an effect by name on a pipeline
  55126. * @param renderPipelineName the name of the pipeline to disable the effect in
  55127. * @param renderEffectName the name of the effect to disable
  55128. * @param cameras the cameras that the effect should be disabled on
  55129. */
  55130. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55131. /**
  55132. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55133. */
  55134. update(): void;
  55135. /** @hidden */
  55136. _rebuild(): void;
  55137. /**
  55138. * Disposes of the manager and pipelines
  55139. */
  55140. dispose(): void;
  55141. }
  55142. }
  55143. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55144. import { ISceneComponent } from "babylonjs/sceneComponent";
  55145. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55146. import { Scene } from "babylonjs/scene";
  55147. module "babylonjs/scene" {
  55148. interface Scene {
  55149. /** @hidden (Backing field) */
  55150. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55151. /**
  55152. * Gets the postprocess render pipeline manager
  55153. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55154. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55155. */
  55156. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55157. }
  55158. }
  55159. /**
  55160. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55161. */
  55162. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55163. /**
  55164. * The component name helpfull to identify the component in the list of scene components.
  55165. */
  55166. readonly name: string;
  55167. /**
  55168. * The scene the component belongs to.
  55169. */
  55170. scene: Scene;
  55171. /**
  55172. * Creates a new instance of the component for the given scene
  55173. * @param scene Defines the scene to register the component in
  55174. */
  55175. constructor(scene: Scene);
  55176. /**
  55177. * Registers the component in a given scene
  55178. */
  55179. register(): void;
  55180. /**
  55181. * Rebuilds the elements related to this component in case of
  55182. * context lost for instance.
  55183. */
  55184. rebuild(): void;
  55185. /**
  55186. * Disposes the component and the associated ressources
  55187. */
  55188. dispose(): void;
  55189. private _gatherRenderTargets;
  55190. }
  55191. }
  55192. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55193. import { IAnimatable } from "babylonjs/Misc/tools";
  55194. import { Camera } from "babylonjs/Cameras/camera";
  55195. import { IDisposable } from "babylonjs/scene";
  55196. import { Scene } from "babylonjs/scene";
  55197. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55198. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55199. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55200. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55201. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55202. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55203. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55204. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55205. import { Animation } from "babylonjs/Animations/animation";
  55206. /**
  55207. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55208. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55209. */
  55210. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55211. private _scene;
  55212. private _camerasToBeAttached;
  55213. /**
  55214. * ID of the sharpen post process,
  55215. */
  55216. private readonly SharpenPostProcessId;
  55217. /**
  55218. * @ignore
  55219. * ID of the image processing post process;
  55220. */
  55221. readonly ImageProcessingPostProcessId: string;
  55222. /**
  55223. * @ignore
  55224. * ID of the Fast Approximate Anti-Aliasing post process;
  55225. */
  55226. readonly FxaaPostProcessId: string;
  55227. /**
  55228. * ID of the chromatic aberration post process,
  55229. */
  55230. private readonly ChromaticAberrationPostProcessId;
  55231. /**
  55232. * ID of the grain post process
  55233. */
  55234. private readonly GrainPostProcessId;
  55235. /**
  55236. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55237. */
  55238. sharpen: SharpenPostProcess;
  55239. private _sharpenEffect;
  55240. private bloom;
  55241. /**
  55242. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55243. */
  55244. depthOfField: DepthOfFieldEffect;
  55245. /**
  55246. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55247. */
  55248. fxaa: FxaaPostProcess;
  55249. /**
  55250. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55251. */
  55252. imageProcessing: ImageProcessingPostProcess;
  55253. /**
  55254. * Chromatic aberration post process which will shift rgb colors in the image
  55255. */
  55256. chromaticAberration: ChromaticAberrationPostProcess;
  55257. private _chromaticAberrationEffect;
  55258. /**
  55259. * Grain post process which add noise to the image
  55260. */
  55261. grain: GrainPostProcess;
  55262. private _grainEffect;
  55263. /**
  55264. * Glow post process which adds a glow to emissive areas of the image
  55265. */
  55266. private _glowLayer;
  55267. /**
  55268. * Animations which can be used to tweak settings over a period of time
  55269. */
  55270. animations: Animation[];
  55271. private _imageProcessingConfigurationObserver;
  55272. private _sharpenEnabled;
  55273. private _bloomEnabled;
  55274. private _depthOfFieldEnabled;
  55275. private _depthOfFieldBlurLevel;
  55276. private _fxaaEnabled;
  55277. private _imageProcessingEnabled;
  55278. private _defaultPipelineTextureType;
  55279. private _bloomScale;
  55280. private _chromaticAberrationEnabled;
  55281. private _grainEnabled;
  55282. private _buildAllowed;
  55283. /**
  55284. * Gets active scene
  55285. */
  55286. readonly scene: Scene;
  55287. /**
  55288. * Enable or disable the sharpen process from the pipeline
  55289. */
  55290. sharpenEnabled: boolean;
  55291. private _resizeObserver;
  55292. private _hardwareScaleLevel;
  55293. private _bloomKernel;
  55294. /**
  55295. * Specifies the size of the bloom blur kernel, relative to the final output size
  55296. */
  55297. bloomKernel: number;
  55298. /**
  55299. * Specifies the weight of the bloom in the final rendering
  55300. */
  55301. private _bloomWeight;
  55302. /**
  55303. * Specifies the luma threshold for the area that will be blurred by the bloom
  55304. */
  55305. private _bloomThreshold;
  55306. private _hdr;
  55307. /**
  55308. * The strength of the bloom.
  55309. */
  55310. bloomWeight: number;
  55311. /**
  55312. * The strength of the bloom.
  55313. */
  55314. bloomThreshold: number;
  55315. /**
  55316. * The scale of the bloom, lower value will provide better performance.
  55317. */
  55318. bloomScale: number;
  55319. /**
  55320. * Enable or disable the bloom from the pipeline
  55321. */
  55322. bloomEnabled: boolean;
  55323. private _rebuildBloom;
  55324. /**
  55325. * If the depth of field is enabled.
  55326. */
  55327. depthOfFieldEnabled: boolean;
  55328. /**
  55329. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55330. */
  55331. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55332. /**
  55333. * If the anti aliasing is enabled.
  55334. */
  55335. fxaaEnabled: boolean;
  55336. private _samples;
  55337. /**
  55338. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55339. */
  55340. samples: number;
  55341. /**
  55342. * If image processing is enabled.
  55343. */
  55344. imageProcessingEnabled: boolean;
  55345. /**
  55346. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55347. */
  55348. glowLayerEnabled: boolean;
  55349. /**
  55350. * Enable or disable the chromaticAberration process from the pipeline
  55351. */
  55352. chromaticAberrationEnabled: boolean;
  55353. /**
  55354. * Enable or disable the grain process from the pipeline
  55355. */
  55356. grainEnabled: boolean;
  55357. /**
  55358. * @constructor
  55359. * @param name - The rendering pipeline name (default: "")
  55360. * @param hdr - If high dynamic range textures should be used (default: true)
  55361. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55362. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55363. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55364. */
  55365. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55366. /**
  55367. * Get the class name
  55368. * @returns "DefaultRenderingPipeline"
  55369. */
  55370. getClassName(): string;
  55371. /**
  55372. * Force the compilation of the entire pipeline.
  55373. */
  55374. prepare(): void;
  55375. private _hasCleared;
  55376. private _prevPostProcess;
  55377. private _prevPrevPostProcess;
  55378. private _setAutoClearAndTextureSharing;
  55379. private _depthOfFieldSceneObserver;
  55380. private _buildPipeline;
  55381. private _disposePostProcesses;
  55382. /**
  55383. * Adds a camera to the pipeline
  55384. * @param camera the camera to be added
  55385. */
  55386. addCamera(camera: Camera): void;
  55387. /**
  55388. * Removes a camera from the pipeline
  55389. * @param camera the camera to remove
  55390. */
  55391. removeCamera(camera: Camera): void;
  55392. /**
  55393. * Dispose of the pipeline and stop all post processes
  55394. */
  55395. dispose(): void;
  55396. /**
  55397. * Serialize the rendering pipeline (Used when exporting)
  55398. * @returns the serialized object
  55399. */
  55400. serialize(): any;
  55401. /**
  55402. * Parse the serialized pipeline
  55403. * @param source Source pipeline.
  55404. * @param scene The scene to load the pipeline to.
  55405. * @param rootUrl The URL of the serialized pipeline.
  55406. * @returns An instantiated pipeline from the serialized object.
  55407. */
  55408. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55409. }
  55410. }
  55411. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55412. /** @hidden */
  55413. export var lensHighlightsPixelShader: {
  55414. name: string;
  55415. shader: string;
  55416. };
  55417. }
  55418. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55419. /** @hidden */
  55420. export var depthOfFieldPixelShader: {
  55421. name: string;
  55422. shader: string;
  55423. };
  55424. }
  55425. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55426. import { Camera } from "babylonjs/Cameras/camera";
  55427. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55428. import { Scene } from "babylonjs/scene";
  55429. import "babylonjs/Shaders/chromaticAberration.fragment";
  55430. import "babylonjs/Shaders/lensHighlights.fragment";
  55431. import "babylonjs/Shaders/depthOfField.fragment";
  55432. /**
  55433. * BABYLON.JS Chromatic Aberration GLSL Shader
  55434. * Author: Olivier Guyot
  55435. * Separates very slightly R, G and B colors on the edges of the screen
  55436. * Inspired by Francois Tarlier & Martins Upitis
  55437. */
  55438. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55439. /**
  55440. * @ignore
  55441. * The chromatic aberration PostProcess id in the pipeline
  55442. */
  55443. LensChromaticAberrationEffect: string;
  55444. /**
  55445. * @ignore
  55446. * The highlights enhancing PostProcess id in the pipeline
  55447. */
  55448. HighlightsEnhancingEffect: string;
  55449. /**
  55450. * @ignore
  55451. * The depth-of-field PostProcess id in the pipeline
  55452. */
  55453. LensDepthOfFieldEffect: string;
  55454. private _scene;
  55455. private _depthTexture;
  55456. private _grainTexture;
  55457. private _chromaticAberrationPostProcess;
  55458. private _highlightsPostProcess;
  55459. private _depthOfFieldPostProcess;
  55460. private _edgeBlur;
  55461. private _grainAmount;
  55462. private _chromaticAberration;
  55463. private _distortion;
  55464. private _highlightsGain;
  55465. private _highlightsThreshold;
  55466. private _dofDistance;
  55467. private _dofAperture;
  55468. private _dofDarken;
  55469. private _dofPentagon;
  55470. private _blurNoise;
  55471. /**
  55472. * @constructor
  55473. *
  55474. * Effect parameters are as follow:
  55475. * {
  55476. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55477. * edge_blur: number; // from 0 to x (1 for realism)
  55478. * distortion: number; // from 0 to x (1 for realism)
  55479. * grain_amount: number; // from 0 to 1
  55480. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55481. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55482. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55483. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55484. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55485. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55486. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55487. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55488. * }
  55489. * Note: if an effect parameter is unset, effect is disabled
  55490. *
  55491. * @param name The rendering pipeline name
  55492. * @param parameters - An object containing all parameters (see above)
  55493. * @param scene The scene linked to this pipeline
  55494. * @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)
  55495. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55496. */
  55497. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55498. /**
  55499. * Get the class name
  55500. * @returns "LensRenderingPipeline"
  55501. */
  55502. getClassName(): string;
  55503. /**
  55504. * Gets associated scene
  55505. */
  55506. readonly scene: Scene;
  55507. /**
  55508. * Gets or sets the edge blur
  55509. */
  55510. edgeBlur: number;
  55511. /**
  55512. * Gets or sets the grain amount
  55513. */
  55514. grainAmount: number;
  55515. /**
  55516. * Gets or sets the chromatic aberration amount
  55517. */
  55518. chromaticAberration: number;
  55519. /**
  55520. * Gets or sets the depth of field aperture
  55521. */
  55522. dofAperture: number;
  55523. /**
  55524. * Gets or sets the edge distortion
  55525. */
  55526. edgeDistortion: number;
  55527. /**
  55528. * Gets or sets the depth of field distortion
  55529. */
  55530. dofDistortion: number;
  55531. /**
  55532. * Gets or sets the darken out of focus amount
  55533. */
  55534. darkenOutOfFocus: number;
  55535. /**
  55536. * Gets or sets a boolean indicating if blur noise is enabled
  55537. */
  55538. blurNoise: boolean;
  55539. /**
  55540. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55541. */
  55542. pentagonBokeh: boolean;
  55543. /**
  55544. * Gets or sets the highlight grain amount
  55545. */
  55546. highlightsGain: number;
  55547. /**
  55548. * Gets or sets the highlight threshold
  55549. */
  55550. highlightsThreshold: number;
  55551. /**
  55552. * Sets the amount of blur at the edges
  55553. * @param amount blur amount
  55554. */
  55555. setEdgeBlur(amount: number): void;
  55556. /**
  55557. * Sets edge blur to 0
  55558. */
  55559. disableEdgeBlur(): void;
  55560. /**
  55561. * Sets the amout of grain
  55562. * @param amount Amount of grain
  55563. */
  55564. setGrainAmount(amount: number): void;
  55565. /**
  55566. * Set grain amount to 0
  55567. */
  55568. disableGrain(): void;
  55569. /**
  55570. * Sets the chromatic aberration amount
  55571. * @param amount amount of chromatic aberration
  55572. */
  55573. setChromaticAberration(amount: number): void;
  55574. /**
  55575. * Sets chromatic aberration amount to 0
  55576. */
  55577. disableChromaticAberration(): void;
  55578. /**
  55579. * Sets the EdgeDistortion amount
  55580. * @param amount amount of EdgeDistortion
  55581. */
  55582. setEdgeDistortion(amount: number): void;
  55583. /**
  55584. * Sets edge distortion to 0
  55585. */
  55586. disableEdgeDistortion(): void;
  55587. /**
  55588. * Sets the FocusDistance amount
  55589. * @param amount amount of FocusDistance
  55590. */
  55591. setFocusDistance(amount: number): void;
  55592. /**
  55593. * Disables depth of field
  55594. */
  55595. disableDepthOfField(): void;
  55596. /**
  55597. * Sets the Aperture amount
  55598. * @param amount amount of Aperture
  55599. */
  55600. setAperture(amount: number): void;
  55601. /**
  55602. * Sets the DarkenOutOfFocus amount
  55603. * @param amount amount of DarkenOutOfFocus
  55604. */
  55605. setDarkenOutOfFocus(amount: number): void;
  55606. private _pentagonBokehIsEnabled;
  55607. /**
  55608. * Creates a pentagon bokeh effect
  55609. */
  55610. enablePentagonBokeh(): void;
  55611. /**
  55612. * Disables the pentagon bokeh effect
  55613. */
  55614. disablePentagonBokeh(): void;
  55615. /**
  55616. * Enables noise blur
  55617. */
  55618. enableNoiseBlur(): void;
  55619. /**
  55620. * Disables noise blur
  55621. */
  55622. disableNoiseBlur(): void;
  55623. /**
  55624. * Sets the HighlightsGain amount
  55625. * @param amount amount of HighlightsGain
  55626. */
  55627. setHighlightsGain(amount: number): void;
  55628. /**
  55629. * Sets the HighlightsThreshold amount
  55630. * @param amount amount of HighlightsThreshold
  55631. */
  55632. setHighlightsThreshold(amount: number): void;
  55633. /**
  55634. * Disables highlights
  55635. */
  55636. disableHighlights(): void;
  55637. /**
  55638. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55639. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55640. */
  55641. dispose(disableDepthRender?: boolean): void;
  55642. private _createChromaticAberrationPostProcess;
  55643. private _createHighlightsPostProcess;
  55644. private _createDepthOfFieldPostProcess;
  55645. private _createGrainTexture;
  55646. }
  55647. }
  55648. declare module "babylonjs/Shaders/ssao2.fragment" {
  55649. /** @hidden */
  55650. export var ssao2PixelShader: {
  55651. name: string;
  55652. shader: string;
  55653. };
  55654. }
  55655. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55656. /** @hidden */
  55657. export var ssaoCombinePixelShader: {
  55658. name: string;
  55659. shader: string;
  55660. };
  55661. }
  55662. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55663. import { Camera } from "babylonjs/Cameras/camera";
  55664. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55665. import { Scene } from "babylonjs/scene";
  55666. import "babylonjs/Shaders/ssao2.fragment";
  55667. import "babylonjs/Shaders/ssaoCombine.fragment";
  55668. /**
  55669. * Render pipeline to produce ssao effect
  55670. */
  55671. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55672. /**
  55673. * @ignore
  55674. * The PassPostProcess id in the pipeline that contains the original scene color
  55675. */
  55676. SSAOOriginalSceneColorEffect: string;
  55677. /**
  55678. * @ignore
  55679. * The SSAO PostProcess id in the pipeline
  55680. */
  55681. SSAORenderEffect: string;
  55682. /**
  55683. * @ignore
  55684. * The horizontal blur PostProcess id in the pipeline
  55685. */
  55686. SSAOBlurHRenderEffect: string;
  55687. /**
  55688. * @ignore
  55689. * The vertical blur PostProcess id in the pipeline
  55690. */
  55691. SSAOBlurVRenderEffect: string;
  55692. /**
  55693. * @ignore
  55694. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55695. */
  55696. SSAOCombineRenderEffect: string;
  55697. /**
  55698. * The output strength of the SSAO post-process. Default value is 1.0.
  55699. */
  55700. totalStrength: number;
  55701. /**
  55702. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55703. */
  55704. maxZ: number;
  55705. /**
  55706. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55707. */
  55708. minZAspect: number;
  55709. private _samples;
  55710. /**
  55711. * Number of samples used for the SSAO calculations. Default value is 8
  55712. */
  55713. samples: number;
  55714. private _textureSamples;
  55715. /**
  55716. * Number of samples to use for antialiasing
  55717. */
  55718. textureSamples: number;
  55719. /**
  55720. * Ratio object used for SSAO ratio and blur ratio
  55721. */
  55722. private _ratio;
  55723. /**
  55724. * Dynamically generated sphere sampler.
  55725. */
  55726. private _sampleSphere;
  55727. /**
  55728. * Blur filter offsets
  55729. */
  55730. private _samplerOffsets;
  55731. private _expensiveBlur;
  55732. /**
  55733. * If bilateral blur should be used
  55734. */
  55735. expensiveBlur: boolean;
  55736. /**
  55737. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55738. */
  55739. radius: number;
  55740. /**
  55741. * The base color of the SSAO post-process
  55742. * The final result is "base + ssao" between [0, 1]
  55743. */
  55744. base: number;
  55745. /**
  55746. * Support test.
  55747. */
  55748. static readonly IsSupported: boolean;
  55749. private _scene;
  55750. private _depthTexture;
  55751. private _normalTexture;
  55752. private _randomTexture;
  55753. private _originalColorPostProcess;
  55754. private _ssaoPostProcess;
  55755. private _blurHPostProcess;
  55756. private _blurVPostProcess;
  55757. private _ssaoCombinePostProcess;
  55758. private _firstUpdate;
  55759. /**
  55760. * Gets active scene
  55761. */
  55762. readonly scene: Scene;
  55763. /**
  55764. * @constructor
  55765. * @param name The rendering pipeline name
  55766. * @param scene The scene linked to this pipeline
  55767. * @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 }
  55768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55769. */
  55770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55771. /**
  55772. * Get the class name
  55773. * @returns "SSAO2RenderingPipeline"
  55774. */
  55775. getClassName(): string;
  55776. /**
  55777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55778. */
  55779. dispose(disableGeometryBufferRenderer?: boolean): void;
  55780. private _createBlurPostProcess;
  55781. /** @hidden */
  55782. _rebuild(): void;
  55783. private _bits;
  55784. private _radicalInverse_VdC;
  55785. private _hammersley;
  55786. private _hemisphereSample_uniform;
  55787. private _generateHemisphere;
  55788. private _createSSAOPostProcess;
  55789. private _createSSAOCombinePostProcess;
  55790. private _createRandomTexture;
  55791. /**
  55792. * Serialize the rendering pipeline (Used when exporting)
  55793. * @returns the serialized object
  55794. */
  55795. serialize(): any;
  55796. /**
  55797. * Parse the serialized pipeline
  55798. * @param source Source pipeline.
  55799. * @param scene The scene to load the pipeline to.
  55800. * @param rootUrl The URL of the serialized pipeline.
  55801. * @returns An instantiated pipeline from the serialized object.
  55802. */
  55803. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55804. }
  55805. }
  55806. declare module "babylonjs/Shaders/ssao.fragment" {
  55807. /** @hidden */
  55808. export var ssaoPixelShader: {
  55809. name: string;
  55810. shader: string;
  55811. };
  55812. }
  55813. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55814. import { Camera } from "babylonjs/Cameras/camera";
  55815. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55816. import { Scene } from "babylonjs/scene";
  55817. import "babylonjs/Shaders/ssao.fragment";
  55818. import "babylonjs/Shaders/ssaoCombine.fragment";
  55819. /**
  55820. * Render pipeline to produce ssao effect
  55821. */
  55822. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55823. /**
  55824. * @ignore
  55825. * The PassPostProcess id in the pipeline that contains the original scene color
  55826. */
  55827. SSAOOriginalSceneColorEffect: string;
  55828. /**
  55829. * @ignore
  55830. * The SSAO PostProcess id in the pipeline
  55831. */
  55832. SSAORenderEffect: string;
  55833. /**
  55834. * @ignore
  55835. * The horizontal blur PostProcess id in the pipeline
  55836. */
  55837. SSAOBlurHRenderEffect: string;
  55838. /**
  55839. * @ignore
  55840. * The vertical blur PostProcess id in the pipeline
  55841. */
  55842. SSAOBlurVRenderEffect: string;
  55843. /**
  55844. * @ignore
  55845. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55846. */
  55847. SSAOCombineRenderEffect: string;
  55848. /**
  55849. * The output strength of the SSAO post-process. Default value is 1.0.
  55850. */
  55851. totalStrength: number;
  55852. /**
  55853. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55854. */
  55855. radius: number;
  55856. /**
  55857. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55858. * Must not be equal to fallOff and superior to fallOff.
  55859. * Default value is 0.0075
  55860. */
  55861. area: number;
  55862. /**
  55863. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55864. * Must not be equal to area and inferior to area.
  55865. * Default value is 0.000001
  55866. */
  55867. fallOff: number;
  55868. /**
  55869. * The base color of the SSAO post-process
  55870. * The final result is "base + ssao" between [0, 1]
  55871. */
  55872. base: number;
  55873. private _scene;
  55874. private _depthTexture;
  55875. private _randomTexture;
  55876. private _originalColorPostProcess;
  55877. private _ssaoPostProcess;
  55878. private _blurHPostProcess;
  55879. private _blurVPostProcess;
  55880. private _ssaoCombinePostProcess;
  55881. private _firstUpdate;
  55882. /**
  55883. * Gets active scene
  55884. */
  55885. readonly scene: Scene;
  55886. /**
  55887. * @constructor
  55888. * @param name - The rendering pipeline name
  55889. * @param scene - The scene linked to this pipeline
  55890. * @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 }
  55891. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55892. */
  55893. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55894. /**
  55895. * Get the class name
  55896. * @returns "SSAORenderingPipeline"
  55897. */
  55898. getClassName(): string;
  55899. /**
  55900. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55901. */
  55902. dispose(disableDepthRender?: boolean): void;
  55903. private _createBlurPostProcess;
  55904. /** @hidden */
  55905. _rebuild(): void;
  55906. private _createSSAOPostProcess;
  55907. private _createSSAOCombinePostProcess;
  55908. private _createRandomTexture;
  55909. }
  55910. }
  55911. declare module "babylonjs/Shaders/standard.fragment" {
  55912. /** @hidden */
  55913. export var standardPixelShader: {
  55914. name: string;
  55915. shader: string;
  55916. };
  55917. }
  55918. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55919. import { Nullable } from "babylonjs/types";
  55920. import { IAnimatable } from "babylonjs/Misc/tools";
  55921. import { Camera } from "babylonjs/Cameras/camera";
  55922. import { Texture } from "babylonjs/Materials/Textures/texture";
  55923. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55924. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55925. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55926. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55927. import { IDisposable } from "babylonjs/scene";
  55928. import { SpotLight } from "babylonjs/Lights/spotLight";
  55929. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55930. import { Scene } from "babylonjs/scene";
  55931. import { Animation } from "babylonjs/Animations/animation";
  55932. import "babylonjs/Shaders/standard.fragment";
  55933. /**
  55934. * Standard rendering pipeline
  55935. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55936. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55937. */
  55938. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55939. /**
  55940. * Public members
  55941. */
  55942. /**
  55943. * Post-process which contains the original scene color before the pipeline applies all the effects
  55944. */
  55945. originalPostProcess: Nullable<PostProcess>;
  55946. /**
  55947. * Post-process used to down scale an image x4
  55948. */
  55949. downSampleX4PostProcess: Nullable<PostProcess>;
  55950. /**
  55951. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55952. */
  55953. brightPassPostProcess: Nullable<PostProcess>;
  55954. /**
  55955. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55956. */
  55957. blurHPostProcesses: PostProcess[];
  55958. /**
  55959. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55960. */
  55961. blurVPostProcesses: PostProcess[];
  55962. /**
  55963. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55964. */
  55965. textureAdderPostProcess: Nullable<PostProcess>;
  55966. /**
  55967. * Post-process used to create volumetric lighting effect
  55968. */
  55969. volumetricLightPostProcess: Nullable<PostProcess>;
  55970. /**
  55971. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55972. */
  55973. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55974. /**
  55975. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55976. */
  55977. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55978. /**
  55979. * Post-process used to merge the volumetric light effect and the real scene color
  55980. */
  55981. volumetricLightMergePostProces: Nullable<PostProcess>;
  55982. /**
  55983. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55984. */
  55985. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55986. /**
  55987. * Base post-process used to calculate the average luminance of the final image for HDR
  55988. */
  55989. luminancePostProcess: Nullable<PostProcess>;
  55990. /**
  55991. * Post-processes used to create down sample post-processes in order to get
  55992. * the average luminance of the final image for HDR
  55993. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55994. */
  55995. luminanceDownSamplePostProcesses: PostProcess[];
  55996. /**
  55997. * Post-process used to create a HDR effect (light adaptation)
  55998. */
  55999. hdrPostProcess: Nullable<PostProcess>;
  56000. /**
  56001. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56002. */
  56003. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56004. /**
  56005. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56006. */
  56007. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56008. /**
  56009. * Post-process used to merge the final HDR post-process and the real scene color
  56010. */
  56011. hdrFinalPostProcess: Nullable<PostProcess>;
  56012. /**
  56013. * Post-process used to create a lens flare effect
  56014. */
  56015. lensFlarePostProcess: Nullable<PostProcess>;
  56016. /**
  56017. * Post-process that merges the result of the lens flare post-process and the real scene color
  56018. */
  56019. lensFlareComposePostProcess: Nullable<PostProcess>;
  56020. /**
  56021. * Post-process used to create a motion blur effect
  56022. */
  56023. motionBlurPostProcess: Nullable<PostProcess>;
  56024. /**
  56025. * Post-process used to create a depth of field effect
  56026. */
  56027. depthOfFieldPostProcess: Nullable<PostProcess>;
  56028. /**
  56029. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56030. */
  56031. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56032. /**
  56033. * Represents the brightness threshold in order to configure the illuminated surfaces
  56034. */
  56035. brightThreshold: number;
  56036. /**
  56037. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56038. */
  56039. blurWidth: number;
  56040. /**
  56041. * Sets if the blur for highlighted surfaces must be only horizontal
  56042. */
  56043. horizontalBlur: boolean;
  56044. /**
  56045. * Gets the overall exposure used by the pipeline
  56046. */
  56047. /**
  56048. * Sets the overall exposure used by the pipeline
  56049. */
  56050. exposure: number;
  56051. /**
  56052. * Texture used typically to simulate "dirty" on camera lens
  56053. */
  56054. lensTexture: Nullable<Texture>;
  56055. /**
  56056. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56057. */
  56058. volumetricLightCoefficient: number;
  56059. /**
  56060. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56061. */
  56062. volumetricLightPower: number;
  56063. /**
  56064. * Used the set the blur intensity to smooth the volumetric lights
  56065. */
  56066. volumetricLightBlurScale: number;
  56067. /**
  56068. * Light (spot or directional) used to generate the volumetric lights rays
  56069. * The source light must have a shadow generate so the pipeline can get its
  56070. * depth map
  56071. */
  56072. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56073. /**
  56074. * For eye adaptation, represents the minimum luminance the eye can see
  56075. */
  56076. hdrMinimumLuminance: number;
  56077. /**
  56078. * For eye adaptation, represents the decrease luminance speed
  56079. */
  56080. hdrDecreaseRate: number;
  56081. /**
  56082. * For eye adaptation, represents the increase luminance speed
  56083. */
  56084. hdrIncreaseRate: number;
  56085. /**
  56086. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56087. */
  56088. /**
  56089. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56090. */
  56091. hdrAutoExposure: boolean;
  56092. /**
  56093. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56094. */
  56095. lensColorTexture: Nullable<Texture>;
  56096. /**
  56097. * The overall strengh for the lens flare effect
  56098. */
  56099. lensFlareStrength: number;
  56100. /**
  56101. * Dispersion coefficient for lens flare ghosts
  56102. */
  56103. lensFlareGhostDispersal: number;
  56104. /**
  56105. * Main lens flare halo width
  56106. */
  56107. lensFlareHaloWidth: number;
  56108. /**
  56109. * Based on the lens distortion effect, defines how much the lens flare result
  56110. * is distorted
  56111. */
  56112. lensFlareDistortionStrength: number;
  56113. /**
  56114. * Lens star texture must be used to simulate rays on the flares and is available
  56115. * in the documentation
  56116. */
  56117. lensStarTexture: Nullable<Texture>;
  56118. /**
  56119. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56120. * flare effect by taking account of the dirt texture
  56121. */
  56122. lensFlareDirtTexture: Nullable<Texture>;
  56123. /**
  56124. * Represents the focal length for the depth of field effect
  56125. */
  56126. depthOfFieldDistance: number;
  56127. /**
  56128. * Represents the blur intensity for the blurred part of the depth of field effect
  56129. */
  56130. depthOfFieldBlurWidth: number;
  56131. /**
  56132. * For motion blur, defines how much the image is blurred by the movement
  56133. */
  56134. motionStrength: number;
  56135. /**
  56136. * List of animations for the pipeline (IAnimatable implementation)
  56137. */
  56138. animations: Animation[];
  56139. /**
  56140. * Private members
  56141. */
  56142. private _scene;
  56143. private _currentDepthOfFieldSource;
  56144. private _basePostProcess;
  56145. private _fixedExposure;
  56146. private _currentExposure;
  56147. private _hdrAutoExposure;
  56148. private _hdrCurrentLuminance;
  56149. private _floatTextureType;
  56150. private _ratio;
  56151. private _bloomEnabled;
  56152. private _depthOfFieldEnabled;
  56153. private _vlsEnabled;
  56154. private _lensFlareEnabled;
  56155. private _hdrEnabled;
  56156. private _motionBlurEnabled;
  56157. private _fxaaEnabled;
  56158. private _motionBlurSamples;
  56159. private _volumetricLightStepsCount;
  56160. private _samples;
  56161. /**
  56162. * @ignore
  56163. * Specifies if the bloom pipeline is enabled
  56164. */
  56165. BloomEnabled: boolean;
  56166. /**
  56167. * @ignore
  56168. * Specifies if the depth of field pipeline is enabed
  56169. */
  56170. DepthOfFieldEnabled: boolean;
  56171. /**
  56172. * @ignore
  56173. * Specifies if the lens flare pipeline is enabed
  56174. */
  56175. LensFlareEnabled: boolean;
  56176. /**
  56177. * @ignore
  56178. * Specifies if the HDR pipeline is enabled
  56179. */
  56180. HDREnabled: boolean;
  56181. /**
  56182. * @ignore
  56183. * Specifies if the volumetric lights scattering effect is enabled
  56184. */
  56185. VLSEnabled: boolean;
  56186. /**
  56187. * @ignore
  56188. * Specifies if the motion blur effect is enabled
  56189. */
  56190. MotionBlurEnabled: boolean;
  56191. /**
  56192. * Specifies if anti-aliasing is enabled
  56193. */
  56194. fxaaEnabled: boolean;
  56195. /**
  56196. * Specifies the number of steps used to calculate the volumetric lights
  56197. * Typically in interval [50, 200]
  56198. */
  56199. volumetricLightStepsCount: number;
  56200. /**
  56201. * Specifies the number of samples used for the motion blur effect
  56202. * Typically in interval [16, 64]
  56203. */
  56204. motionBlurSamples: number;
  56205. /**
  56206. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56207. */
  56208. samples: number;
  56209. /**
  56210. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56211. * @constructor
  56212. * @param name The rendering pipeline name
  56213. * @param scene The scene linked to this pipeline
  56214. * @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)
  56215. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56216. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56217. */
  56218. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56219. private _buildPipeline;
  56220. private _createDownSampleX4PostProcess;
  56221. private _createBrightPassPostProcess;
  56222. private _createBlurPostProcesses;
  56223. private _createTextureAdderPostProcess;
  56224. private _createVolumetricLightPostProcess;
  56225. private _createLuminancePostProcesses;
  56226. private _createHdrPostProcess;
  56227. private _createLensFlarePostProcess;
  56228. private _createDepthOfFieldPostProcess;
  56229. private _createMotionBlurPostProcess;
  56230. private _getDepthTexture;
  56231. private _disposePostProcesses;
  56232. /**
  56233. * Dispose of the pipeline and stop all post processes
  56234. */
  56235. dispose(): void;
  56236. /**
  56237. * Serialize the rendering pipeline (Used when exporting)
  56238. * @returns the serialized object
  56239. */
  56240. serialize(): any;
  56241. /**
  56242. * Parse the serialized pipeline
  56243. * @param source Source pipeline.
  56244. * @param scene The scene to load the pipeline to.
  56245. * @param rootUrl The URL of the serialized pipeline.
  56246. * @returns An instantiated pipeline from the serialized object.
  56247. */
  56248. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56249. /**
  56250. * Luminance steps
  56251. */
  56252. static LuminanceSteps: number;
  56253. }
  56254. }
  56255. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56256. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56257. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56258. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56259. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56260. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56261. }
  56262. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56263. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56264. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56265. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56266. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56267. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56268. }
  56269. declare module "babylonjs/Shaders/tonemap.fragment" {
  56270. /** @hidden */
  56271. export var tonemapPixelShader: {
  56272. name: string;
  56273. shader: string;
  56274. };
  56275. }
  56276. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56277. import { Camera } from "babylonjs/Cameras/camera";
  56278. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56279. import "babylonjs/Shaders/tonemap.fragment";
  56280. import { Engine } from "babylonjs/Engines/engine";
  56281. /** Defines operator used for tonemapping */
  56282. export enum TonemappingOperator {
  56283. /** Hable */
  56284. Hable = 0,
  56285. /** Reinhard */
  56286. Reinhard = 1,
  56287. /** HejiDawson */
  56288. HejiDawson = 2,
  56289. /** Photographic */
  56290. Photographic = 3
  56291. }
  56292. /**
  56293. * Defines a post process to apply tone mapping
  56294. */
  56295. export class TonemapPostProcess extends PostProcess {
  56296. private _operator;
  56297. /** Defines the required exposure adjustement */
  56298. exposureAdjustment: number;
  56299. /**
  56300. * Creates a new TonemapPostProcess
  56301. * @param name defines the name of the postprocess
  56302. * @param _operator defines the operator to use
  56303. * @param exposureAdjustment defines the required exposure adjustement
  56304. * @param camera defines the camera to use (can be null)
  56305. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56306. * @param engine defines the hosting engine (can be ignore if camera is set)
  56307. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56308. */
  56309. constructor(name: string, _operator: TonemappingOperator,
  56310. /** Defines the required exposure adjustement */
  56311. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56312. }
  56313. }
  56314. declare module "babylonjs/Shaders/depth.vertex" {
  56315. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56316. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56317. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56318. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56319. /** @hidden */
  56320. export var depthVertexShader: {
  56321. name: string;
  56322. shader: string;
  56323. };
  56324. }
  56325. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56326. /** @hidden */
  56327. export var volumetricLightScatteringPixelShader: {
  56328. name: string;
  56329. shader: string;
  56330. };
  56331. }
  56332. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56333. /** @hidden */
  56334. export var volumetricLightScatteringPassPixelShader: {
  56335. name: string;
  56336. shader: string;
  56337. };
  56338. }
  56339. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56340. import { Vector3 } from "babylonjs/Maths/math";
  56341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56342. import { Mesh } from "babylonjs/Meshes/mesh";
  56343. import { Camera } from "babylonjs/Cameras/camera";
  56344. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56345. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56346. import { Scene } from "babylonjs/scene";
  56347. import "babylonjs/Meshes/Builders/planeBuilder";
  56348. import "babylonjs/Shaders/depth.vertex";
  56349. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56350. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56351. import { Engine } from "babylonjs/Engines/engine";
  56352. /**
  56353. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56354. */
  56355. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56356. private _volumetricLightScatteringPass;
  56357. private _volumetricLightScatteringRTT;
  56358. private _viewPort;
  56359. private _screenCoordinates;
  56360. private _cachedDefines;
  56361. /**
  56362. * If not undefined, the mesh position is computed from the attached node position
  56363. */
  56364. attachedNode: {
  56365. position: Vector3;
  56366. };
  56367. /**
  56368. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56369. */
  56370. customMeshPosition: Vector3;
  56371. /**
  56372. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56373. */
  56374. useCustomMeshPosition: boolean;
  56375. /**
  56376. * If the post-process should inverse the light scattering direction
  56377. */
  56378. invert: boolean;
  56379. /**
  56380. * The internal mesh used by the post-process
  56381. */
  56382. mesh: Mesh;
  56383. /**
  56384. * @hidden
  56385. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56386. */
  56387. useDiffuseColor: boolean;
  56388. /**
  56389. * Array containing the excluded meshes not rendered in the internal pass
  56390. */
  56391. excludedMeshes: AbstractMesh[];
  56392. /**
  56393. * Controls the overall intensity of the post-process
  56394. */
  56395. exposure: number;
  56396. /**
  56397. * Dissipates each sample's contribution in range [0, 1]
  56398. */
  56399. decay: number;
  56400. /**
  56401. * Controls the overall intensity of each sample
  56402. */
  56403. weight: number;
  56404. /**
  56405. * Controls the density of each sample
  56406. */
  56407. density: number;
  56408. /**
  56409. * @constructor
  56410. * @param name The post-process name
  56411. * @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)
  56412. * @param camera The camera that the post-process will be attached to
  56413. * @param mesh The mesh used to create the light scattering
  56414. * @param samples The post-process quality, default 100
  56415. * @param samplingModeThe post-process filtering mode
  56416. * @param engine The babylon engine
  56417. * @param reusable If the post-process is reusable
  56418. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56419. */
  56420. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56421. /**
  56422. * Returns the string "VolumetricLightScatteringPostProcess"
  56423. * @returns "VolumetricLightScatteringPostProcess"
  56424. */
  56425. getClassName(): string;
  56426. private _isReady;
  56427. /**
  56428. * Sets the new light position for light scattering effect
  56429. * @param position The new custom light position
  56430. */
  56431. setCustomMeshPosition(position: Vector3): void;
  56432. /**
  56433. * Returns the light position for light scattering effect
  56434. * @return Vector3 The custom light position
  56435. */
  56436. getCustomMeshPosition(): Vector3;
  56437. /**
  56438. * Disposes the internal assets and detaches the post-process from the camera
  56439. */
  56440. dispose(camera: Camera): void;
  56441. /**
  56442. * Returns the render target texture used by the post-process
  56443. * @return the render target texture used by the post-process
  56444. */
  56445. getPass(): RenderTargetTexture;
  56446. private _meshExcluded;
  56447. private _createPass;
  56448. private _updateMeshScreenCoordinates;
  56449. /**
  56450. * Creates a default mesh for the Volumeric Light Scattering post-process
  56451. * @param name The mesh name
  56452. * @param scene The scene where to create the mesh
  56453. * @return the default mesh
  56454. */
  56455. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56456. }
  56457. }
  56458. declare module "babylonjs/PostProcesses/index" {
  56459. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56460. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56461. export * from "babylonjs/PostProcesses/bloomEffect";
  56462. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56463. export * from "babylonjs/PostProcesses/blurPostProcess";
  56464. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56465. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56466. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56467. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56468. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56469. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56470. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56471. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56472. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56473. export * from "babylonjs/PostProcesses/filterPostProcess";
  56474. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56475. export * from "babylonjs/PostProcesses/grainPostProcess";
  56476. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56477. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56478. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56479. export * from "babylonjs/PostProcesses/passPostProcess";
  56480. export * from "babylonjs/PostProcesses/postProcess";
  56481. export * from "babylonjs/PostProcesses/postProcessManager";
  56482. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56483. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56484. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56485. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56486. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56487. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56488. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56489. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56490. }
  56491. declare module "babylonjs/Probes/index" {
  56492. export * from "babylonjs/Probes/reflectionProbe";
  56493. }
  56494. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56495. import { Scene } from "babylonjs/scene";
  56496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56497. import { Color3 } from "babylonjs/Maths/math";
  56498. import { SmartArray } from "babylonjs/Misc/smartArray";
  56499. import { ISceneComponent } from "babylonjs/sceneComponent";
  56500. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56501. import "babylonjs/Meshes/Builders/boxBuilder";
  56502. import "babylonjs/Shaders/color.fragment";
  56503. import "babylonjs/Shaders/color.vertex";
  56504. module "babylonjs/scene" {
  56505. interface Scene {
  56506. /** @hidden (Backing field) */
  56507. _boundingBoxRenderer: BoundingBoxRenderer;
  56508. /** @hidden (Backing field) */
  56509. _forceShowBoundingBoxes: boolean;
  56510. /**
  56511. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56512. */
  56513. forceShowBoundingBoxes: boolean;
  56514. /**
  56515. * Gets the bounding box renderer associated with the scene
  56516. * @returns a BoundingBoxRenderer
  56517. */
  56518. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56519. }
  56520. }
  56521. module "babylonjs/Meshes/abstractMesh" {
  56522. interface AbstractMesh {
  56523. /** @hidden (Backing field) */
  56524. _showBoundingBox: boolean;
  56525. /**
  56526. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56527. */
  56528. showBoundingBox: boolean;
  56529. }
  56530. }
  56531. /**
  56532. * Component responsible of rendering the bounding box of the meshes in a scene.
  56533. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56534. */
  56535. export class BoundingBoxRenderer implements ISceneComponent {
  56536. /**
  56537. * The component name helpfull to identify the component in the list of scene components.
  56538. */
  56539. readonly name: string;
  56540. /**
  56541. * The scene the component belongs to.
  56542. */
  56543. scene: Scene;
  56544. /**
  56545. * Color of the bounding box lines placed in front of an object
  56546. */
  56547. frontColor: Color3;
  56548. /**
  56549. * Color of the bounding box lines placed behind an object
  56550. */
  56551. backColor: Color3;
  56552. /**
  56553. * Defines if the renderer should show the back lines or not
  56554. */
  56555. showBackLines: boolean;
  56556. /**
  56557. * @hidden
  56558. */
  56559. renderList: SmartArray<BoundingBox>;
  56560. private _colorShader;
  56561. private _vertexBuffers;
  56562. private _indexBuffer;
  56563. /**
  56564. * Instantiates a new bounding box renderer in a scene.
  56565. * @param scene the scene the renderer renders in
  56566. */
  56567. constructor(scene: Scene);
  56568. /**
  56569. * Registers the component in a given scene
  56570. */
  56571. register(): void;
  56572. private _evaluateSubMesh;
  56573. private _activeMesh;
  56574. private _prepareRessources;
  56575. private _createIndexBuffer;
  56576. /**
  56577. * Rebuilds the elements related to this component in case of
  56578. * context lost for instance.
  56579. */
  56580. rebuild(): void;
  56581. /**
  56582. * @hidden
  56583. */
  56584. reset(): void;
  56585. /**
  56586. * Render the bounding boxes of a specific rendering group
  56587. * @param renderingGroupId defines the rendering group to render
  56588. */
  56589. render(renderingGroupId: number): void;
  56590. /**
  56591. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56592. * @param mesh Define the mesh to render the occlusion bounding box for
  56593. */
  56594. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56595. /**
  56596. * Dispose and release the resources attached to this renderer.
  56597. */
  56598. dispose(): void;
  56599. }
  56600. }
  56601. declare module "babylonjs/Shaders/depth.fragment" {
  56602. /** @hidden */
  56603. export var depthPixelShader: {
  56604. name: string;
  56605. shader: string;
  56606. };
  56607. }
  56608. declare module "babylonjs/Rendering/depthRenderer" {
  56609. import { Nullable } from "babylonjs/types";
  56610. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56611. import { Scene } from "babylonjs/scene";
  56612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56613. import { Camera } from "babylonjs/Cameras/camera";
  56614. import "babylonjs/Shaders/depth.fragment";
  56615. import "babylonjs/Shaders/depth.vertex";
  56616. /**
  56617. * This represents a depth renderer in Babylon.
  56618. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56619. */
  56620. export class DepthRenderer {
  56621. private _scene;
  56622. private _depthMap;
  56623. private _effect;
  56624. private _cachedDefines;
  56625. private _camera;
  56626. /**
  56627. * Specifiess that the depth renderer will only be used within
  56628. * the camera it is created for.
  56629. * This can help forcing its rendering during the camera processing.
  56630. */
  56631. useOnlyInActiveCamera: boolean;
  56632. /** @hidden */
  56633. static _SceneComponentInitialization: (scene: Scene) => void;
  56634. /**
  56635. * Instantiates a depth renderer
  56636. * @param scene The scene the renderer belongs to
  56637. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56638. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56639. */
  56640. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56641. /**
  56642. * Creates the depth rendering effect and checks if the effect is ready.
  56643. * @param subMesh The submesh to be used to render the depth map of
  56644. * @param useInstances If multiple world instances should be used
  56645. * @returns if the depth renderer is ready to render the depth map
  56646. */
  56647. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56648. /**
  56649. * Gets the texture which the depth map will be written to.
  56650. * @returns The depth map texture
  56651. */
  56652. getDepthMap(): RenderTargetTexture;
  56653. /**
  56654. * Disposes of the depth renderer.
  56655. */
  56656. dispose(): void;
  56657. }
  56658. }
  56659. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56660. import { Nullable } from "babylonjs/types";
  56661. import { Scene } from "babylonjs/scene";
  56662. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56663. import { Camera } from "babylonjs/Cameras/camera";
  56664. import { ISceneComponent } from "babylonjs/sceneComponent";
  56665. module "babylonjs/scene" {
  56666. interface Scene {
  56667. /** @hidden (Backing field) */
  56668. _depthRenderer: {
  56669. [id: string]: DepthRenderer;
  56670. };
  56671. /**
  56672. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56673. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56674. * @returns the created depth renderer
  56675. */
  56676. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56677. /**
  56678. * Disables a depth renderer for a given camera
  56679. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56680. */
  56681. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56682. }
  56683. }
  56684. /**
  56685. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56686. * in several rendering techniques.
  56687. */
  56688. export class DepthRendererSceneComponent implements ISceneComponent {
  56689. /**
  56690. * The component name helpfull to identify the component in the list of scene components.
  56691. */
  56692. readonly name: string;
  56693. /**
  56694. * The scene the component belongs to.
  56695. */
  56696. scene: Scene;
  56697. /**
  56698. * Creates a new instance of the component for the given scene
  56699. * @param scene Defines the scene to register the component in
  56700. */
  56701. constructor(scene: Scene);
  56702. /**
  56703. * Registers the component in a given scene
  56704. */
  56705. register(): void;
  56706. /**
  56707. * Rebuilds the elements related to this component in case of
  56708. * context lost for instance.
  56709. */
  56710. rebuild(): void;
  56711. /**
  56712. * Disposes the component and the associated ressources
  56713. */
  56714. dispose(): void;
  56715. private _gatherRenderTargets;
  56716. private _gatherActiveCameraRenderTargets;
  56717. }
  56718. }
  56719. declare module "babylonjs/Shaders/outline.fragment" {
  56720. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56721. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56722. /** @hidden */
  56723. export var outlinePixelShader: {
  56724. name: string;
  56725. shader: string;
  56726. };
  56727. }
  56728. declare module "babylonjs/Shaders/outline.vertex" {
  56729. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56730. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56731. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56732. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56733. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56734. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56735. /** @hidden */
  56736. export var outlineVertexShader: {
  56737. name: string;
  56738. shader: string;
  56739. };
  56740. }
  56741. declare module "babylonjs/Rendering/outlineRenderer" {
  56742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56743. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56744. import { Scene } from "babylonjs/scene";
  56745. import { ISceneComponent } from "babylonjs/sceneComponent";
  56746. import "babylonjs/Shaders/outline.fragment";
  56747. import "babylonjs/Shaders/outline.vertex";
  56748. module "babylonjs/scene" {
  56749. interface Scene {
  56750. /** @hidden */
  56751. _outlineRenderer: OutlineRenderer;
  56752. /**
  56753. * Gets the outline renderer associated with the scene
  56754. * @returns a OutlineRenderer
  56755. */
  56756. getOutlineRenderer(): OutlineRenderer;
  56757. }
  56758. }
  56759. module "babylonjs/Meshes/abstractMesh" {
  56760. interface AbstractMesh {
  56761. /** @hidden (Backing field) */
  56762. _renderOutline: boolean;
  56763. /**
  56764. * Gets or sets a boolean indicating if the outline must be rendered as well
  56765. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56766. */
  56767. renderOutline: boolean;
  56768. /** @hidden (Backing field) */
  56769. _renderOverlay: boolean;
  56770. /**
  56771. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56772. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56773. */
  56774. renderOverlay: boolean;
  56775. }
  56776. }
  56777. /**
  56778. * This class is responsible to draw bothe outline/overlay of meshes.
  56779. * It should not be used directly but through the available method on mesh.
  56780. */
  56781. export class OutlineRenderer implements ISceneComponent {
  56782. /**
  56783. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56784. */
  56785. private static _StencilReference;
  56786. /**
  56787. * The name of the component. Each component must have a unique name.
  56788. */
  56789. name: string;
  56790. /**
  56791. * The scene the component belongs to.
  56792. */
  56793. scene: Scene;
  56794. /**
  56795. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56796. */
  56797. zOffset: number;
  56798. private _engine;
  56799. private _effect;
  56800. private _cachedDefines;
  56801. private _savedDepthWrite;
  56802. /**
  56803. * Instantiates a new outline renderer. (There could be only one per scene).
  56804. * @param scene Defines the scene it belongs to
  56805. */
  56806. constructor(scene: Scene);
  56807. /**
  56808. * Register the component to one instance of a scene.
  56809. */
  56810. register(): void;
  56811. /**
  56812. * Rebuilds the elements related to this component in case of
  56813. * context lost for instance.
  56814. */
  56815. rebuild(): void;
  56816. /**
  56817. * Disposes the component and the associated ressources.
  56818. */
  56819. dispose(): void;
  56820. /**
  56821. * Renders the outline in the canvas.
  56822. * @param subMesh Defines the sumesh to render
  56823. * @param batch Defines the batch of meshes in case of instances
  56824. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56825. */
  56826. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56827. /**
  56828. * Returns whether or not the outline renderer is ready for a given submesh.
  56829. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56830. * @param subMesh Defines the submesh to check readyness for
  56831. * @param useInstances Defines wheter wee are trying to render instances or not
  56832. * @returns true if ready otherwise false
  56833. */
  56834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56835. private _beforeRenderingMesh;
  56836. private _afterRenderingMesh;
  56837. }
  56838. }
  56839. declare module "babylonjs/Rendering/index" {
  56840. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56841. export * from "babylonjs/Rendering/depthRenderer";
  56842. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56843. export * from "babylonjs/Rendering/edgesRenderer";
  56844. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56845. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56846. export * from "babylonjs/Rendering/outlineRenderer";
  56847. export * from "babylonjs/Rendering/renderingGroup";
  56848. export * from "babylonjs/Rendering/renderingManager";
  56849. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56850. }
  56851. declare module "babylonjs/Sprites/index" {
  56852. export * from "babylonjs/Sprites/sprite";
  56853. export * from "babylonjs/Sprites/spriteManager";
  56854. export * from "babylonjs/Sprites/spriteSceneComponent";
  56855. }
  56856. declare module "babylonjs/Misc/assetsManager" {
  56857. import { Scene } from "babylonjs/scene";
  56858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56859. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56860. import { Skeleton } from "babylonjs/Bones/skeleton";
  56861. import { Observable } from "babylonjs/Misc/observable";
  56862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56863. import { Texture } from "babylonjs/Materials/Textures/texture";
  56864. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56865. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56866. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56867. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56868. /**
  56869. * Defines the list of states available for a task inside a AssetsManager
  56870. */
  56871. export enum AssetTaskState {
  56872. /**
  56873. * Initialization
  56874. */
  56875. INIT = 0,
  56876. /**
  56877. * Running
  56878. */
  56879. RUNNING = 1,
  56880. /**
  56881. * Done
  56882. */
  56883. DONE = 2,
  56884. /**
  56885. * Error
  56886. */
  56887. ERROR = 3
  56888. }
  56889. /**
  56890. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56891. */
  56892. export abstract class AbstractAssetTask {
  56893. /**
  56894. * Task name
  56895. */ name: string;
  56896. /**
  56897. * Callback called when the task is successful
  56898. */
  56899. onSuccess: (task: any) => void;
  56900. /**
  56901. * Callback called when the task is not successful
  56902. */
  56903. onError: (task: any, message?: string, exception?: any) => void;
  56904. /**
  56905. * Creates a new AssetsManager
  56906. * @param name defines the name of the task
  56907. */
  56908. constructor(
  56909. /**
  56910. * Task name
  56911. */ name: string);
  56912. private _isCompleted;
  56913. private _taskState;
  56914. private _errorObject;
  56915. /**
  56916. * Get if the task is completed
  56917. */
  56918. readonly isCompleted: boolean;
  56919. /**
  56920. * Gets the current state of the task
  56921. */
  56922. readonly taskState: AssetTaskState;
  56923. /**
  56924. * Gets the current error object (if task is in error)
  56925. */
  56926. readonly errorObject: {
  56927. message?: string;
  56928. exception?: any;
  56929. };
  56930. /**
  56931. * Internal only
  56932. * @hidden
  56933. */
  56934. _setErrorObject(message?: string, exception?: any): void;
  56935. /**
  56936. * Execute the current task
  56937. * @param scene defines the scene where you want your assets to be loaded
  56938. * @param onSuccess is a callback called when the task is successfully executed
  56939. * @param onError is a callback called if an error occurs
  56940. */
  56941. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56942. /**
  56943. * Execute the current task
  56944. * @param scene defines the scene where you want your assets to be loaded
  56945. * @param onSuccess is a callback called when the task is successfully executed
  56946. * @param onError is a callback called if an error occurs
  56947. */
  56948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56949. /**
  56950. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56951. * This can be used with failed tasks that have the reason for failure fixed.
  56952. */
  56953. reset(): void;
  56954. private onErrorCallback;
  56955. private onDoneCallback;
  56956. }
  56957. /**
  56958. * Define the interface used by progress events raised during assets loading
  56959. */
  56960. export interface IAssetsProgressEvent {
  56961. /**
  56962. * Defines the number of remaining tasks to process
  56963. */
  56964. remainingCount: number;
  56965. /**
  56966. * Defines the total number of tasks
  56967. */
  56968. totalCount: number;
  56969. /**
  56970. * Defines the task that was just processed
  56971. */
  56972. task: AbstractAssetTask;
  56973. }
  56974. /**
  56975. * Class used to share progress information about assets loading
  56976. */
  56977. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56978. /**
  56979. * Defines the number of remaining tasks to process
  56980. */
  56981. remainingCount: number;
  56982. /**
  56983. * Defines the total number of tasks
  56984. */
  56985. totalCount: number;
  56986. /**
  56987. * Defines the task that was just processed
  56988. */
  56989. task: AbstractAssetTask;
  56990. /**
  56991. * Creates a AssetsProgressEvent
  56992. * @param remainingCount defines the number of remaining tasks to process
  56993. * @param totalCount defines the total number of tasks
  56994. * @param task defines the task that was just processed
  56995. */
  56996. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56997. }
  56998. /**
  56999. * Define a task used by AssetsManager to load meshes
  57000. */
  57001. export class MeshAssetTask extends AbstractAssetTask {
  57002. /**
  57003. * Defines the name of the task
  57004. */
  57005. name: string;
  57006. /**
  57007. * Defines the list of mesh's names you want to load
  57008. */
  57009. meshesNames: any;
  57010. /**
  57011. * Defines the root url to use as a base to load your meshes and associated resources
  57012. */
  57013. rootUrl: string;
  57014. /**
  57015. * Defines the filename of the scene to load from
  57016. */
  57017. sceneFilename: string;
  57018. /**
  57019. * Gets the list of loaded meshes
  57020. */
  57021. loadedMeshes: Array<AbstractMesh>;
  57022. /**
  57023. * Gets the list of loaded particle systems
  57024. */
  57025. loadedParticleSystems: Array<IParticleSystem>;
  57026. /**
  57027. * Gets the list of loaded skeletons
  57028. */
  57029. loadedSkeletons: Array<Skeleton>;
  57030. /**
  57031. * Gets the list of loaded animation groups
  57032. */
  57033. loadedAnimationGroups: Array<AnimationGroup>;
  57034. /**
  57035. * Callback called when the task is successful
  57036. */
  57037. onSuccess: (task: MeshAssetTask) => void;
  57038. /**
  57039. * Callback called when the task is successful
  57040. */
  57041. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57042. /**
  57043. * Creates a new MeshAssetTask
  57044. * @param name defines the name of the task
  57045. * @param meshesNames defines the list of mesh's names you want to load
  57046. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57047. * @param sceneFilename defines the filename of the scene to load from
  57048. */
  57049. constructor(
  57050. /**
  57051. * Defines the name of the task
  57052. */
  57053. name: string,
  57054. /**
  57055. * Defines the list of mesh's names you want to load
  57056. */
  57057. meshesNames: any,
  57058. /**
  57059. * Defines the root url to use as a base to load your meshes and associated resources
  57060. */
  57061. rootUrl: string,
  57062. /**
  57063. * Defines the filename of the scene to load from
  57064. */
  57065. sceneFilename: string);
  57066. /**
  57067. * Execute the current task
  57068. * @param scene defines the scene where you want your assets to be loaded
  57069. * @param onSuccess is a callback called when the task is successfully executed
  57070. * @param onError is a callback called if an error occurs
  57071. */
  57072. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57073. }
  57074. /**
  57075. * Define a task used by AssetsManager to load text content
  57076. */
  57077. export class TextFileAssetTask extends AbstractAssetTask {
  57078. /**
  57079. * Defines the name of the task
  57080. */
  57081. name: string;
  57082. /**
  57083. * Defines the location of the file to load
  57084. */
  57085. url: string;
  57086. /**
  57087. * Gets the loaded text string
  57088. */
  57089. text: string;
  57090. /**
  57091. * Callback called when the task is successful
  57092. */
  57093. onSuccess: (task: TextFileAssetTask) => void;
  57094. /**
  57095. * Callback called when the task is successful
  57096. */
  57097. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57098. /**
  57099. * Creates a new TextFileAssetTask object
  57100. * @param name defines the name of the task
  57101. * @param url defines the location of the file to load
  57102. */
  57103. constructor(
  57104. /**
  57105. * Defines the name of the task
  57106. */
  57107. name: string,
  57108. /**
  57109. * Defines the location of the file to load
  57110. */
  57111. url: string);
  57112. /**
  57113. * Execute the current task
  57114. * @param scene defines the scene where you want your assets to be loaded
  57115. * @param onSuccess is a callback called when the task is successfully executed
  57116. * @param onError is a callback called if an error occurs
  57117. */
  57118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57119. }
  57120. /**
  57121. * Define a task used by AssetsManager to load binary data
  57122. */
  57123. export class BinaryFileAssetTask extends AbstractAssetTask {
  57124. /**
  57125. * Defines the name of the task
  57126. */
  57127. name: string;
  57128. /**
  57129. * Defines the location of the file to load
  57130. */
  57131. url: string;
  57132. /**
  57133. * Gets the lodaded data (as an array buffer)
  57134. */
  57135. data: ArrayBuffer;
  57136. /**
  57137. * Callback called when the task is successful
  57138. */
  57139. onSuccess: (task: BinaryFileAssetTask) => void;
  57140. /**
  57141. * Callback called when the task is successful
  57142. */
  57143. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57144. /**
  57145. * Creates a new BinaryFileAssetTask object
  57146. * @param name defines the name of the new task
  57147. * @param url defines the location of the file to load
  57148. */
  57149. constructor(
  57150. /**
  57151. * Defines the name of the task
  57152. */
  57153. name: string,
  57154. /**
  57155. * Defines the location of the file to load
  57156. */
  57157. url: string);
  57158. /**
  57159. * Execute the current task
  57160. * @param scene defines the scene where you want your assets to be loaded
  57161. * @param onSuccess is a callback called when the task is successfully executed
  57162. * @param onError is a callback called if an error occurs
  57163. */
  57164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57165. }
  57166. /**
  57167. * Define a task used by AssetsManager to load images
  57168. */
  57169. export class ImageAssetTask extends AbstractAssetTask {
  57170. /**
  57171. * Defines the name of the task
  57172. */
  57173. name: string;
  57174. /**
  57175. * Defines the location of the image to load
  57176. */
  57177. url: string;
  57178. /**
  57179. * Gets the loaded images
  57180. */
  57181. image: HTMLImageElement;
  57182. /**
  57183. * Callback called when the task is successful
  57184. */
  57185. onSuccess: (task: ImageAssetTask) => void;
  57186. /**
  57187. * Callback called when the task is successful
  57188. */
  57189. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57190. /**
  57191. * Creates a new ImageAssetTask
  57192. * @param name defines the name of the task
  57193. * @param url defines the location of the image to load
  57194. */
  57195. constructor(
  57196. /**
  57197. * Defines the name of the task
  57198. */
  57199. name: string,
  57200. /**
  57201. * Defines the location of the image to load
  57202. */
  57203. url: string);
  57204. /**
  57205. * Execute the current task
  57206. * @param scene defines the scene where you want your assets to be loaded
  57207. * @param onSuccess is a callback called when the task is successfully executed
  57208. * @param onError is a callback called if an error occurs
  57209. */
  57210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57211. }
  57212. /**
  57213. * Defines the interface used by texture loading tasks
  57214. */
  57215. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57216. /**
  57217. * Gets the loaded texture
  57218. */
  57219. texture: TEX;
  57220. }
  57221. /**
  57222. * Define a task used by AssetsManager to load 2D textures
  57223. */
  57224. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57225. /**
  57226. * Defines the name of the task
  57227. */
  57228. name: string;
  57229. /**
  57230. * Defines the location of the file to load
  57231. */
  57232. url: string;
  57233. /**
  57234. * Defines if mipmap should not be generated (default is false)
  57235. */
  57236. noMipmap?: boolean | undefined;
  57237. /**
  57238. * Defines if texture must be inverted on Y axis (default is false)
  57239. */
  57240. invertY?: boolean | undefined;
  57241. /**
  57242. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57243. */
  57244. samplingMode: number;
  57245. /**
  57246. * Gets the loaded texture
  57247. */
  57248. texture: Texture;
  57249. /**
  57250. * Callback called when the task is successful
  57251. */
  57252. onSuccess: (task: TextureAssetTask) => void;
  57253. /**
  57254. * Callback called when the task is successful
  57255. */
  57256. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57257. /**
  57258. * Creates a new TextureAssetTask object
  57259. * @param name defines the name of the task
  57260. * @param url defines the location of the file to load
  57261. * @param noMipmap defines if mipmap should not be generated (default is false)
  57262. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57263. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57264. */
  57265. constructor(
  57266. /**
  57267. * Defines the name of the task
  57268. */
  57269. name: string,
  57270. /**
  57271. * Defines the location of the file to load
  57272. */
  57273. url: string,
  57274. /**
  57275. * Defines if mipmap should not be generated (default is false)
  57276. */
  57277. noMipmap?: boolean | undefined,
  57278. /**
  57279. * Defines if texture must be inverted on Y axis (default is false)
  57280. */
  57281. invertY?: boolean | undefined,
  57282. /**
  57283. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57284. */
  57285. samplingMode?: number);
  57286. /**
  57287. * Execute the current task
  57288. * @param scene defines the scene where you want your assets to be loaded
  57289. * @param onSuccess is a callback called when the task is successfully executed
  57290. * @param onError is a callback called if an error occurs
  57291. */
  57292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57293. }
  57294. /**
  57295. * Define a task used by AssetsManager to load cube textures
  57296. */
  57297. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57298. /**
  57299. * Defines the name of the task
  57300. */
  57301. name: string;
  57302. /**
  57303. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57304. */
  57305. url: string;
  57306. /**
  57307. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57308. */
  57309. extensions?: string[] | undefined;
  57310. /**
  57311. * Defines if mipmaps should not be generated (default is false)
  57312. */
  57313. noMipmap?: boolean | undefined;
  57314. /**
  57315. * Defines the explicit list of files (undefined by default)
  57316. */
  57317. files?: string[] | undefined;
  57318. /**
  57319. * Gets the loaded texture
  57320. */
  57321. texture: CubeTexture;
  57322. /**
  57323. * Callback called when the task is successful
  57324. */
  57325. onSuccess: (task: CubeTextureAssetTask) => void;
  57326. /**
  57327. * Callback called when the task is successful
  57328. */
  57329. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57330. /**
  57331. * Creates a new CubeTextureAssetTask
  57332. * @param name defines the name of the task
  57333. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57334. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57335. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57336. * @param files defines the explicit list of files (undefined by default)
  57337. */
  57338. constructor(
  57339. /**
  57340. * Defines the name of the task
  57341. */
  57342. name: string,
  57343. /**
  57344. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57345. */
  57346. url: string,
  57347. /**
  57348. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57349. */
  57350. extensions?: string[] | undefined,
  57351. /**
  57352. * Defines if mipmaps should not be generated (default is false)
  57353. */
  57354. noMipmap?: boolean | undefined,
  57355. /**
  57356. * Defines the explicit list of files (undefined by default)
  57357. */
  57358. files?: string[] | undefined);
  57359. /**
  57360. * Execute the current task
  57361. * @param scene defines the scene where you want your assets to be loaded
  57362. * @param onSuccess is a callback called when the task is successfully executed
  57363. * @param onError is a callback called if an error occurs
  57364. */
  57365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57366. }
  57367. /**
  57368. * Define a task used by AssetsManager to load HDR cube textures
  57369. */
  57370. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57371. /**
  57372. * Defines the name of the task
  57373. */
  57374. name: string;
  57375. /**
  57376. * Defines the location of the file to load
  57377. */
  57378. url: string;
  57379. /**
  57380. * Defines the desired size (the more it increases the longer the generation will be)
  57381. */
  57382. size: number;
  57383. /**
  57384. * Defines if mipmaps should not be generated (default is false)
  57385. */
  57386. noMipmap: boolean;
  57387. /**
  57388. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57389. */
  57390. generateHarmonics: boolean;
  57391. /**
  57392. * 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)
  57393. */
  57394. gammaSpace: boolean;
  57395. /**
  57396. * Internal Use Only
  57397. */
  57398. reserved: boolean;
  57399. /**
  57400. * Gets the loaded texture
  57401. */
  57402. texture: HDRCubeTexture;
  57403. /**
  57404. * Callback called when the task is successful
  57405. */
  57406. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57407. /**
  57408. * Callback called when the task is successful
  57409. */
  57410. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57411. /**
  57412. * Creates a new HDRCubeTextureAssetTask object
  57413. * @param name defines the name of the task
  57414. * @param url defines the location of the file to load
  57415. * @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.
  57416. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57417. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57418. * @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)
  57419. * @param reserved Internal use only
  57420. */
  57421. constructor(
  57422. /**
  57423. * Defines the name of the task
  57424. */
  57425. name: string,
  57426. /**
  57427. * Defines the location of the file to load
  57428. */
  57429. url: string,
  57430. /**
  57431. * Defines the desired size (the more it increases the longer the generation will be)
  57432. */
  57433. size: number,
  57434. /**
  57435. * Defines if mipmaps should not be generated (default is false)
  57436. */
  57437. noMipmap?: boolean,
  57438. /**
  57439. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57440. */
  57441. generateHarmonics?: boolean,
  57442. /**
  57443. * 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)
  57444. */
  57445. gammaSpace?: boolean,
  57446. /**
  57447. * Internal Use Only
  57448. */
  57449. reserved?: boolean);
  57450. /**
  57451. * Execute the current task
  57452. * @param scene defines the scene where you want your assets to be loaded
  57453. * @param onSuccess is a callback called when the task is successfully executed
  57454. * @param onError is a callback called if an error occurs
  57455. */
  57456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57457. }
  57458. /**
  57459. * Define a task used by AssetsManager to load Equirectangular cube textures
  57460. */
  57461. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57462. /**
  57463. * Defines the name of the task
  57464. */
  57465. name: string;
  57466. /**
  57467. * Defines the location of the file to load
  57468. */
  57469. url: string;
  57470. /**
  57471. * Defines the desired size (the more it increases the longer the generation will be)
  57472. */
  57473. size: number;
  57474. /**
  57475. * Defines if mipmaps should not be generated (default is false)
  57476. */
  57477. noMipmap: boolean;
  57478. /**
  57479. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57480. * but the standard material would require them in Gamma space) (default is true)
  57481. */
  57482. gammaSpace: boolean;
  57483. /**
  57484. * Gets the loaded texture
  57485. */
  57486. texture: EquiRectangularCubeTexture;
  57487. /**
  57488. * Callback called when the task is successful
  57489. */
  57490. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57491. /**
  57492. * Callback called when the task is successful
  57493. */
  57494. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57495. /**
  57496. * Creates a new EquiRectangularCubeTextureAssetTask object
  57497. * @param name defines the name of the task
  57498. * @param url defines the location of the file to load
  57499. * @param size defines the desired size (the more it increases the longer the generation will be)
  57500. * If the size is omitted this implies you are using a preprocessed cubemap.
  57501. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57502. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57503. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57504. * (default is true)
  57505. */
  57506. constructor(
  57507. /**
  57508. * Defines the name of the task
  57509. */
  57510. name: string,
  57511. /**
  57512. * Defines the location of the file to load
  57513. */
  57514. url: string,
  57515. /**
  57516. * Defines the desired size (the more it increases the longer the generation will be)
  57517. */
  57518. size: number,
  57519. /**
  57520. * Defines if mipmaps should not be generated (default is false)
  57521. */
  57522. noMipmap?: boolean,
  57523. /**
  57524. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57525. * but the standard material would require them in Gamma space) (default is true)
  57526. */
  57527. gammaSpace?: boolean);
  57528. /**
  57529. * Execute the current task
  57530. * @param scene defines the scene where you want your assets to be loaded
  57531. * @param onSuccess is a callback called when the task is successfully executed
  57532. * @param onError is a callback called if an error occurs
  57533. */
  57534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57535. }
  57536. /**
  57537. * This class can be used to easily import assets into a scene
  57538. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57539. */
  57540. export class AssetsManager {
  57541. private _scene;
  57542. private _isLoading;
  57543. protected _tasks: AbstractAssetTask[];
  57544. protected _waitingTasksCount: number;
  57545. protected _totalTasksCount: number;
  57546. /**
  57547. * Callback called when all tasks are processed
  57548. */
  57549. onFinish: (tasks: AbstractAssetTask[]) => void;
  57550. /**
  57551. * Callback called when a task is successful
  57552. */
  57553. onTaskSuccess: (task: AbstractAssetTask) => void;
  57554. /**
  57555. * Callback called when a task had an error
  57556. */
  57557. onTaskError: (task: AbstractAssetTask) => void;
  57558. /**
  57559. * Callback called when a task is done (whatever the result is)
  57560. */
  57561. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57562. /**
  57563. * Observable called when all tasks are processed
  57564. */
  57565. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57566. /**
  57567. * Observable called when a task had an error
  57568. */
  57569. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57570. /**
  57571. * Observable called when all tasks were executed
  57572. */
  57573. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57574. /**
  57575. * Observable called when a task is done (whatever the result is)
  57576. */
  57577. onProgressObservable: Observable<IAssetsProgressEvent>;
  57578. /**
  57579. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57580. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57581. */
  57582. useDefaultLoadingScreen: boolean;
  57583. /**
  57584. * Creates a new AssetsManager
  57585. * @param scene defines the scene to work on
  57586. */
  57587. constructor(scene: Scene);
  57588. /**
  57589. * Add a MeshAssetTask to the list of active tasks
  57590. * @param taskName defines the name of the new task
  57591. * @param meshesNames defines the name of meshes to load
  57592. * @param rootUrl defines the root url to use to locate files
  57593. * @param sceneFilename defines the filename of the scene file
  57594. * @returns a new MeshAssetTask object
  57595. */
  57596. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57597. /**
  57598. * Add a TextFileAssetTask to the list of active tasks
  57599. * @param taskName defines the name of the new task
  57600. * @param url defines the url of the file to load
  57601. * @returns a new TextFileAssetTask object
  57602. */
  57603. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57604. /**
  57605. * Add a BinaryFileAssetTask to the list of active tasks
  57606. * @param taskName defines the name of the new task
  57607. * @param url defines the url of the file to load
  57608. * @returns a new BinaryFileAssetTask object
  57609. */
  57610. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57611. /**
  57612. * Add a ImageAssetTask to the list of active tasks
  57613. * @param taskName defines the name of the new task
  57614. * @param url defines the url of the file to load
  57615. * @returns a new ImageAssetTask object
  57616. */
  57617. addImageTask(taskName: string, url: string): ImageAssetTask;
  57618. /**
  57619. * Add a TextureAssetTask to the list of active tasks
  57620. * @param taskName defines the name of the new task
  57621. * @param url defines the url of the file to load
  57622. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57623. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57624. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57625. * @returns a new TextureAssetTask object
  57626. */
  57627. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57628. /**
  57629. * Add a CubeTextureAssetTask to the list of active tasks
  57630. * @param taskName defines the name of the new task
  57631. * @param url defines the url of the file to load
  57632. * @param extensions defines the extension to use to load the cube map (can be null)
  57633. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57634. * @param files defines the list of files to load (can be null)
  57635. * @returns a new CubeTextureAssetTask object
  57636. */
  57637. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57638. /**
  57639. *
  57640. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57641. * @param taskName defines the name of the new task
  57642. * @param url defines the url of the file to load
  57643. * @param size defines the size you want for the cubemap (can be null)
  57644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57645. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57646. * @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)
  57647. * @param reserved Internal use only
  57648. * @returns a new HDRCubeTextureAssetTask object
  57649. */
  57650. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57651. /**
  57652. *
  57653. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57654. * @param taskName defines the name of the new task
  57655. * @param url defines the url of the file to load
  57656. * @param size defines the size you want for the cubemap (can be null)
  57657. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57658. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57659. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57660. * @returns a new EquiRectangularCubeTextureAssetTask object
  57661. */
  57662. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57663. /**
  57664. * Remove a task from the assets manager.
  57665. * @param task the task to remove
  57666. */
  57667. removeTask(task: AbstractAssetTask): void;
  57668. private _decreaseWaitingTasksCount;
  57669. private _runTask;
  57670. /**
  57671. * Reset the AssetsManager and remove all tasks
  57672. * @return the current instance of the AssetsManager
  57673. */
  57674. reset(): AssetsManager;
  57675. /**
  57676. * Start the loading process
  57677. * @return the current instance of the AssetsManager
  57678. */
  57679. load(): AssetsManager;
  57680. /**
  57681. * Start the loading process as an async operation
  57682. * @return a promise returning the list of failed tasks
  57683. */
  57684. loadAsync(): Promise<void>;
  57685. }
  57686. }
  57687. declare module "babylonjs/Misc/deferred" {
  57688. /**
  57689. * Wrapper class for promise with external resolve and reject.
  57690. */
  57691. export class Deferred<T> {
  57692. /**
  57693. * The promise associated with this deferred object.
  57694. */
  57695. readonly promise: Promise<T>;
  57696. private _resolve;
  57697. private _reject;
  57698. /**
  57699. * The resolve method of the promise associated with this deferred object.
  57700. */
  57701. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57702. /**
  57703. * The reject method of the promise associated with this deferred object.
  57704. */
  57705. readonly reject: (reason?: any) => void;
  57706. /**
  57707. * Constructor for this deferred object.
  57708. */
  57709. constructor();
  57710. }
  57711. }
  57712. declare module "babylonjs/Misc/meshExploder" {
  57713. import { Mesh } from "babylonjs/Meshes/mesh";
  57714. /**
  57715. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57716. */
  57717. export class MeshExploder {
  57718. private _centerMesh;
  57719. private _meshes;
  57720. private _meshesOrigins;
  57721. private _toCenterVectors;
  57722. private _scaledDirection;
  57723. private _newPosition;
  57724. private _centerPosition;
  57725. /**
  57726. * Explodes meshes from a center mesh.
  57727. * @param meshes The meshes to explode.
  57728. * @param centerMesh The mesh to be center of explosion.
  57729. */
  57730. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57731. private _setCenterMesh;
  57732. /**
  57733. * Get class name
  57734. * @returns "MeshExploder"
  57735. */
  57736. getClassName(): string;
  57737. /**
  57738. * "Exploded meshes"
  57739. * @returns Array of meshes with the centerMesh at index 0.
  57740. */
  57741. getMeshes(): Array<Mesh>;
  57742. /**
  57743. * Explodes meshes giving a specific direction
  57744. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57745. */
  57746. explode(direction?: number): void;
  57747. }
  57748. }
  57749. declare module "babylonjs/Misc/filesInput" {
  57750. import { Engine } from "babylonjs/Engines/engine";
  57751. import { Scene } from "babylonjs/scene";
  57752. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57753. /**
  57754. * Class used to help managing file picking and drag'n'drop
  57755. */
  57756. export class FilesInput {
  57757. /**
  57758. * List of files ready to be loaded
  57759. */
  57760. static readonly FilesToLoad: {
  57761. [key: string]: File;
  57762. };
  57763. /**
  57764. * Callback called when a file is processed
  57765. */
  57766. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57767. private _engine;
  57768. private _currentScene;
  57769. private _sceneLoadedCallback;
  57770. private _progressCallback;
  57771. private _additionalRenderLoopLogicCallback;
  57772. private _textureLoadingCallback;
  57773. private _startingProcessingFilesCallback;
  57774. private _onReloadCallback;
  57775. private _errorCallback;
  57776. private _elementToMonitor;
  57777. private _sceneFileToLoad;
  57778. private _filesToLoad;
  57779. /**
  57780. * Creates a new FilesInput
  57781. * @param engine defines the rendering engine
  57782. * @param scene defines the hosting scene
  57783. * @param sceneLoadedCallback callback called when scene is loaded
  57784. * @param progressCallback callback called to track progress
  57785. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57786. * @param textureLoadingCallback callback called when a texture is loading
  57787. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57788. * @param onReloadCallback callback called when a reload is requested
  57789. * @param errorCallback callback call if an error occurs
  57790. */
  57791. 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);
  57792. private _dragEnterHandler;
  57793. private _dragOverHandler;
  57794. private _dropHandler;
  57795. /**
  57796. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57797. * @param elementToMonitor defines the DOM element to track
  57798. */
  57799. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57800. /**
  57801. * Release all associated resources
  57802. */
  57803. dispose(): void;
  57804. private renderFunction;
  57805. private drag;
  57806. private drop;
  57807. private _traverseFolder;
  57808. private _processFiles;
  57809. /**
  57810. * Load files from a drop event
  57811. * @param event defines the drop event to use as source
  57812. */
  57813. loadFiles(event: any): void;
  57814. private _processReload;
  57815. /**
  57816. * Reload the current scene from the loaded files
  57817. */
  57818. reload(): void;
  57819. }
  57820. }
  57821. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57822. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57823. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57824. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57825. }
  57826. declare module "babylonjs/Misc/sceneOptimizer" {
  57827. import { Scene, IDisposable } from "babylonjs/scene";
  57828. import { Observable } from "babylonjs/Misc/observable";
  57829. /**
  57830. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57831. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57832. */
  57833. export class SceneOptimization {
  57834. /**
  57835. * Defines the priority of this optimization (0 by default which means first in the list)
  57836. */
  57837. priority: number;
  57838. /**
  57839. * Gets a string describing the action executed by the current optimization
  57840. * @returns description string
  57841. */
  57842. getDescription(): string;
  57843. /**
  57844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57845. * @param scene defines the current scene where to apply this optimization
  57846. * @param optimizer defines the current optimizer
  57847. * @returns true if everything that can be done was applied
  57848. */
  57849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57850. /**
  57851. * Creates the SceneOptimization object
  57852. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57853. * @param desc defines the description associated with the optimization
  57854. */
  57855. constructor(
  57856. /**
  57857. * Defines the priority of this optimization (0 by default which means first in the list)
  57858. */
  57859. priority?: number);
  57860. }
  57861. /**
  57862. * Defines an optimization used to reduce the size of render target textures
  57863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57864. */
  57865. export class TextureOptimization extends SceneOptimization {
  57866. /**
  57867. * Defines the priority of this optimization (0 by default which means first in the list)
  57868. */
  57869. priority: number;
  57870. /**
  57871. * 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
  57872. */
  57873. maximumSize: number;
  57874. /**
  57875. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57876. */
  57877. step: number;
  57878. /**
  57879. * Gets a string describing the action executed by the current optimization
  57880. * @returns description string
  57881. */
  57882. getDescription(): string;
  57883. /**
  57884. * Creates the TextureOptimization object
  57885. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57886. * @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
  57887. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57888. */
  57889. constructor(
  57890. /**
  57891. * Defines the priority of this optimization (0 by default which means first in the list)
  57892. */
  57893. priority?: number,
  57894. /**
  57895. * 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
  57896. */
  57897. maximumSize?: number,
  57898. /**
  57899. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57900. */
  57901. step?: number);
  57902. /**
  57903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57904. * @param scene defines the current scene where to apply this optimization
  57905. * @param optimizer defines the current optimizer
  57906. * @returns true if everything that can be done was applied
  57907. */
  57908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57909. }
  57910. /**
  57911. * Defines an optimization used to increase or decrease the rendering resolution
  57912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57913. */
  57914. export class HardwareScalingOptimization extends SceneOptimization {
  57915. /**
  57916. * Defines the priority of this optimization (0 by default which means first in the list)
  57917. */
  57918. priority: number;
  57919. /**
  57920. * Defines the maximum scale to use (2 by default)
  57921. */
  57922. maximumScale: number;
  57923. /**
  57924. * Defines the step to use between two passes (0.5 by default)
  57925. */
  57926. step: number;
  57927. private _currentScale;
  57928. private _directionOffset;
  57929. /**
  57930. * Gets a string describing the action executed by the current optimization
  57931. * @return description string
  57932. */
  57933. getDescription(): string;
  57934. /**
  57935. * Creates the HardwareScalingOptimization object
  57936. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57937. * @param maximumScale defines the maximum scale to use (2 by default)
  57938. * @param step defines the step to use between two passes (0.5 by default)
  57939. */
  57940. constructor(
  57941. /**
  57942. * Defines the priority of this optimization (0 by default which means first in the list)
  57943. */
  57944. priority?: number,
  57945. /**
  57946. * Defines the maximum scale to use (2 by default)
  57947. */
  57948. maximumScale?: number,
  57949. /**
  57950. * Defines the step to use between two passes (0.5 by default)
  57951. */
  57952. step?: number);
  57953. /**
  57954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57955. * @param scene defines the current scene where to apply this optimization
  57956. * @param optimizer defines the current optimizer
  57957. * @returns true if everything that can be done was applied
  57958. */
  57959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57960. }
  57961. /**
  57962. * Defines an optimization used to remove shadows
  57963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57964. */
  57965. export class ShadowsOptimization extends SceneOptimization {
  57966. /**
  57967. * Gets a string describing the action executed by the current optimization
  57968. * @return description string
  57969. */
  57970. getDescription(): string;
  57971. /**
  57972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57973. * @param scene defines the current scene where to apply this optimization
  57974. * @param optimizer defines the current optimizer
  57975. * @returns true if everything that can be done was applied
  57976. */
  57977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57978. }
  57979. /**
  57980. * Defines an optimization used to turn post-processes off
  57981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57982. */
  57983. export class PostProcessesOptimization extends SceneOptimization {
  57984. /**
  57985. * Gets a string describing the action executed by the current optimization
  57986. * @return description string
  57987. */
  57988. getDescription(): string;
  57989. /**
  57990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57991. * @param scene defines the current scene where to apply this optimization
  57992. * @param optimizer defines the current optimizer
  57993. * @returns true if everything that can be done was applied
  57994. */
  57995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57996. }
  57997. /**
  57998. * Defines an optimization used to turn lens flares off
  57999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58000. */
  58001. export class LensFlaresOptimization extends SceneOptimization {
  58002. /**
  58003. * Gets a string describing the action executed by the current optimization
  58004. * @return description string
  58005. */
  58006. getDescription(): string;
  58007. /**
  58008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58009. * @param scene defines the current scene where to apply this optimization
  58010. * @param optimizer defines the current optimizer
  58011. * @returns true if everything that can be done was applied
  58012. */
  58013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58014. }
  58015. /**
  58016. * Defines an optimization based on user defined callback.
  58017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58018. */
  58019. export class CustomOptimization extends SceneOptimization {
  58020. /**
  58021. * Callback called to apply the custom optimization.
  58022. */
  58023. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58024. /**
  58025. * Callback called to get custom description
  58026. */
  58027. onGetDescription: () => string;
  58028. /**
  58029. * Gets a string describing the action executed by the current optimization
  58030. * @returns description string
  58031. */
  58032. getDescription(): string;
  58033. /**
  58034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58035. * @param scene defines the current scene where to apply this optimization
  58036. * @param optimizer defines the current optimizer
  58037. * @returns true if everything that can be done was applied
  58038. */
  58039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58040. }
  58041. /**
  58042. * Defines an optimization used to turn particles off
  58043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58044. */
  58045. export class ParticlesOptimization extends SceneOptimization {
  58046. /**
  58047. * Gets a string describing the action executed by the current optimization
  58048. * @return description string
  58049. */
  58050. getDescription(): string;
  58051. /**
  58052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58053. * @param scene defines the current scene where to apply this optimization
  58054. * @param optimizer defines the current optimizer
  58055. * @returns true if everything that can be done was applied
  58056. */
  58057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58058. }
  58059. /**
  58060. * Defines an optimization used to turn render targets off
  58061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58062. */
  58063. export class RenderTargetsOptimization extends SceneOptimization {
  58064. /**
  58065. * Gets a string describing the action executed by the current optimization
  58066. * @return description string
  58067. */
  58068. getDescription(): string;
  58069. /**
  58070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58071. * @param scene defines the current scene where to apply this optimization
  58072. * @param optimizer defines the current optimizer
  58073. * @returns true if everything that can be done was applied
  58074. */
  58075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58076. }
  58077. /**
  58078. * Defines an optimization used to merge meshes with compatible materials
  58079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58080. */
  58081. export class MergeMeshesOptimization extends SceneOptimization {
  58082. private static _UpdateSelectionTree;
  58083. /**
  58084. * Gets or sets a boolean which defines if optimization octree has to be updated
  58085. */
  58086. /**
  58087. * Gets or sets a boolean which defines if optimization octree has to be updated
  58088. */
  58089. static UpdateSelectionTree: boolean;
  58090. /**
  58091. * Gets a string describing the action executed by the current optimization
  58092. * @return description string
  58093. */
  58094. getDescription(): string;
  58095. private _canBeMerged;
  58096. /**
  58097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58098. * @param scene defines the current scene where to apply this optimization
  58099. * @param optimizer defines the current optimizer
  58100. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58101. * @returns true if everything that can be done was applied
  58102. */
  58103. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58104. }
  58105. /**
  58106. * Defines a list of options used by SceneOptimizer
  58107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58108. */
  58109. export class SceneOptimizerOptions {
  58110. /**
  58111. * Defines the target frame rate to reach (60 by default)
  58112. */
  58113. targetFrameRate: number;
  58114. /**
  58115. * Defines the interval between two checkes (2000ms by default)
  58116. */
  58117. trackerDuration: number;
  58118. /**
  58119. * Gets the list of optimizations to apply
  58120. */
  58121. optimizations: SceneOptimization[];
  58122. /**
  58123. * Creates a new list of options used by SceneOptimizer
  58124. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58125. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58126. */
  58127. constructor(
  58128. /**
  58129. * Defines the target frame rate to reach (60 by default)
  58130. */
  58131. targetFrameRate?: number,
  58132. /**
  58133. * Defines the interval between two checkes (2000ms by default)
  58134. */
  58135. trackerDuration?: number);
  58136. /**
  58137. * Add a new optimization
  58138. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58139. * @returns the current SceneOptimizerOptions
  58140. */
  58141. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58142. /**
  58143. * Add a new custom optimization
  58144. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58145. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58146. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58147. * @returns the current SceneOptimizerOptions
  58148. */
  58149. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58150. /**
  58151. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58152. * @param targetFrameRate defines the target frame rate (60 by default)
  58153. * @returns a SceneOptimizerOptions object
  58154. */
  58155. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58156. /**
  58157. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58158. * @param targetFrameRate defines the target frame rate (60 by default)
  58159. * @returns a SceneOptimizerOptions object
  58160. */
  58161. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58162. /**
  58163. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58164. * @param targetFrameRate defines the target frame rate (60 by default)
  58165. * @returns a SceneOptimizerOptions object
  58166. */
  58167. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58168. }
  58169. /**
  58170. * Class used to run optimizations in order to reach a target frame rate
  58171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58172. */
  58173. export class SceneOptimizer implements IDisposable {
  58174. private _isRunning;
  58175. private _options;
  58176. private _scene;
  58177. private _currentPriorityLevel;
  58178. private _targetFrameRate;
  58179. private _trackerDuration;
  58180. private _currentFrameRate;
  58181. private _sceneDisposeObserver;
  58182. private _improvementMode;
  58183. /**
  58184. * Defines an observable called when the optimizer reaches the target frame rate
  58185. */
  58186. onSuccessObservable: Observable<SceneOptimizer>;
  58187. /**
  58188. * Defines an observable called when the optimizer enables an optimization
  58189. */
  58190. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58191. /**
  58192. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58193. */
  58194. onFailureObservable: Observable<SceneOptimizer>;
  58195. /**
  58196. * Gets a boolean indicating if the optimizer is in improvement mode
  58197. */
  58198. readonly isInImprovementMode: boolean;
  58199. /**
  58200. * Gets the current priority level (0 at start)
  58201. */
  58202. readonly currentPriorityLevel: number;
  58203. /**
  58204. * Gets the current frame rate checked by the SceneOptimizer
  58205. */
  58206. readonly currentFrameRate: number;
  58207. /**
  58208. * Gets or sets the current target frame rate (60 by default)
  58209. */
  58210. /**
  58211. * Gets or sets the current target frame rate (60 by default)
  58212. */
  58213. targetFrameRate: number;
  58214. /**
  58215. * Gets or sets the current interval between two checks (every 2000ms by default)
  58216. */
  58217. /**
  58218. * Gets or sets the current interval between two checks (every 2000ms by default)
  58219. */
  58220. trackerDuration: number;
  58221. /**
  58222. * Gets the list of active optimizations
  58223. */
  58224. readonly optimizations: SceneOptimization[];
  58225. /**
  58226. * Creates a new SceneOptimizer
  58227. * @param scene defines the scene to work on
  58228. * @param options defines the options to use with the SceneOptimizer
  58229. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58230. * @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)
  58231. */
  58232. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58233. /**
  58234. * Stops the current optimizer
  58235. */
  58236. stop(): void;
  58237. /**
  58238. * Reset the optimizer to initial step (current priority level = 0)
  58239. */
  58240. reset(): void;
  58241. /**
  58242. * Start the optimizer. By default it will try to reach a specific framerate
  58243. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58244. */
  58245. start(): void;
  58246. private _checkCurrentState;
  58247. /**
  58248. * Release all resources
  58249. */
  58250. dispose(): void;
  58251. /**
  58252. * Helper function to create a SceneOptimizer with one single line of code
  58253. * @param scene defines the scene to work on
  58254. * @param options defines the options to use with the SceneOptimizer
  58255. * @param onSuccess defines a callback to call on success
  58256. * @param onFailure defines a callback to call on failure
  58257. * @returns the new SceneOptimizer object
  58258. */
  58259. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58260. }
  58261. }
  58262. declare module "babylonjs/Misc/sceneSerializer" {
  58263. import { Scene } from "babylonjs/scene";
  58264. /**
  58265. * Class used to serialize a scene into a string
  58266. */
  58267. export class SceneSerializer {
  58268. /**
  58269. * Clear cache used by a previous serialization
  58270. */
  58271. static ClearCache(): void;
  58272. /**
  58273. * Serialize a scene into a JSON compatible object
  58274. * @param scene defines the scene to serialize
  58275. * @returns a JSON compatible object
  58276. */
  58277. static Serialize(scene: Scene): any;
  58278. /**
  58279. * Serialize a mesh into a JSON compatible object
  58280. * @param toSerialize defines the mesh to serialize
  58281. * @param withParents defines if parents must be serialized as well
  58282. * @param withChildren defines if children must be serialized as well
  58283. * @returns a JSON compatible object
  58284. */
  58285. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58286. }
  58287. }
  58288. declare module "babylonjs/Misc/textureTools" {
  58289. import { Texture } from "babylonjs/Materials/Textures/texture";
  58290. /**
  58291. * Class used to host texture specific utilities
  58292. */
  58293. export class TextureTools {
  58294. /**
  58295. * Uses the GPU to create a copy texture rescaled at a given size
  58296. * @param texture Texture to copy from
  58297. * @param width defines the desired width
  58298. * @param height defines the desired height
  58299. * @param useBilinearMode defines if bilinear mode has to be used
  58300. * @return the generated texture
  58301. */
  58302. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58303. }
  58304. }
  58305. declare module "babylonjs/Misc/videoRecorder" {
  58306. import { Nullable } from "babylonjs/types";
  58307. import { Engine } from "babylonjs/Engines/engine";
  58308. /**
  58309. * This represents the different options avilable for the video capture.
  58310. */
  58311. export interface VideoRecorderOptions {
  58312. /** Defines the mime type of the video */
  58313. mimeType: string;
  58314. /** Defines the video the video should be recorded at */
  58315. fps: number;
  58316. /** Defines the chunk size for the recording data */
  58317. recordChunckSize: number;
  58318. /** The audio tracks to attach to the record */
  58319. audioTracks?: MediaStreamTrack[];
  58320. }
  58321. /**
  58322. * This can helps recording videos from BabylonJS.
  58323. * This is based on the available WebRTC functionalities of the browser.
  58324. *
  58325. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58326. */
  58327. export class VideoRecorder {
  58328. private static readonly _defaultOptions;
  58329. /**
  58330. * Returns wehther or not the VideoRecorder is available in your browser.
  58331. * @param engine Defines the Babylon Engine to check the support for
  58332. * @returns true if supported otherwise false
  58333. */
  58334. static IsSupported(engine: Engine): boolean;
  58335. private readonly _options;
  58336. private _canvas;
  58337. private _mediaRecorder;
  58338. private _recordedChunks;
  58339. private _fileName;
  58340. private _resolve;
  58341. private _reject;
  58342. /**
  58343. * True wether a recording is already in progress.
  58344. */
  58345. readonly isRecording: boolean;
  58346. /**
  58347. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58348. * a video file.
  58349. * @param engine Defines the BabylonJS Engine you wish to record
  58350. * @param options Defines options that can be used to customized the capture
  58351. */
  58352. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58353. /**
  58354. * Stops the current recording before the default capture timeout passed in the startRecording
  58355. * functions.
  58356. */
  58357. stopRecording(): void;
  58358. /**
  58359. * Starts recording the canvas for a max duration specified in parameters.
  58360. * @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.
  58361. * @param maxDuration Defines the maximum recording time in seconds.
  58362. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58363. * @return a promise callback at the end of the recording with the video data in Blob.
  58364. */
  58365. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58366. /**
  58367. * Releases internal resources used during the recording.
  58368. */
  58369. dispose(): void;
  58370. private _handleDataAvailable;
  58371. private _handleError;
  58372. private _handleStop;
  58373. }
  58374. }
  58375. declare module "babylonjs/Misc/workerPool" {
  58376. import { IDisposable } from "babylonjs/scene";
  58377. /**
  58378. * Helper class to push actions to a pool of workers.
  58379. */
  58380. export class WorkerPool implements IDisposable {
  58381. private _workerInfos;
  58382. private _pendingActions;
  58383. /**
  58384. * Constructor
  58385. * @param workers Array of workers to use for actions
  58386. */
  58387. constructor(workers: Array<Worker>);
  58388. /**
  58389. * Terminates all workers and clears any pending actions.
  58390. */
  58391. dispose(): void;
  58392. /**
  58393. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58394. * pended until a worker has completed its action.
  58395. * @param action The action to perform. Call onComplete when the action is complete.
  58396. */
  58397. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58398. private _execute;
  58399. }
  58400. }
  58401. declare module "babylonjs/Misc/screenshotTools" {
  58402. import { Camera } from "babylonjs/Cameras/camera";
  58403. import { Engine } from "babylonjs/Engines/engine";
  58404. /**
  58405. * Class containing a set of static utilities functions for screenshots
  58406. */
  58407. export class ScreenshotTools {
  58408. /**
  58409. * Captures a screenshot of the current rendering
  58410. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58411. * @param engine defines the rendering engine
  58412. * @param camera defines the source camera
  58413. * @param size This parameter can be set to a single number or to an object with the
  58414. * following (optional) properties: precision, width, height. If a single number is passed,
  58415. * it will be used for both width and height. If an object is passed, the screenshot size
  58416. * will be derived from the parameters. The precision property is a multiplier allowing
  58417. * rendering at a higher or lower resolution
  58418. * @param successCallback defines the callback receives a single parameter which contains the
  58419. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58420. * src parameter of an <img> to display it
  58421. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58422. * Check your browser for supported MIME types
  58423. */
  58424. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58425. /**
  58426. * Generates an image screenshot from the specified camera.
  58427. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58428. * @param engine The engine to use for rendering
  58429. * @param camera The camera to use for rendering
  58430. * @param size This parameter can be set to a single number or to an object with the
  58431. * following (optional) properties: precision, width, height. If a single number is passed,
  58432. * it will be used for both width and height. If an object is passed, the screenshot size
  58433. * will be derived from the parameters. The precision property is a multiplier allowing
  58434. * rendering at a higher or lower resolution
  58435. * @param successCallback The callback receives a single parameter which contains the
  58436. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58437. * src parameter of an <img> to display it
  58438. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58439. * Check your browser for supported MIME types
  58440. * @param samples Texture samples (default: 1)
  58441. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58442. * @param fileName A name for for the downloaded file.
  58443. */
  58444. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58445. }
  58446. }
  58447. declare module "babylonjs/Misc/index" {
  58448. export * from "babylonjs/Misc/andOrNotEvaluator";
  58449. export * from "babylonjs/Misc/assetsManager";
  58450. export * from "babylonjs/Misc/dds";
  58451. export * from "babylonjs/Misc/decorators";
  58452. export * from "babylonjs/Misc/deferred";
  58453. export * from "babylonjs/Misc/environmentTextureTools";
  58454. export * from "babylonjs/Misc/meshExploder";
  58455. export * from "babylonjs/Misc/filesInput";
  58456. export * from "babylonjs/Misc/HighDynamicRange/index";
  58457. export * from "babylonjs/Misc/khronosTextureContainer";
  58458. export * from "babylonjs/Misc/observable";
  58459. export * from "babylonjs/Misc/performanceMonitor";
  58460. export * from "babylonjs/Misc/promise";
  58461. export * from "babylonjs/Misc/sceneOptimizer";
  58462. export * from "babylonjs/Misc/sceneSerializer";
  58463. export * from "babylonjs/Misc/smartArray";
  58464. export * from "babylonjs/Misc/stringDictionary";
  58465. export * from "babylonjs/Misc/tags";
  58466. export * from "babylonjs/Misc/textureTools";
  58467. export * from "babylonjs/Misc/tga";
  58468. export * from "babylonjs/Misc/tools";
  58469. export * from "babylonjs/Misc/videoRecorder";
  58470. export * from "babylonjs/Misc/virtualJoystick";
  58471. export * from "babylonjs/Misc/workerPool";
  58472. export * from "babylonjs/Misc/logger";
  58473. export * from "babylonjs/Misc/typeStore";
  58474. export * from "babylonjs/Misc/filesInputStore";
  58475. export * from "babylonjs/Misc/deepCopier";
  58476. export * from "babylonjs/Misc/pivotTools";
  58477. export * from "babylonjs/Misc/precisionDate";
  58478. export * from "babylonjs/Misc/screenshotTools";
  58479. export * from "babylonjs/Misc/typeStore";
  58480. export * from "babylonjs/Misc/webRequest";
  58481. export * from "babylonjs/Misc/iInspectable";
  58482. }
  58483. declare module "babylonjs/index" {
  58484. export * from "babylonjs/abstractScene";
  58485. export * from "babylonjs/Actions/index";
  58486. export * from "babylonjs/Animations/index";
  58487. export * from "babylonjs/assetContainer";
  58488. export * from "babylonjs/Audio/index";
  58489. export * from "babylonjs/Behaviors/index";
  58490. export * from "babylonjs/Bones/index";
  58491. export * from "babylonjs/Cameras/index";
  58492. export * from "babylonjs/Collisions/index";
  58493. export * from "babylonjs/Culling/index";
  58494. export * from "babylonjs/Debug/index";
  58495. export * from "babylonjs/Engines/index";
  58496. export * from "babylonjs/Events/index";
  58497. export * from "babylonjs/Gamepads/index";
  58498. export * from "babylonjs/Gizmos/index";
  58499. export * from "babylonjs/Helpers/index";
  58500. export * from "babylonjs/Instrumentation/index";
  58501. export * from "babylonjs/Layers/index";
  58502. export * from "babylonjs/LensFlares/index";
  58503. export * from "babylonjs/Lights/index";
  58504. export * from "babylonjs/Loading/index";
  58505. export * from "babylonjs/Materials/index";
  58506. export * from "babylonjs/Maths/index";
  58507. export * from "babylonjs/Meshes/index";
  58508. export * from "babylonjs/Morph/index";
  58509. export * from "babylonjs/node";
  58510. export * from "babylonjs/Offline/index";
  58511. export * from "babylonjs/Particles/index";
  58512. export * from "babylonjs/Physics/index";
  58513. export * from "babylonjs/PostProcesses/index";
  58514. export * from "babylonjs/Probes/index";
  58515. export * from "babylonjs/Rendering/index";
  58516. export * from "babylonjs/scene";
  58517. export * from "babylonjs/sceneComponent";
  58518. export * from "babylonjs/Sprites/index";
  58519. export * from "babylonjs/States/index";
  58520. export * from "babylonjs/Misc/index";
  58521. export * from "babylonjs/types";
  58522. }
  58523. declare module "babylonjs/Animations/pathCursor" {
  58524. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58525. /**
  58526. * A cursor which tracks a point on a path
  58527. */
  58528. export class PathCursor {
  58529. private path;
  58530. /**
  58531. * Stores path cursor callbacks for when an onchange event is triggered
  58532. */
  58533. private _onchange;
  58534. /**
  58535. * The value of the path cursor
  58536. */
  58537. value: number;
  58538. /**
  58539. * The animation array of the path cursor
  58540. */
  58541. animations: Animation[];
  58542. /**
  58543. * Initializes the path cursor
  58544. * @param path The path to track
  58545. */
  58546. constructor(path: Path2);
  58547. /**
  58548. * Gets the cursor point on the path
  58549. * @returns A point on the path cursor at the cursor location
  58550. */
  58551. getPoint(): Vector3;
  58552. /**
  58553. * Moves the cursor ahead by the step amount
  58554. * @param step The amount to move the cursor forward
  58555. * @returns This path cursor
  58556. */
  58557. moveAhead(step?: number): PathCursor;
  58558. /**
  58559. * Moves the cursor behind by the step amount
  58560. * @param step The amount to move the cursor back
  58561. * @returns This path cursor
  58562. */
  58563. moveBack(step?: number): PathCursor;
  58564. /**
  58565. * Moves the cursor by the step amount
  58566. * If the step amount is greater than one, an exception is thrown
  58567. * @param step The amount to move the cursor
  58568. * @returns This path cursor
  58569. */
  58570. move(step: number): PathCursor;
  58571. /**
  58572. * Ensures that the value is limited between zero and one
  58573. * @returns This path cursor
  58574. */
  58575. private ensureLimits;
  58576. /**
  58577. * Runs onchange callbacks on change (used by the animation engine)
  58578. * @returns This path cursor
  58579. */
  58580. private raiseOnChange;
  58581. /**
  58582. * Executes a function on change
  58583. * @param f A path cursor onchange callback
  58584. * @returns This path cursor
  58585. */
  58586. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58587. }
  58588. }
  58589. declare module "babylonjs/Legacy/legacy" {
  58590. import * as Babylon from "babylonjs/index";
  58591. export * from "babylonjs/index";
  58592. }
  58593. declare module "babylonjs/Shaders/blur.fragment" {
  58594. /** @hidden */
  58595. export var blurPixelShader: {
  58596. name: string;
  58597. shader: string;
  58598. };
  58599. }
  58600. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58601. /** @hidden */
  58602. export var bones300Declaration: {
  58603. name: string;
  58604. shader: string;
  58605. };
  58606. }
  58607. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58608. /** @hidden */
  58609. export var instances300Declaration: {
  58610. name: string;
  58611. shader: string;
  58612. };
  58613. }
  58614. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58615. /** @hidden */
  58616. export var pointCloudVertexDeclaration: {
  58617. name: string;
  58618. shader: string;
  58619. };
  58620. }
  58621. // Mixins
  58622. interface Window {
  58623. mozIndexedDB: IDBFactory;
  58624. webkitIndexedDB: IDBFactory;
  58625. msIndexedDB: IDBFactory;
  58626. webkitURL: typeof URL;
  58627. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58628. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58629. WebGLRenderingContext: WebGLRenderingContext;
  58630. MSGesture: MSGesture;
  58631. CANNON: any;
  58632. AudioContext: AudioContext;
  58633. webkitAudioContext: AudioContext;
  58634. PointerEvent: any;
  58635. Math: Math;
  58636. Uint8Array: Uint8ArrayConstructor;
  58637. Float32Array: Float32ArrayConstructor;
  58638. mozURL: typeof URL;
  58639. msURL: typeof URL;
  58640. VRFrameData: any; // WebVR, from specs 1.1
  58641. DracoDecoderModule: any;
  58642. setImmediate(handler: (...args: any[]) => void): number;
  58643. }
  58644. interface HTMLCanvasElement {
  58645. requestPointerLock(): void;
  58646. msRequestPointerLock?(): void;
  58647. mozRequestPointerLock?(): void;
  58648. webkitRequestPointerLock?(): void;
  58649. /** Track wether a record is in progress */
  58650. isRecording: boolean;
  58651. /** Capture Stream method defined by some browsers */
  58652. captureStream(fps?: number): MediaStream;
  58653. }
  58654. interface CanvasRenderingContext2D {
  58655. msImageSmoothingEnabled: boolean;
  58656. }
  58657. interface MouseEvent {
  58658. mozMovementX: number;
  58659. mozMovementY: number;
  58660. webkitMovementX: number;
  58661. webkitMovementY: number;
  58662. msMovementX: number;
  58663. msMovementY: number;
  58664. }
  58665. interface Navigator {
  58666. mozGetVRDevices: (any: any) => any;
  58667. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58668. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58669. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58670. webkitGetGamepads(): Gamepad[];
  58671. msGetGamepads(): Gamepad[];
  58672. webkitGamepads(): Gamepad[];
  58673. }
  58674. interface HTMLVideoElement {
  58675. mozSrcObject: any;
  58676. }
  58677. interface Math {
  58678. fround(x: number): number;
  58679. imul(a: number, b: number): number;
  58680. }
  58681. interface WebGLProgram {
  58682. context?: WebGLRenderingContext;
  58683. vertexShader?: WebGLShader;
  58684. fragmentShader?: WebGLShader;
  58685. isParallelCompiled: boolean;
  58686. onCompiled?: () => void;
  58687. }
  58688. interface WebGLRenderingContext {
  58689. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58690. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58691. vertexAttribDivisor(index: number, divisor: number): void;
  58692. createVertexArray(): any;
  58693. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58694. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58695. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58696. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58697. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58698. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58699. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58700. // Queries
  58701. createQuery(): WebGLQuery;
  58702. deleteQuery(query: WebGLQuery): void;
  58703. beginQuery(target: number, query: WebGLQuery): void;
  58704. endQuery(target: number): void;
  58705. getQueryParameter(query: WebGLQuery, pname: number): any;
  58706. getQuery(target: number, pname: number): any;
  58707. MAX_SAMPLES: number;
  58708. RGBA8: number;
  58709. READ_FRAMEBUFFER: number;
  58710. DRAW_FRAMEBUFFER: number;
  58711. UNIFORM_BUFFER: number;
  58712. HALF_FLOAT_OES: number;
  58713. RGBA16F: number;
  58714. RGBA32F: number;
  58715. R32F: number;
  58716. RG32F: number;
  58717. RGB32F: number;
  58718. R16F: number;
  58719. RG16F: number;
  58720. RGB16F: number;
  58721. RED: number;
  58722. RG: number;
  58723. R8: number;
  58724. RG8: number;
  58725. UNSIGNED_INT_24_8: number;
  58726. DEPTH24_STENCIL8: number;
  58727. /* Multiple Render Targets */
  58728. drawBuffers(buffers: number[]): void;
  58729. readBuffer(src: number): void;
  58730. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58731. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58732. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58733. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58734. // Occlusion Query
  58735. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58736. ANY_SAMPLES_PASSED: number;
  58737. QUERY_RESULT_AVAILABLE: number;
  58738. QUERY_RESULT: number;
  58739. }
  58740. interface WebGLBuffer {
  58741. references: number;
  58742. capacity: number;
  58743. is32Bits: boolean;
  58744. }
  58745. interface WebGLProgram {
  58746. transformFeedback?: WebGLTransformFeedback | null;
  58747. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58748. }
  58749. interface EXT_disjoint_timer_query {
  58750. QUERY_COUNTER_BITS_EXT: number;
  58751. TIME_ELAPSED_EXT: number;
  58752. TIMESTAMP_EXT: number;
  58753. GPU_DISJOINT_EXT: number;
  58754. QUERY_RESULT_EXT: number;
  58755. QUERY_RESULT_AVAILABLE_EXT: number;
  58756. queryCounterEXT(query: WebGLQuery, target: number): void;
  58757. createQueryEXT(): WebGLQuery;
  58758. beginQueryEXT(target: number, query: WebGLQuery): void;
  58759. endQueryEXT(target: number): void;
  58760. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58761. deleteQueryEXT(query: WebGLQuery): void;
  58762. }
  58763. interface WebGLUniformLocation {
  58764. _currentState: any;
  58765. }
  58766. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58767. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58768. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58769. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58770. interface WebGLRenderingContext {
  58771. readonly RASTERIZER_DISCARD: number;
  58772. readonly DEPTH_COMPONENT24: number;
  58773. readonly TEXTURE_3D: number;
  58774. readonly TEXTURE_2D_ARRAY: number;
  58775. readonly TEXTURE_COMPARE_FUNC: number;
  58776. readonly TEXTURE_COMPARE_MODE: number;
  58777. readonly COMPARE_REF_TO_TEXTURE: number;
  58778. readonly TEXTURE_WRAP_R: number;
  58779. readonly HALF_FLOAT: number;
  58780. readonly RGB8: number;
  58781. readonly RED_INTEGER: number;
  58782. readonly RG_INTEGER: number;
  58783. readonly RGB_INTEGER: number;
  58784. readonly RGBA_INTEGER: number;
  58785. readonly R8_SNORM: number;
  58786. readonly RG8_SNORM: number;
  58787. readonly RGB8_SNORM: number;
  58788. readonly RGBA8_SNORM: number;
  58789. readonly R8I: number;
  58790. readonly RG8I: number;
  58791. readonly RGB8I: number;
  58792. readonly RGBA8I: number;
  58793. readonly R8UI: number;
  58794. readonly RG8UI: number;
  58795. readonly RGB8UI: number;
  58796. readonly RGBA8UI: number;
  58797. readonly R16I: number;
  58798. readonly RG16I: number;
  58799. readonly RGB16I: number;
  58800. readonly RGBA16I: number;
  58801. readonly R16UI: number;
  58802. readonly RG16UI: number;
  58803. readonly RGB16UI: number;
  58804. readonly RGBA16UI: number;
  58805. readonly R32I: number;
  58806. readonly RG32I: number;
  58807. readonly RGB32I: number;
  58808. readonly RGBA32I: number;
  58809. readonly R32UI: number;
  58810. readonly RG32UI: number;
  58811. readonly RGB32UI: number;
  58812. readonly RGBA32UI: number;
  58813. readonly RGB10_A2UI: number;
  58814. readonly R11F_G11F_B10F: number;
  58815. readonly RGB9_E5: number;
  58816. readonly RGB10_A2: number;
  58817. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58818. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58819. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58820. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58821. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58822. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58823. 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;
  58824. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58825. readonly TRANSFORM_FEEDBACK: number;
  58826. readonly INTERLEAVED_ATTRIBS: number;
  58827. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58828. createTransformFeedback(): WebGLTransformFeedback;
  58829. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58830. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58831. beginTransformFeedback(primitiveMode: number): void;
  58832. endTransformFeedback(): void;
  58833. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58834. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58835. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58836. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58837. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58838. }
  58839. interface ImageBitmap {
  58840. readonly width: number;
  58841. readonly height: number;
  58842. close(): void;
  58843. }
  58844. interface WebGLQuery extends WebGLObject {
  58845. }
  58846. declare var WebGLQuery: {
  58847. prototype: WebGLQuery;
  58848. new(): WebGLQuery;
  58849. };
  58850. interface WebGLSampler extends WebGLObject {
  58851. }
  58852. declare var WebGLSampler: {
  58853. prototype: WebGLSampler;
  58854. new(): WebGLSampler;
  58855. };
  58856. interface WebGLSync extends WebGLObject {
  58857. }
  58858. declare var WebGLSync: {
  58859. prototype: WebGLSync;
  58860. new(): WebGLSync;
  58861. };
  58862. interface WebGLTransformFeedback extends WebGLObject {
  58863. }
  58864. declare var WebGLTransformFeedback: {
  58865. prototype: WebGLTransformFeedback;
  58866. new(): WebGLTransformFeedback;
  58867. };
  58868. interface WebGLVertexArrayObject extends WebGLObject {
  58869. }
  58870. declare var WebGLVertexArrayObject: {
  58871. prototype: WebGLVertexArrayObject;
  58872. new(): WebGLVertexArrayObject;
  58873. };
  58874. // Type definitions for WebVR API
  58875. // Project: https://w3c.github.io/webvr/
  58876. // Definitions by: six a <https://github.com/lostfictions>
  58877. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58878. interface VRDisplay extends EventTarget {
  58879. /**
  58880. * Dictionary of capabilities describing the VRDisplay.
  58881. */
  58882. readonly capabilities: VRDisplayCapabilities;
  58883. /**
  58884. * z-depth defining the far plane of the eye view frustum
  58885. * enables mapping of values in the render target depth
  58886. * attachment to scene coordinates. Initially set to 10000.0.
  58887. */
  58888. depthFar: number;
  58889. /**
  58890. * z-depth defining the near plane of the eye view frustum
  58891. * enables mapping of values in the render target depth
  58892. * attachment to scene coordinates. Initially set to 0.01.
  58893. */
  58894. depthNear: number;
  58895. /**
  58896. * An identifier for this distinct VRDisplay. Used as an
  58897. * association point in the Gamepad API.
  58898. */
  58899. readonly displayId: number;
  58900. /**
  58901. * A display name, a user-readable name identifying it.
  58902. */
  58903. readonly displayName: string;
  58904. readonly isConnected: boolean;
  58905. readonly isPresenting: boolean;
  58906. /**
  58907. * If this VRDisplay supports room-scale experiences, the optional
  58908. * stage attribute contains details on the room-scale parameters.
  58909. */
  58910. readonly stageParameters: VRStageParameters | null;
  58911. /**
  58912. * Passing the value returned by `requestAnimationFrame` to
  58913. * `cancelAnimationFrame` will unregister the callback.
  58914. * @param handle Define the hanle of the request to cancel
  58915. */
  58916. cancelAnimationFrame(handle: number): void;
  58917. /**
  58918. * Stops presenting to the VRDisplay.
  58919. * @returns a promise to know when it stopped
  58920. */
  58921. exitPresent(): Promise<void>;
  58922. /**
  58923. * Return the current VREyeParameters for the given eye.
  58924. * @param whichEye Define the eye we want the parameter for
  58925. * @returns the eye parameters
  58926. */
  58927. getEyeParameters(whichEye: string): VREyeParameters;
  58928. /**
  58929. * Populates the passed VRFrameData with the information required to render
  58930. * the current frame.
  58931. * @param frameData Define the data structure to populate
  58932. * @returns true if ok otherwise false
  58933. */
  58934. getFrameData(frameData: VRFrameData): boolean;
  58935. /**
  58936. * Get the layers currently being presented.
  58937. * @returns the list of VR layers
  58938. */
  58939. getLayers(): VRLayer[];
  58940. /**
  58941. * Return a VRPose containing the future predicted pose of the VRDisplay
  58942. * when the current frame will be presented. The value returned will not
  58943. * change until JavaScript has returned control to the browser.
  58944. *
  58945. * The VRPose will contain the position, orientation, velocity,
  58946. * and acceleration of each of these properties.
  58947. * @returns the pose object
  58948. */
  58949. getPose(): VRPose;
  58950. /**
  58951. * Return the current instantaneous pose of the VRDisplay, with no
  58952. * prediction applied.
  58953. * @returns the current instantaneous pose
  58954. */
  58955. getImmediatePose(): VRPose;
  58956. /**
  58957. * The callback passed to `requestAnimationFrame` will be called
  58958. * any time a new frame should be rendered. When the VRDisplay is
  58959. * presenting the callback will be called at the native refresh
  58960. * rate of the HMD. When not presenting this function acts
  58961. * identically to how window.requestAnimationFrame acts. Content should
  58962. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58963. * asynchronously from other displays and at differing refresh rates.
  58964. * @param callback Define the eaction to run next frame
  58965. * @returns the request handle it
  58966. */
  58967. requestAnimationFrame(callback: FrameRequestCallback): number;
  58968. /**
  58969. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58970. * Repeat calls while already presenting will update the VRLayers being displayed.
  58971. * @param layers Define the list of layer to present
  58972. * @returns a promise to know when the request has been fulfilled
  58973. */
  58974. requestPresent(layers: VRLayer[]): Promise<void>;
  58975. /**
  58976. * Reset the pose for this display, treating its current position and
  58977. * orientation as the "origin/zero" values. VRPose.position,
  58978. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58979. * updated when calling resetPose(). This should be called in only
  58980. * sitting-space experiences.
  58981. */
  58982. resetPose(): void;
  58983. /**
  58984. * The VRLayer provided to the VRDisplay will be captured and presented
  58985. * in the HMD. Calling this function has the same effect on the source
  58986. * canvas as any other operation that uses its source image, and canvases
  58987. * created without preserveDrawingBuffer set to true will be cleared.
  58988. * @param pose Define the pose to submit
  58989. */
  58990. submitFrame(pose?: VRPose): void;
  58991. }
  58992. declare var VRDisplay: {
  58993. prototype: VRDisplay;
  58994. new(): VRDisplay;
  58995. };
  58996. interface VRLayer {
  58997. leftBounds?: number[] | Float32Array | null;
  58998. rightBounds?: number[] | Float32Array | null;
  58999. source?: HTMLCanvasElement | null;
  59000. }
  59001. interface VRDisplayCapabilities {
  59002. readonly canPresent: boolean;
  59003. readonly hasExternalDisplay: boolean;
  59004. readonly hasOrientation: boolean;
  59005. readonly hasPosition: boolean;
  59006. readonly maxLayers: number;
  59007. }
  59008. interface VREyeParameters {
  59009. /** @deprecated */
  59010. readonly fieldOfView: VRFieldOfView;
  59011. readonly offset: Float32Array;
  59012. readonly renderHeight: number;
  59013. readonly renderWidth: number;
  59014. }
  59015. interface VRFieldOfView {
  59016. readonly downDegrees: number;
  59017. readonly leftDegrees: number;
  59018. readonly rightDegrees: number;
  59019. readonly upDegrees: number;
  59020. }
  59021. interface VRFrameData {
  59022. readonly leftProjectionMatrix: Float32Array;
  59023. readonly leftViewMatrix: Float32Array;
  59024. readonly pose: VRPose;
  59025. readonly rightProjectionMatrix: Float32Array;
  59026. readonly rightViewMatrix: Float32Array;
  59027. readonly timestamp: number;
  59028. }
  59029. interface VRPose {
  59030. readonly angularAcceleration: Float32Array | null;
  59031. readonly angularVelocity: Float32Array | null;
  59032. readonly linearAcceleration: Float32Array | null;
  59033. readonly linearVelocity: Float32Array | null;
  59034. readonly orientation: Float32Array | null;
  59035. readonly position: Float32Array | null;
  59036. readonly timestamp: number;
  59037. }
  59038. interface VRStageParameters {
  59039. sittingToStandingTransform?: Float32Array;
  59040. sizeX?: number;
  59041. sizeY?: number;
  59042. }
  59043. interface Navigator {
  59044. getVRDisplays(): Promise<VRDisplay[]>;
  59045. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59046. }
  59047. interface Window {
  59048. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59049. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59050. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59051. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59052. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59053. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59054. }
  59055. interface Gamepad {
  59056. readonly displayId: number;
  59057. }
  59058. interface XRDevice {
  59059. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59060. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59061. }
  59062. interface XRSession {
  59063. getInputSources(): Array<any>;
  59064. baseLayer: XRWebGLLayer;
  59065. requestFrameOfReference(type: string): Promise<void>;
  59066. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59067. end(): Promise<void>;
  59068. requestAnimationFrame: Function;
  59069. addEventListener: Function;
  59070. }
  59071. interface XRSessionCreationOptions {
  59072. outputContext?: WebGLRenderingContext | null;
  59073. immersive?: boolean;
  59074. environmentIntegration?: boolean;
  59075. }
  59076. interface XRLayer {
  59077. getViewport: Function;
  59078. framebufferWidth: number;
  59079. framebufferHeight: number;
  59080. }
  59081. interface XRView {
  59082. projectionMatrix: Float32Array;
  59083. }
  59084. interface XRFrame {
  59085. getDevicePose: Function;
  59086. getInputPose: Function;
  59087. views: Array<XRView>;
  59088. baseLayer: XRLayer;
  59089. }
  59090. interface XRFrameOfReference {
  59091. }
  59092. interface XRWebGLLayer extends XRLayer {
  59093. framebuffer: WebGLFramebuffer;
  59094. }
  59095. declare var XRWebGLLayer: {
  59096. prototype: XRWebGLLayer;
  59097. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59098. };
  59099. declare module "babylonjs" {
  59100. export * from "babylonjs/Legacy/legacy";
  59101. }
  59102. declare module BABYLON {
  59103. /** Alias type for value that can be null */
  59104. export type Nullable<T> = T | null;
  59105. /**
  59106. * Alias type for number that are floats
  59107. * @ignorenaming
  59108. */
  59109. export type float = number;
  59110. /**
  59111. * Alias type for number that are doubles.
  59112. * @ignorenaming
  59113. */
  59114. export type double = number;
  59115. /**
  59116. * Alias type for number that are integer
  59117. * @ignorenaming
  59118. */
  59119. export type int = number;
  59120. /** Alias type for number array or Float32Array */
  59121. export type FloatArray = number[] | Float32Array;
  59122. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59123. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59124. /**
  59125. * Alias for types that can be used by a Buffer or VertexBuffer.
  59126. */
  59127. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59128. /**
  59129. * Alias type for primitive types
  59130. * @ignorenaming
  59131. */
  59132. type Primitive = undefined | null | boolean | string | number | Function;
  59133. /**
  59134. * Type modifier to make all the properties of an object Readonly
  59135. */
  59136. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59137. /**
  59138. * Type modifier to make all the properties of an object Readonly recursively
  59139. */
  59140. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59141. /** @hidden */
  59142. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59143. }
  59144. /** @hidden */
  59145. /** @hidden */
  59146. type DeepImmutableObject<T> = {
  59147. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59148. };
  59149. }
  59150. declare module BABYLON {
  59151. /**
  59152. * Class containing a set of static utilities functions for arrays.
  59153. */
  59154. export class ArrayTools {
  59155. /**
  59156. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59157. * @param size the number of element to construct and put in the array
  59158. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59159. * @returns a new array filled with new objects
  59160. */
  59161. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59162. }
  59163. }
  59164. declare module BABYLON {
  59165. /**
  59166. * Scalar computation library
  59167. */
  59168. export class Scalar {
  59169. /**
  59170. * Two pi constants convenient for computation.
  59171. */
  59172. static TwoPi: number;
  59173. /**
  59174. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59175. * @param a number
  59176. * @param b number
  59177. * @param epsilon (default = 1.401298E-45)
  59178. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59179. */
  59180. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59181. /**
  59182. * Returns a string : the upper case translation of the number i to hexadecimal.
  59183. * @param i number
  59184. * @returns the upper case translation of the number i to hexadecimal.
  59185. */
  59186. static ToHex(i: number): string;
  59187. /**
  59188. * Returns -1 if value is negative and +1 is value is positive.
  59189. * @param value the value
  59190. * @returns the value itself if it's equal to zero.
  59191. */
  59192. static Sign(value: number): number;
  59193. /**
  59194. * Returns the value itself if it's between min and max.
  59195. * Returns min if the value is lower than min.
  59196. * Returns max if the value is greater than max.
  59197. * @param value the value to clmap
  59198. * @param min the min value to clamp to (default: 0)
  59199. * @param max the max value to clamp to (default: 1)
  59200. * @returns the clamped value
  59201. */
  59202. static Clamp(value: number, min?: number, max?: number): number;
  59203. /**
  59204. * the log2 of value.
  59205. * @param value the value to compute log2 of
  59206. * @returns the log2 of value.
  59207. */
  59208. static Log2(value: number): number;
  59209. /**
  59210. * Loops the value, so that it is never larger than length and never smaller than 0.
  59211. *
  59212. * This is similar to the modulo operator but it works with floating point numbers.
  59213. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59214. * With t = 5 and length = 2.5, the result would be 0.0.
  59215. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59216. * @param value the value
  59217. * @param length the length
  59218. * @returns the looped value
  59219. */
  59220. static Repeat(value: number, length: number): number;
  59221. /**
  59222. * Normalize the value between 0.0 and 1.0 using min and max values
  59223. * @param value value to normalize
  59224. * @param min max to normalize between
  59225. * @param max min to normalize between
  59226. * @returns the normalized value
  59227. */
  59228. static Normalize(value: number, min: number, max: number): number;
  59229. /**
  59230. * Denormalize the value from 0.0 and 1.0 using min and max values
  59231. * @param normalized value to denormalize
  59232. * @param min max to denormalize between
  59233. * @param max min to denormalize between
  59234. * @returns the denormalized value
  59235. */
  59236. static Denormalize(normalized: number, min: number, max: number): number;
  59237. /**
  59238. * Calculates the shortest difference between two given angles given in degrees.
  59239. * @param current current angle in degrees
  59240. * @param target target angle in degrees
  59241. * @returns the delta
  59242. */
  59243. static DeltaAngle(current: number, target: number): number;
  59244. /**
  59245. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59246. * @param tx value
  59247. * @param length length
  59248. * @returns The returned value will move back and forth between 0 and length
  59249. */
  59250. static PingPong(tx: number, length: number): number;
  59251. /**
  59252. * Interpolates between min and max with smoothing at the limits.
  59253. *
  59254. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59255. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59256. * @param from from
  59257. * @param to to
  59258. * @param tx value
  59259. * @returns the smooth stepped value
  59260. */
  59261. static SmoothStep(from: number, to: number, tx: number): number;
  59262. /**
  59263. * Moves a value current towards target.
  59264. *
  59265. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59266. * Negative values of maxDelta pushes the value away from target.
  59267. * @param current current value
  59268. * @param target target value
  59269. * @param maxDelta max distance to move
  59270. * @returns resulting value
  59271. */
  59272. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59273. /**
  59274. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59275. *
  59276. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59277. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59278. * @param current current value
  59279. * @param target target value
  59280. * @param maxDelta max distance to move
  59281. * @returns resulting angle
  59282. */
  59283. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59284. /**
  59285. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59286. * @param start start value
  59287. * @param end target value
  59288. * @param amount amount to lerp between
  59289. * @returns the lerped value
  59290. */
  59291. static Lerp(start: number, end: number, amount: number): number;
  59292. /**
  59293. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59294. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59295. * @param start start value
  59296. * @param end target value
  59297. * @param amount amount to lerp between
  59298. * @returns the lerped value
  59299. */
  59300. static LerpAngle(start: number, end: number, amount: number): number;
  59301. /**
  59302. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59303. * @param a start value
  59304. * @param b target value
  59305. * @param value value between a and b
  59306. * @returns the inverseLerp value
  59307. */
  59308. static InverseLerp(a: number, b: number, value: number): number;
  59309. /**
  59310. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59311. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59312. * @param value1 spline value
  59313. * @param tangent1 spline value
  59314. * @param value2 spline value
  59315. * @param tangent2 spline value
  59316. * @param amount input value
  59317. * @returns hermite result
  59318. */
  59319. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59320. /**
  59321. * Returns a random float number between and min and max values
  59322. * @param min min value of random
  59323. * @param max max value of random
  59324. * @returns random value
  59325. */
  59326. static RandomRange(min: number, max: number): number;
  59327. /**
  59328. * This function returns percentage of a number in a given range.
  59329. *
  59330. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59331. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59332. * @param number to convert to percentage
  59333. * @param min min range
  59334. * @param max max range
  59335. * @returns the percentage
  59336. */
  59337. static RangeToPercent(number: number, min: number, max: number): number;
  59338. /**
  59339. * This function returns number that corresponds to the percentage in a given range.
  59340. *
  59341. * PercentToRange(0.34,0,100) will return 34.
  59342. * @param percent to convert to number
  59343. * @param min min range
  59344. * @param max max range
  59345. * @returns the number
  59346. */
  59347. static PercentToRange(percent: number, min: number, max: number): number;
  59348. /**
  59349. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59350. * @param angle The angle to normalize in radian.
  59351. * @return The converted angle.
  59352. */
  59353. static NormalizeRadians(angle: number): number;
  59354. }
  59355. }
  59356. declare module BABYLON {
  59357. /**
  59358. * Constant used to convert a value to gamma space
  59359. * @ignorenaming
  59360. */
  59361. export const ToGammaSpace: number;
  59362. /**
  59363. * Constant used to convert a value to linear space
  59364. * @ignorenaming
  59365. */
  59366. export const ToLinearSpace = 2.2;
  59367. /**
  59368. * Constant used to define the minimal number value in Babylon.js
  59369. * @ignorenaming
  59370. */
  59371. export const Epsilon = 0.001;
  59372. /**
  59373. * Class used to hold a RBG color
  59374. */
  59375. export class Color3 {
  59376. /**
  59377. * Defines the red component (between 0 and 1, default is 0)
  59378. */
  59379. r: number;
  59380. /**
  59381. * Defines the green component (between 0 and 1, default is 0)
  59382. */
  59383. g: number;
  59384. /**
  59385. * Defines the blue component (between 0 and 1, default is 0)
  59386. */
  59387. b: number;
  59388. /**
  59389. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59390. * @param r defines the red component (between 0 and 1, default is 0)
  59391. * @param g defines the green component (between 0 and 1, default is 0)
  59392. * @param b defines the blue component (between 0 and 1, default is 0)
  59393. */
  59394. constructor(
  59395. /**
  59396. * Defines the red component (between 0 and 1, default is 0)
  59397. */
  59398. r?: number,
  59399. /**
  59400. * Defines the green component (between 0 and 1, default is 0)
  59401. */
  59402. g?: number,
  59403. /**
  59404. * Defines the blue component (between 0 and 1, default is 0)
  59405. */
  59406. b?: number);
  59407. /**
  59408. * Creates a string with the Color3 current values
  59409. * @returns the string representation of the Color3 object
  59410. */
  59411. toString(): string;
  59412. /**
  59413. * Returns the string "Color3"
  59414. * @returns "Color3"
  59415. */
  59416. getClassName(): string;
  59417. /**
  59418. * Compute the Color3 hash code
  59419. * @returns an unique number that can be used to hash Color3 objects
  59420. */
  59421. getHashCode(): number;
  59422. /**
  59423. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59424. * @param array defines the array where to store the r,g,b components
  59425. * @param index defines an optional index in the target array to define where to start storing values
  59426. * @returns the current Color3 object
  59427. */
  59428. toArray(array: FloatArray, index?: number): Color3;
  59429. /**
  59430. * Returns a new Color4 object from the current Color3 and the given alpha
  59431. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59432. * @returns a new Color4 object
  59433. */
  59434. toColor4(alpha?: number): Color4;
  59435. /**
  59436. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59437. * @returns the new array
  59438. */
  59439. asArray(): number[];
  59440. /**
  59441. * Returns the luminance value
  59442. * @returns a float value
  59443. */
  59444. toLuminance(): number;
  59445. /**
  59446. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59447. * @param otherColor defines the second operand
  59448. * @returns the new Color3 object
  59449. */
  59450. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59451. /**
  59452. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59453. * @param otherColor defines the second operand
  59454. * @param result defines the Color3 object where to store the result
  59455. * @returns the current Color3
  59456. */
  59457. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59458. /**
  59459. * Determines equality between Color3 objects
  59460. * @param otherColor defines the second operand
  59461. * @returns true if the rgb values are equal to the given ones
  59462. */
  59463. equals(otherColor: DeepImmutable<Color3>): boolean;
  59464. /**
  59465. * Determines equality between the current Color3 object and a set of r,b,g values
  59466. * @param r defines the red component to check
  59467. * @param g defines the green component to check
  59468. * @param b defines the blue component to check
  59469. * @returns true if the rgb values are equal to the given ones
  59470. */
  59471. equalsFloats(r: number, g: number, b: number): boolean;
  59472. /**
  59473. * Multiplies in place each rgb value by scale
  59474. * @param scale defines the scaling factor
  59475. * @returns the updated Color3
  59476. */
  59477. scale(scale: number): Color3;
  59478. /**
  59479. * Multiplies the rgb values by scale and stores the result into "result"
  59480. * @param scale defines the scaling factor
  59481. * @param result defines the Color3 object where to store the result
  59482. * @returns the unmodified current Color3
  59483. */
  59484. scaleToRef(scale: number, result: Color3): Color3;
  59485. /**
  59486. * Scale the current Color3 values by a factor and add the result to a given Color3
  59487. * @param scale defines the scale factor
  59488. * @param result defines color to store the result into
  59489. * @returns the unmodified current Color3
  59490. */
  59491. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59492. /**
  59493. * Clamps the rgb values by the min and max values and stores the result into "result"
  59494. * @param min defines minimum clamping value (default is 0)
  59495. * @param max defines maximum clamping value (default is 1)
  59496. * @param result defines color to store the result into
  59497. * @returns the original Color3
  59498. */
  59499. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59500. /**
  59501. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59502. * @param otherColor defines the second operand
  59503. * @returns the new Color3
  59504. */
  59505. add(otherColor: DeepImmutable<Color3>): Color3;
  59506. /**
  59507. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59508. * @param otherColor defines the second operand
  59509. * @param result defines Color3 object to store the result into
  59510. * @returns the unmodified current Color3
  59511. */
  59512. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59513. /**
  59514. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59515. * @param otherColor defines the second operand
  59516. * @returns the new Color3
  59517. */
  59518. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59519. /**
  59520. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59521. * @param otherColor defines the second operand
  59522. * @param result defines Color3 object to store the result into
  59523. * @returns the unmodified current Color3
  59524. */
  59525. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59526. /**
  59527. * Copy the current object
  59528. * @returns a new Color3 copied the current one
  59529. */
  59530. clone(): Color3;
  59531. /**
  59532. * Copies the rgb values from the source in the current Color3
  59533. * @param source defines the source Color3 object
  59534. * @returns the updated Color3 object
  59535. */
  59536. copyFrom(source: DeepImmutable<Color3>): Color3;
  59537. /**
  59538. * Updates the Color3 rgb values from the given floats
  59539. * @param r defines the red component to read from
  59540. * @param g defines the green component to read from
  59541. * @param b defines the blue component to read from
  59542. * @returns the current Color3 object
  59543. */
  59544. copyFromFloats(r: number, g: number, b: number): Color3;
  59545. /**
  59546. * Updates the Color3 rgb values from the given floats
  59547. * @param r defines the red component to read from
  59548. * @param g defines the green component to read from
  59549. * @param b defines the blue component to read from
  59550. * @returns the current Color3 object
  59551. */
  59552. set(r: number, g: number, b: number): Color3;
  59553. /**
  59554. * Compute the Color3 hexadecimal code as a string
  59555. * @returns a string containing the hexadecimal representation of the Color3 object
  59556. */
  59557. toHexString(): string;
  59558. /**
  59559. * Computes a new Color3 converted from the current one to linear space
  59560. * @returns a new Color3 object
  59561. */
  59562. toLinearSpace(): Color3;
  59563. /**
  59564. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59565. * @param convertedColor defines the Color3 object where to store the linear space version
  59566. * @returns the unmodified Color3
  59567. */
  59568. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59569. /**
  59570. * Computes a new Color3 converted from the current one to gamma space
  59571. * @returns a new Color3 object
  59572. */
  59573. toGammaSpace(): Color3;
  59574. /**
  59575. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59576. * @param convertedColor defines the Color3 object where to store the gamma space version
  59577. * @returns the unmodified Color3
  59578. */
  59579. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59580. private static _BlackReadOnly;
  59581. /**
  59582. * Creates a new Color3 from the string containing valid hexadecimal values
  59583. * @param hex defines a string containing valid hexadecimal values
  59584. * @returns a new Color3 object
  59585. */
  59586. static FromHexString(hex: string): Color3;
  59587. /**
  59588. * Creates a new Vector3 from the starting index of the given array
  59589. * @param array defines the source array
  59590. * @param offset defines an offset in the source array
  59591. * @returns a new Color3 object
  59592. */
  59593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59594. /**
  59595. * Creates a new Color3 from integer values (< 256)
  59596. * @param r defines the red component to read from (value between 0 and 255)
  59597. * @param g defines the green component to read from (value between 0 and 255)
  59598. * @param b defines the blue component to read from (value between 0 and 255)
  59599. * @returns a new Color3 object
  59600. */
  59601. static FromInts(r: number, g: number, b: number): Color3;
  59602. /**
  59603. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59604. * @param start defines the start Color3 value
  59605. * @param end defines the end Color3 value
  59606. * @param amount defines the gradient value between start and end
  59607. * @returns a new Color3 object
  59608. */
  59609. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59610. /**
  59611. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59612. * @param left defines the start value
  59613. * @param right defines the end value
  59614. * @param amount defines the gradient factor
  59615. * @param result defines the Color3 object where to store the result
  59616. */
  59617. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59618. /**
  59619. * Returns a Color3 value containing a red color
  59620. * @returns a new Color3 object
  59621. */
  59622. static Red(): Color3;
  59623. /**
  59624. * Returns a Color3 value containing a green color
  59625. * @returns a new Color3 object
  59626. */
  59627. static Green(): Color3;
  59628. /**
  59629. * Returns a Color3 value containing a blue color
  59630. * @returns a new Color3 object
  59631. */
  59632. static Blue(): Color3;
  59633. /**
  59634. * Returns a Color3 value containing a black color
  59635. * @returns a new Color3 object
  59636. */
  59637. static Black(): Color3;
  59638. /**
  59639. * Gets a Color3 value containing a black color that must not be updated
  59640. */
  59641. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59642. /**
  59643. * Returns a Color3 value containing a white color
  59644. * @returns a new Color3 object
  59645. */
  59646. static White(): Color3;
  59647. /**
  59648. * Returns a Color3 value containing a purple color
  59649. * @returns a new Color3 object
  59650. */
  59651. static Purple(): Color3;
  59652. /**
  59653. * Returns a Color3 value containing a magenta color
  59654. * @returns a new Color3 object
  59655. */
  59656. static Magenta(): Color3;
  59657. /**
  59658. * Returns a Color3 value containing a yellow color
  59659. * @returns a new Color3 object
  59660. */
  59661. static Yellow(): Color3;
  59662. /**
  59663. * Returns a Color3 value containing a gray color
  59664. * @returns a new Color3 object
  59665. */
  59666. static Gray(): Color3;
  59667. /**
  59668. * Returns a Color3 value containing a teal color
  59669. * @returns a new Color3 object
  59670. */
  59671. static Teal(): Color3;
  59672. /**
  59673. * Returns a Color3 value containing a random color
  59674. * @returns a new Color3 object
  59675. */
  59676. static Random(): Color3;
  59677. }
  59678. /**
  59679. * Class used to hold a RBGA color
  59680. */
  59681. export class Color4 {
  59682. /**
  59683. * Defines the red component (between 0 and 1, default is 0)
  59684. */
  59685. r: number;
  59686. /**
  59687. * Defines the green component (between 0 and 1, default is 0)
  59688. */
  59689. g: number;
  59690. /**
  59691. * Defines the blue component (between 0 and 1, default is 0)
  59692. */
  59693. b: number;
  59694. /**
  59695. * Defines the alpha component (between 0 and 1, default is 1)
  59696. */
  59697. a: number;
  59698. /**
  59699. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59700. * @param r defines the red component (between 0 and 1, default is 0)
  59701. * @param g defines the green component (between 0 and 1, default is 0)
  59702. * @param b defines the blue component (between 0 and 1, default is 0)
  59703. * @param a defines the alpha component (between 0 and 1, default is 1)
  59704. */
  59705. constructor(
  59706. /**
  59707. * Defines the red component (between 0 and 1, default is 0)
  59708. */
  59709. r?: number,
  59710. /**
  59711. * Defines the green component (between 0 and 1, default is 0)
  59712. */
  59713. g?: number,
  59714. /**
  59715. * Defines the blue component (between 0 and 1, default is 0)
  59716. */
  59717. b?: number,
  59718. /**
  59719. * Defines the alpha component (between 0 and 1, default is 1)
  59720. */
  59721. a?: number);
  59722. /**
  59723. * Adds in place the given Color4 values to the current Color4 object
  59724. * @param right defines the second operand
  59725. * @returns the current updated Color4 object
  59726. */
  59727. addInPlace(right: DeepImmutable<Color4>): Color4;
  59728. /**
  59729. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59730. * @returns the new array
  59731. */
  59732. asArray(): number[];
  59733. /**
  59734. * Stores from the starting index in the given array the Color4 successive values
  59735. * @param array defines the array where to store the r,g,b components
  59736. * @param index defines an optional index in the target array to define where to start storing values
  59737. * @returns the current Color4 object
  59738. */
  59739. toArray(array: number[], index?: number): Color4;
  59740. /**
  59741. * Determines equality between Color4 objects
  59742. * @param otherColor defines the second operand
  59743. * @returns true if the rgba values are equal to the given ones
  59744. */
  59745. equals(otherColor: DeepImmutable<Color4>): boolean;
  59746. /**
  59747. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59748. * @param right defines the second operand
  59749. * @returns a new Color4 object
  59750. */
  59751. add(right: DeepImmutable<Color4>): Color4;
  59752. /**
  59753. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59754. * @param right defines the second operand
  59755. * @returns a new Color4 object
  59756. */
  59757. subtract(right: DeepImmutable<Color4>): Color4;
  59758. /**
  59759. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59760. * @param right defines the second operand
  59761. * @param result defines the Color4 object where to store the result
  59762. * @returns the current Color4 object
  59763. */
  59764. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59765. /**
  59766. * Creates a new Color4 with the current Color4 values multiplied by scale
  59767. * @param scale defines the scaling factor to apply
  59768. * @returns a new Color4 object
  59769. */
  59770. scale(scale: number): Color4;
  59771. /**
  59772. * Multiplies the current Color4 values by scale and stores the result in "result"
  59773. * @param scale defines the scaling factor to apply
  59774. * @param result defines the Color4 object where to store the result
  59775. * @returns the current unmodified Color4
  59776. */
  59777. scaleToRef(scale: number, result: Color4): Color4;
  59778. /**
  59779. * Scale the current Color4 values by a factor and add the result to a given Color4
  59780. * @param scale defines the scale factor
  59781. * @param result defines the Color4 object where to store the result
  59782. * @returns the unmodified current Color4
  59783. */
  59784. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59785. /**
  59786. * Clamps the rgb values by the min and max values and stores the result into "result"
  59787. * @param min defines minimum clamping value (default is 0)
  59788. * @param max defines maximum clamping value (default is 1)
  59789. * @param result defines color to store the result into.
  59790. * @returns the cuurent Color4
  59791. */
  59792. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59793. /**
  59794. * Multipy an Color4 value by another and return a new Color4 object
  59795. * @param color defines the Color4 value to multiply by
  59796. * @returns a new Color4 object
  59797. */
  59798. multiply(color: Color4): Color4;
  59799. /**
  59800. * Multipy a Color4 value by another and push the result in a reference value
  59801. * @param color defines the Color4 value to multiply by
  59802. * @param result defines the Color4 to fill the result in
  59803. * @returns the result Color4
  59804. */
  59805. multiplyToRef(color: Color4, result: Color4): Color4;
  59806. /**
  59807. * Creates a string with the Color4 current values
  59808. * @returns the string representation of the Color4 object
  59809. */
  59810. toString(): string;
  59811. /**
  59812. * Returns the string "Color4"
  59813. * @returns "Color4"
  59814. */
  59815. getClassName(): string;
  59816. /**
  59817. * Compute the Color4 hash code
  59818. * @returns an unique number that can be used to hash Color4 objects
  59819. */
  59820. getHashCode(): number;
  59821. /**
  59822. * Creates a new Color4 copied from the current one
  59823. * @returns a new Color4 object
  59824. */
  59825. clone(): Color4;
  59826. /**
  59827. * Copies the given Color4 values into the current one
  59828. * @param source defines the source Color4 object
  59829. * @returns the current updated Color4 object
  59830. */
  59831. copyFrom(source: Color4): Color4;
  59832. /**
  59833. * Copies the given float values into the current one
  59834. * @param r defines the red component to read from
  59835. * @param g defines the green component to read from
  59836. * @param b defines the blue component to read from
  59837. * @param a defines the alpha component to read from
  59838. * @returns the current updated Color4 object
  59839. */
  59840. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59841. /**
  59842. * Copies the given float values into the current one
  59843. * @param r defines the red component to read from
  59844. * @param g defines the green component to read from
  59845. * @param b defines the blue component to read from
  59846. * @param a defines the alpha component to read from
  59847. * @returns the current updated Color4 object
  59848. */
  59849. set(r: number, g: number, b: number, a: number): Color4;
  59850. /**
  59851. * Compute the Color4 hexadecimal code as a string
  59852. * @returns a string containing the hexadecimal representation of the Color4 object
  59853. */
  59854. toHexString(): string;
  59855. /**
  59856. * Computes a new Color4 converted from the current one to linear space
  59857. * @returns a new Color4 object
  59858. */
  59859. toLinearSpace(): Color4;
  59860. /**
  59861. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59862. * @param convertedColor defines the Color4 object where to store the linear space version
  59863. * @returns the unmodified Color4
  59864. */
  59865. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59866. /**
  59867. * Computes a new Color4 converted from the current one to gamma space
  59868. * @returns a new Color4 object
  59869. */
  59870. toGammaSpace(): Color4;
  59871. /**
  59872. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59873. * @param convertedColor defines the Color4 object where to store the gamma space version
  59874. * @returns the unmodified Color4
  59875. */
  59876. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59877. /**
  59878. * Creates a new Color4 from the string containing valid hexadecimal values
  59879. * @param hex defines a string containing valid hexadecimal values
  59880. * @returns a new Color4 object
  59881. */
  59882. static FromHexString(hex: string): Color4;
  59883. /**
  59884. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59885. * @param left defines the start value
  59886. * @param right defines the end value
  59887. * @param amount defines the gradient factor
  59888. * @returns a new Color4 object
  59889. */
  59890. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59891. /**
  59892. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59893. * @param left defines the start value
  59894. * @param right defines the end value
  59895. * @param amount defines the gradient factor
  59896. * @param result defines the Color4 object where to store data
  59897. */
  59898. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59899. /**
  59900. * Creates a new Color4 from a Color3 and an alpha value
  59901. * @param color3 defines the source Color3 to read from
  59902. * @param alpha defines the alpha component (1.0 by default)
  59903. * @returns a new Color4 object
  59904. */
  59905. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59906. /**
  59907. * Creates a new Color4 from the starting index element of the given array
  59908. * @param array defines the source array to read from
  59909. * @param offset defines the offset in the source array
  59910. * @returns a new Color4 object
  59911. */
  59912. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59913. /**
  59914. * Creates a new Color3 from integer values (< 256)
  59915. * @param r defines the red component to read from (value between 0 and 255)
  59916. * @param g defines the green component to read from (value between 0 and 255)
  59917. * @param b defines the blue component to read from (value between 0 and 255)
  59918. * @param a defines the alpha component to read from (value between 0 and 255)
  59919. * @returns a new Color3 object
  59920. */
  59921. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59922. /**
  59923. * Check the content of a given array and convert it to an array containing RGBA data
  59924. * If the original array was already containing count * 4 values then it is returned directly
  59925. * @param colors defines the array to check
  59926. * @param count defines the number of RGBA data to expect
  59927. * @returns an array containing count * 4 values (RGBA)
  59928. */
  59929. static CheckColors4(colors: number[], count: number): number[];
  59930. }
  59931. /**
  59932. * Class representing a vector containing 2 coordinates
  59933. */
  59934. export class Vector2 {
  59935. /** defines the first coordinate */
  59936. x: number;
  59937. /** defines the second coordinate */
  59938. y: number;
  59939. /**
  59940. * Creates a new Vector2 from the given x and y coordinates
  59941. * @param x defines the first coordinate
  59942. * @param y defines the second coordinate
  59943. */
  59944. constructor(
  59945. /** defines the first coordinate */
  59946. x?: number,
  59947. /** defines the second coordinate */
  59948. y?: number);
  59949. /**
  59950. * Gets a string with the Vector2 coordinates
  59951. * @returns a string with the Vector2 coordinates
  59952. */
  59953. toString(): string;
  59954. /**
  59955. * Gets class name
  59956. * @returns the string "Vector2"
  59957. */
  59958. getClassName(): string;
  59959. /**
  59960. * Gets current vector hash code
  59961. * @returns the Vector2 hash code as a number
  59962. */
  59963. getHashCode(): number;
  59964. /**
  59965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59966. * @param array defines the source array
  59967. * @param index defines the offset in source array
  59968. * @returns the current Vector2
  59969. */
  59970. toArray(array: FloatArray, index?: number): Vector2;
  59971. /**
  59972. * Copy the current vector to an array
  59973. * @returns a new array with 2 elements: the Vector2 coordinates.
  59974. */
  59975. asArray(): number[];
  59976. /**
  59977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59978. * @param source defines the source Vector2
  59979. * @returns the current updated Vector2
  59980. */
  59981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59982. /**
  59983. * Sets the Vector2 coordinates with the given floats
  59984. * @param x defines the first coordinate
  59985. * @param y defines the second coordinate
  59986. * @returns the current updated Vector2
  59987. */
  59988. copyFromFloats(x: number, y: number): Vector2;
  59989. /**
  59990. * Sets the Vector2 coordinates with the given floats
  59991. * @param x defines the first coordinate
  59992. * @param y defines the second coordinate
  59993. * @returns the current updated Vector2
  59994. */
  59995. set(x: number, y: number): Vector2;
  59996. /**
  59997. * Add another vector with the current one
  59998. * @param otherVector defines the other vector
  59999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60000. */
  60001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60002. /**
  60003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60004. * @param otherVector defines the other vector
  60005. * @param result defines the target vector
  60006. * @returns the unmodified current Vector2
  60007. */
  60008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60009. /**
  60010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60011. * @param otherVector defines the other vector
  60012. * @returns the current updated Vector2
  60013. */
  60014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60015. /**
  60016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60017. * @param otherVector defines the other vector
  60018. * @returns a new Vector2
  60019. */
  60020. addVector3(otherVector: Vector3): Vector2;
  60021. /**
  60022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60023. * @param otherVector defines the other vector
  60024. * @returns a new Vector2
  60025. */
  60026. subtract(otherVector: Vector2): Vector2;
  60027. /**
  60028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60029. * @param otherVector defines the other vector
  60030. * @param result defines the target vector
  60031. * @returns the unmodified current Vector2
  60032. */
  60033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60034. /**
  60035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60036. * @param otherVector defines the other vector
  60037. * @returns the current updated Vector2
  60038. */
  60039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60040. /**
  60041. * Multiplies in place the current Vector2 coordinates by the given ones
  60042. * @param otherVector defines the other vector
  60043. * @returns the current updated Vector2
  60044. */
  60045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60046. /**
  60047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60048. * @param otherVector defines the other vector
  60049. * @returns a new Vector2
  60050. */
  60051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60052. /**
  60053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60054. * @param otherVector defines the other vector
  60055. * @param result defines the target vector
  60056. * @returns the unmodified current Vector2
  60057. */
  60058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60059. /**
  60060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60061. * @param x defines the first coordinate
  60062. * @param y defines the second coordinate
  60063. * @returns a new Vector2
  60064. */
  60065. multiplyByFloats(x: number, y: number): Vector2;
  60066. /**
  60067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60068. * @param otherVector defines the other vector
  60069. * @returns a new Vector2
  60070. */
  60071. divide(otherVector: Vector2): Vector2;
  60072. /**
  60073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60074. * @param otherVector defines the other vector
  60075. * @param result defines the target vector
  60076. * @returns the unmodified current Vector2
  60077. */
  60078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60079. /**
  60080. * Divides the current Vector2 coordinates by the given ones
  60081. * @param otherVector defines the other vector
  60082. * @returns the current updated Vector2
  60083. */
  60084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60085. /**
  60086. * Gets a new Vector2 with current Vector2 negated coordinates
  60087. * @returns a new Vector2
  60088. */
  60089. negate(): Vector2;
  60090. /**
  60091. * Multiply the Vector2 coordinates by scale
  60092. * @param scale defines the scaling factor
  60093. * @returns the current updated Vector2
  60094. */
  60095. scaleInPlace(scale: number): Vector2;
  60096. /**
  60097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60098. * @param scale defines the scaling factor
  60099. * @returns a new Vector2
  60100. */
  60101. scale(scale: number): Vector2;
  60102. /**
  60103. * Scale the current Vector2 values by a factor to a given Vector2
  60104. * @param scale defines the scale factor
  60105. * @param result defines the Vector2 object where to store the result
  60106. * @returns the unmodified current Vector2
  60107. */
  60108. scaleToRef(scale: number, result: Vector2): Vector2;
  60109. /**
  60110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60111. * @param scale defines the scale factor
  60112. * @param result defines the Vector2 object where to store the result
  60113. * @returns the unmodified current Vector2
  60114. */
  60115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60116. /**
  60117. * Gets a boolean if two vectors are equals
  60118. * @param otherVector defines the other vector
  60119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60120. */
  60121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60122. /**
  60123. * Gets a boolean if two vectors are equals (using an epsilon value)
  60124. * @param otherVector defines the other vector
  60125. * @param epsilon defines the minimal distance to consider equality
  60126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60127. */
  60128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60129. /**
  60130. * Gets a new Vector2 from current Vector2 floored values
  60131. * @returns a new Vector2
  60132. */
  60133. floor(): Vector2;
  60134. /**
  60135. * Gets a new Vector2 from current Vector2 floored values
  60136. * @returns a new Vector2
  60137. */
  60138. fract(): Vector2;
  60139. /**
  60140. * Gets the length of the vector
  60141. * @returns the vector length (float)
  60142. */
  60143. length(): number;
  60144. /**
  60145. * Gets the vector squared length
  60146. * @returns the vector squared length (float)
  60147. */
  60148. lengthSquared(): number;
  60149. /**
  60150. * Normalize the vector
  60151. * @returns the current updated Vector2
  60152. */
  60153. normalize(): Vector2;
  60154. /**
  60155. * Gets a new Vector2 copied from the Vector2
  60156. * @returns a new Vector2
  60157. */
  60158. clone(): Vector2;
  60159. /**
  60160. * Gets a new Vector2(0, 0)
  60161. * @returns a new Vector2
  60162. */
  60163. static Zero(): Vector2;
  60164. /**
  60165. * Gets a new Vector2(1, 1)
  60166. * @returns a new Vector2
  60167. */
  60168. static One(): Vector2;
  60169. /**
  60170. * Gets a new Vector2 set from the given index element of the given array
  60171. * @param array defines the data source
  60172. * @param offset defines the offset in the data source
  60173. * @returns a new Vector2
  60174. */
  60175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60176. /**
  60177. * Sets "result" from the given index element of the given array
  60178. * @param array defines the data source
  60179. * @param offset defines the offset in the data source
  60180. * @param result defines the target vector
  60181. */
  60182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60183. /**
  60184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60185. * @param value1 defines 1st point of control
  60186. * @param value2 defines 2nd point of control
  60187. * @param value3 defines 3rd point of control
  60188. * @param value4 defines 4th point of control
  60189. * @param amount defines the interpolation factor
  60190. * @returns a new Vector2
  60191. */
  60192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60193. /**
  60194. * 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".
  60195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60197. * @param value defines the value to clamp
  60198. * @param min defines the lower limit
  60199. * @param max defines the upper limit
  60200. * @returns a new Vector2
  60201. */
  60202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60203. /**
  60204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60205. * @param value1 defines the 1st control point
  60206. * @param tangent1 defines the outgoing tangent
  60207. * @param value2 defines the 2nd control point
  60208. * @param tangent2 defines the incoming tangent
  60209. * @param amount defines the interpolation factor
  60210. * @returns a new Vector2
  60211. */
  60212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60213. /**
  60214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60215. * @param start defines the start vector
  60216. * @param end defines the end vector
  60217. * @param amount defines the interpolation factor
  60218. * @returns a new Vector2
  60219. */
  60220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60221. /**
  60222. * Gets the dot product of the vector "left" and the vector "right"
  60223. * @param left defines first vector
  60224. * @param right defines second vector
  60225. * @returns the dot product (float)
  60226. */
  60227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60228. /**
  60229. * Returns a new Vector2 equal to the normalized given vector
  60230. * @param vector defines the vector to normalize
  60231. * @returns a new Vector2
  60232. */
  60233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60234. /**
  60235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60236. * @param left defines 1st vector
  60237. * @param right defines 2nd vector
  60238. * @returns a new Vector2
  60239. */
  60240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60241. /**
  60242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60243. * @param left defines 1st vector
  60244. * @param right defines 2nd vector
  60245. * @returns a new Vector2
  60246. */
  60247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60248. /**
  60249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60250. * @param vector defines the vector to transform
  60251. * @param transformation defines the matrix to apply
  60252. * @returns a new Vector2
  60253. */
  60254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60255. /**
  60256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60257. * @param vector defines the vector to transform
  60258. * @param transformation defines the matrix to apply
  60259. * @param result defines the target vector
  60260. */
  60261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60262. /**
  60263. * Determines if a given vector is included in a triangle
  60264. * @param p defines the vector to test
  60265. * @param p0 defines 1st triangle point
  60266. * @param p1 defines 2nd triangle point
  60267. * @param p2 defines 3rd triangle point
  60268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60269. */
  60270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60271. /**
  60272. * Gets the distance between the vectors "value1" and "value2"
  60273. * @param value1 defines first vector
  60274. * @param value2 defines second vector
  60275. * @returns the distance between vectors
  60276. */
  60277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60278. /**
  60279. * Returns the squared distance between the vectors "value1" and "value2"
  60280. * @param value1 defines first vector
  60281. * @param value2 defines second vector
  60282. * @returns the squared distance between vectors
  60283. */
  60284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60285. /**
  60286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60287. * @param value1 defines first vector
  60288. * @param value2 defines second vector
  60289. * @returns a new Vector2
  60290. */
  60291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60292. /**
  60293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60294. * @param p defines the middle point
  60295. * @param segA defines one point of the segment
  60296. * @param segB defines the other point of the segment
  60297. * @returns the shortest distance
  60298. */
  60299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60300. }
  60301. /**
  60302. * Classed used to store (x,y,z) vector representation
  60303. * A Vector3 is the main object used in 3D geometry
  60304. * It can represent etiher the coordinates of a point the space, either a direction
  60305. * Reminder: js uses a left handed forward facing system
  60306. */
  60307. export class Vector3 {
  60308. /**
  60309. * Defines the first coordinates (on X axis)
  60310. */
  60311. x: number;
  60312. /**
  60313. * Defines the second coordinates (on Y axis)
  60314. */
  60315. y: number;
  60316. /**
  60317. * Defines the third coordinates (on Z axis)
  60318. */
  60319. z: number;
  60320. private static _UpReadOnly;
  60321. /**
  60322. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60323. * @param x defines the first coordinates (on X axis)
  60324. * @param y defines the second coordinates (on Y axis)
  60325. * @param z defines the third coordinates (on Z axis)
  60326. */
  60327. constructor(
  60328. /**
  60329. * Defines the first coordinates (on X axis)
  60330. */
  60331. x?: number,
  60332. /**
  60333. * Defines the second coordinates (on Y axis)
  60334. */
  60335. y?: number,
  60336. /**
  60337. * Defines the third coordinates (on Z axis)
  60338. */
  60339. z?: number);
  60340. /**
  60341. * Creates a string representation of the Vector3
  60342. * @returns a string with the Vector3 coordinates.
  60343. */
  60344. toString(): string;
  60345. /**
  60346. * Gets the class name
  60347. * @returns the string "Vector3"
  60348. */
  60349. getClassName(): string;
  60350. /**
  60351. * Creates the Vector3 hash code
  60352. * @returns a number which tends to be unique between Vector3 instances
  60353. */
  60354. getHashCode(): number;
  60355. /**
  60356. * Creates an array containing three elements : the coordinates of the Vector3
  60357. * @returns a new array of numbers
  60358. */
  60359. asArray(): number[];
  60360. /**
  60361. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60362. * @param array defines the destination array
  60363. * @param index defines the offset in the destination array
  60364. * @returns the current Vector3
  60365. */
  60366. toArray(array: FloatArray, index?: number): Vector3;
  60367. /**
  60368. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60369. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60370. */
  60371. toQuaternion(): Quaternion;
  60372. /**
  60373. * Adds the given vector to the current Vector3
  60374. * @param otherVector defines the second operand
  60375. * @returns the current updated Vector3
  60376. */
  60377. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60378. /**
  60379. * Adds the given coordinates to the current Vector3
  60380. * @param x defines the x coordinate of the operand
  60381. * @param y defines the y coordinate of the operand
  60382. * @param z defines the z coordinate of the operand
  60383. * @returns the current updated Vector3
  60384. */
  60385. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60386. /**
  60387. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60388. * @param otherVector defines the second operand
  60389. * @returns the resulting Vector3
  60390. */
  60391. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60392. /**
  60393. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60394. * @param otherVector defines the second operand
  60395. * @param result defines the Vector3 object where to store the result
  60396. * @returns the current Vector3
  60397. */
  60398. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60399. /**
  60400. * Subtract the given vector from the current Vector3
  60401. * @param otherVector defines the second operand
  60402. * @returns the current updated Vector3
  60403. */
  60404. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60405. /**
  60406. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60407. * @param otherVector defines the second operand
  60408. * @returns the resulting Vector3
  60409. */
  60410. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60411. /**
  60412. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60413. * @param otherVector defines the second operand
  60414. * @param result defines the Vector3 object where to store the result
  60415. * @returns the current Vector3
  60416. */
  60417. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60418. /**
  60419. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60420. * @param x defines the x coordinate of the operand
  60421. * @param y defines the y coordinate of the operand
  60422. * @param z defines the z coordinate of the operand
  60423. * @returns the resulting Vector3
  60424. */
  60425. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60426. /**
  60427. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60428. * @param x defines the x coordinate of the operand
  60429. * @param y defines the y coordinate of the operand
  60430. * @param z defines the z coordinate of the operand
  60431. * @param result defines the Vector3 object where to store the result
  60432. * @returns the current Vector3
  60433. */
  60434. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60435. /**
  60436. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60437. * @returns a new Vector3
  60438. */
  60439. negate(): Vector3;
  60440. /**
  60441. * Multiplies the Vector3 coordinates by the float "scale"
  60442. * @param scale defines the multiplier factor
  60443. * @returns the current updated Vector3
  60444. */
  60445. scaleInPlace(scale: number): Vector3;
  60446. /**
  60447. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60448. * @param scale defines the multiplier factor
  60449. * @returns a new Vector3
  60450. */
  60451. scale(scale: number): Vector3;
  60452. /**
  60453. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60454. * @param scale defines the multiplier factor
  60455. * @param result defines the Vector3 object where to store the result
  60456. * @returns the current Vector3
  60457. */
  60458. scaleToRef(scale: number, result: Vector3): Vector3;
  60459. /**
  60460. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60461. * @param scale defines the scale factor
  60462. * @param result defines the Vector3 object where to store the result
  60463. * @returns the unmodified current Vector3
  60464. */
  60465. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60466. /**
  60467. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60468. * @param otherVector defines the second operand
  60469. * @returns true if both vectors are equals
  60470. */
  60471. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60472. /**
  60473. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60474. * @param otherVector defines the second operand
  60475. * @param epsilon defines the minimal distance to define values as equals
  60476. * @returns true if both vectors are distant less than epsilon
  60477. */
  60478. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60479. /**
  60480. * Returns true if the current Vector3 coordinates equals the given floats
  60481. * @param x defines the x coordinate of the operand
  60482. * @param y defines the y coordinate of the operand
  60483. * @param z defines the z coordinate of the operand
  60484. * @returns true if both vectors are equals
  60485. */
  60486. equalsToFloats(x: number, y: number, z: number): boolean;
  60487. /**
  60488. * Multiplies the current Vector3 coordinates by the given ones
  60489. * @param otherVector defines the second operand
  60490. * @returns the current updated Vector3
  60491. */
  60492. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60493. /**
  60494. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60495. * @param otherVector defines the second operand
  60496. * @returns the new Vector3
  60497. */
  60498. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60499. /**
  60500. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60501. * @param otherVector defines the second operand
  60502. * @param result defines the Vector3 object where to store the result
  60503. * @returns the current Vector3
  60504. */
  60505. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60506. /**
  60507. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60508. * @param x defines the x coordinate of the operand
  60509. * @param y defines the y coordinate of the operand
  60510. * @param z defines the z coordinate of the operand
  60511. * @returns the new Vector3
  60512. */
  60513. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60514. /**
  60515. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60516. * @param otherVector defines the second operand
  60517. * @returns the new Vector3
  60518. */
  60519. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60520. /**
  60521. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60522. * @param otherVector defines the second operand
  60523. * @param result defines the Vector3 object where to store the result
  60524. * @returns the current Vector3
  60525. */
  60526. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60527. /**
  60528. * Divides the current Vector3 coordinates by the given ones.
  60529. * @param otherVector defines the second operand
  60530. * @returns the current updated Vector3
  60531. */
  60532. divideInPlace(otherVector: Vector3): Vector3;
  60533. /**
  60534. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60535. * @param other defines the second operand
  60536. * @returns the current updated Vector3
  60537. */
  60538. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60539. /**
  60540. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60541. * @param other defines the second operand
  60542. * @returns the current updated Vector3
  60543. */
  60544. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60545. /**
  60546. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60547. * @param x defines the x coordinate of the operand
  60548. * @param y defines the y coordinate of the operand
  60549. * @param z defines the z coordinate of the operand
  60550. * @returns the current updated Vector3
  60551. */
  60552. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60553. /**
  60554. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60555. * @param x defines the x coordinate of the operand
  60556. * @param y defines the y coordinate of the operand
  60557. * @param z defines the z coordinate of the operand
  60558. * @returns the current updated Vector3
  60559. */
  60560. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60561. /**
  60562. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60563. * Check if is non uniform within a certain amount of decimal places to account for this
  60564. * @param epsilon the amount the values can differ
  60565. * @returns if the the vector is non uniform to a certain number of decimal places
  60566. */
  60567. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60568. /**
  60569. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60570. */
  60571. readonly isNonUniform: boolean;
  60572. /**
  60573. * Gets a new Vector3 from current Vector3 floored values
  60574. * @returns a new Vector3
  60575. */
  60576. floor(): Vector3;
  60577. /**
  60578. * Gets a new Vector3 from current Vector3 floored values
  60579. * @returns a new Vector3
  60580. */
  60581. fract(): Vector3;
  60582. /**
  60583. * Gets the length of the Vector3
  60584. * @returns the length of the Vecto3
  60585. */
  60586. length(): number;
  60587. /**
  60588. * Gets the squared length of the Vector3
  60589. * @returns squared length of the Vector3
  60590. */
  60591. lengthSquared(): number;
  60592. /**
  60593. * Normalize the current Vector3.
  60594. * Please note that this is an in place operation.
  60595. * @returns the current updated Vector3
  60596. */
  60597. normalize(): Vector3;
  60598. /**
  60599. * Reorders the x y z properties of the vector in place
  60600. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60601. * @returns the current updated vector
  60602. */
  60603. reorderInPlace(order: string): this;
  60604. /**
  60605. * Rotates the vector around 0,0,0 by a quaternion
  60606. * @param quaternion the rotation quaternion
  60607. * @param result vector to store the result
  60608. * @returns the resulting vector
  60609. */
  60610. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60611. /**
  60612. * Rotates a vector around a given point
  60613. * @param quaternion the rotation quaternion
  60614. * @param point the point to rotate around
  60615. * @param result vector to store the result
  60616. * @returns the resulting vector
  60617. */
  60618. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60619. /**
  60620. * Normalize the current Vector3 with the given input length.
  60621. * Please note that this is an in place operation.
  60622. * @param len the length of the vector
  60623. * @returns the current updated Vector3
  60624. */
  60625. normalizeFromLength(len: number): Vector3;
  60626. /**
  60627. * Normalize the current Vector3 to a new vector
  60628. * @returns the new Vector3
  60629. */
  60630. normalizeToNew(): Vector3;
  60631. /**
  60632. * Normalize the current Vector3 to the reference
  60633. * @param reference define the Vector3 to update
  60634. * @returns the updated Vector3
  60635. */
  60636. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60637. /**
  60638. * Creates a new Vector3 copied from the current Vector3
  60639. * @returns the new Vector3
  60640. */
  60641. clone(): Vector3;
  60642. /**
  60643. * Copies the given vector coordinates to the current Vector3 ones
  60644. * @param source defines the source Vector3
  60645. * @returns the current updated Vector3
  60646. */
  60647. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60648. /**
  60649. * Copies the given floats to the current Vector3 coordinates
  60650. * @param x defines the x coordinate of the operand
  60651. * @param y defines the y coordinate of the operand
  60652. * @param z defines the z coordinate of the operand
  60653. * @returns the current updated Vector3
  60654. */
  60655. copyFromFloats(x: number, y: number, z: number): Vector3;
  60656. /**
  60657. * Copies the given floats to the current Vector3 coordinates
  60658. * @param x defines the x coordinate of the operand
  60659. * @param y defines the y coordinate of the operand
  60660. * @param z defines the z coordinate of the operand
  60661. * @returns the current updated Vector3
  60662. */
  60663. set(x: number, y: number, z: number): Vector3;
  60664. /**
  60665. * Copies the given float to the current Vector3 coordinates
  60666. * @param v defines the x, y and z coordinates of the operand
  60667. * @returns the current updated Vector3
  60668. */
  60669. setAll(v: number): Vector3;
  60670. /**
  60671. * Get the clip factor between two vectors
  60672. * @param vector0 defines the first operand
  60673. * @param vector1 defines the second operand
  60674. * @param axis defines the axis to use
  60675. * @param size defines the size along the axis
  60676. * @returns the clip factor
  60677. */
  60678. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60679. /**
  60680. * Get angle between two vectors
  60681. * @param vector0 angle between vector0 and vector1
  60682. * @param vector1 angle between vector0 and vector1
  60683. * @param normal direction of the normal
  60684. * @return the angle between vector0 and vector1
  60685. */
  60686. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60687. /**
  60688. * Returns a new Vector3 set from the index "offset" of the given array
  60689. * @param array defines the source array
  60690. * @param offset defines the offset in the source array
  60691. * @returns the new Vector3
  60692. */
  60693. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60694. /**
  60695. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60696. * This function is deprecated. Use FromArray instead
  60697. * @param array defines the source array
  60698. * @param offset defines the offset in the source array
  60699. * @returns the new Vector3
  60700. */
  60701. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60702. /**
  60703. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60704. * @param array defines the source array
  60705. * @param offset defines the offset in the source array
  60706. * @param result defines the Vector3 where to store the result
  60707. */
  60708. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60709. /**
  60710. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60711. * This function is deprecated. Use FromArrayToRef instead.
  60712. * @param array defines the source array
  60713. * @param offset defines the offset in the source array
  60714. * @param result defines the Vector3 where to store the result
  60715. */
  60716. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60717. /**
  60718. * Sets the given vector "result" with the given floats.
  60719. * @param x defines the x coordinate of the source
  60720. * @param y defines the y coordinate of the source
  60721. * @param z defines the z coordinate of the source
  60722. * @param result defines the Vector3 where to store the result
  60723. */
  60724. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60725. /**
  60726. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60727. * @returns a new empty Vector3
  60728. */
  60729. static Zero(): Vector3;
  60730. /**
  60731. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60732. * @returns a new unit Vector3
  60733. */
  60734. static One(): Vector3;
  60735. /**
  60736. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60737. * @returns a new up Vector3
  60738. */
  60739. static Up(): Vector3;
  60740. /**
  60741. * Gets a up Vector3 that must not be updated
  60742. */
  60743. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60744. /**
  60745. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60746. * @returns a new down Vector3
  60747. */
  60748. static Down(): Vector3;
  60749. /**
  60750. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60751. * @returns a new forward Vector3
  60752. */
  60753. static Forward(): Vector3;
  60754. /**
  60755. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60756. * @returns a new forward Vector3
  60757. */
  60758. static Backward(): Vector3;
  60759. /**
  60760. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60761. * @returns a new right Vector3
  60762. */
  60763. static Right(): Vector3;
  60764. /**
  60765. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60766. * @returns a new left Vector3
  60767. */
  60768. static Left(): Vector3;
  60769. /**
  60770. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60771. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60772. * @param vector defines the Vector3 to transform
  60773. * @param transformation defines the transformation matrix
  60774. * @returns the transformed Vector3
  60775. */
  60776. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60777. /**
  60778. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60780. * @param vector defines the Vector3 to transform
  60781. * @param transformation defines the transformation matrix
  60782. * @param result defines the Vector3 where to store the result
  60783. */
  60784. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60785. /**
  60786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60787. * This method computes tranformed coordinates only, not transformed direction vectors
  60788. * @param x define the x coordinate of the source vector
  60789. * @param y define the y coordinate of the source vector
  60790. * @param z define the z coordinate of the source vector
  60791. * @param transformation defines the transformation matrix
  60792. * @param result defines the Vector3 where to store the result
  60793. */
  60794. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60795. /**
  60796. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60797. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60798. * @param vector defines the Vector3 to transform
  60799. * @param transformation defines the transformation matrix
  60800. * @returns the new Vector3
  60801. */
  60802. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60803. /**
  60804. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60806. * @param vector defines the Vector3 to transform
  60807. * @param transformation defines the transformation matrix
  60808. * @param result defines the Vector3 where to store the result
  60809. */
  60810. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60811. /**
  60812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60814. * @param x define the x coordinate of the source vector
  60815. * @param y define the y coordinate of the source vector
  60816. * @param z define the z coordinate of the source vector
  60817. * @param transformation defines the transformation matrix
  60818. * @param result defines the Vector3 where to store the result
  60819. */
  60820. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60821. /**
  60822. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60823. * @param value1 defines the first control point
  60824. * @param value2 defines the second control point
  60825. * @param value3 defines the third control point
  60826. * @param value4 defines the fourth control point
  60827. * @param amount defines the amount on the spline to use
  60828. * @returns the new Vector3
  60829. */
  60830. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60831. /**
  60832. * 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"
  60833. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60834. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60835. * @param value defines the current value
  60836. * @param min defines the lower range value
  60837. * @param max defines the upper range value
  60838. * @returns the new Vector3
  60839. */
  60840. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60841. /**
  60842. * 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"
  60843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60845. * @param value defines the current value
  60846. * @param min defines the lower range value
  60847. * @param max defines the upper range value
  60848. * @param result defines the Vector3 where to store the result
  60849. */
  60850. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60851. /**
  60852. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60853. * @param value1 defines the first control point
  60854. * @param tangent1 defines the first tangent vector
  60855. * @param value2 defines the second control point
  60856. * @param tangent2 defines the second tangent vector
  60857. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60858. * @returns the new Vector3
  60859. */
  60860. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60861. /**
  60862. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60863. * @param start defines the start value
  60864. * @param end defines the end value
  60865. * @param amount max defines amount between both (between 0 and 1)
  60866. * @returns the new Vector3
  60867. */
  60868. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60869. /**
  60870. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60871. * @param start defines the start value
  60872. * @param end defines the end value
  60873. * @param amount max defines amount between both (between 0 and 1)
  60874. * @param result defines the Vector3 where to store the result
  60875. */
  60876. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60877. /**
  60878. * Returns the dot product (float) between the vectors "left" and "right"
  60879. * @param left defines the left operand
  60880. * @param right defines the right operand
  60881. * @returns the dot product
  60882. */
  60883. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60884. /**
  60885. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60886. * The cross product is then orthogonal to both "left" and "right"
  60887. * @param left defines the left operand
  60888. * @param right defines the right operand
  60889. * @returns the cross product
  60890. */
  60891. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60892. /**
  60893. * Sets the given vector "result" with the cross product of "left" and "right"
  60894. * The cross product is then orthogonal to both "left" and "right"
  60895. * @param left defines the left operand
  60896. * @param right defines the right operand
  60897. * @param result defines the Vector3 where to store the result
  60898. */
  60899. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60900. /**
  60901. * Returns a new Vector3 as the normalization of the given vector
  60902. * @param vector defines the Vector3 to normalize
  60903. * @returns the new Vector3
  60904. */
  60905. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60906. /**
  60907. * Sets the given vector "result" with the normalization of the given first vector
  60908. * @param vector defines the Vector3 to normalize
  60909. * @param result defines the Vector3 where to store the result
  60910. */
  60911. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60912. /**
  60913. * Project a Vector3 onto screen space
  60914. * @param vector defines the Vector3 to project
  60915. * @param world defines the world matrix to use
  60916. * @param transform defines the transform (view x projection) matrix to use
  60917. * @param viewport defines the screen viewport to use
  60918. * @returns the new Vector3
  60919. */
  60920. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60921. /** @hidden */
  60922. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60923. /**
  60924. * Unproject from screen space to object space
  60925. * @param source defines the screen space Vector3 to use
  60926. * @param viewportWidth defines the current width of the viewport
  60927. * @param viewportHeight defines the current height of the viewport
  60928. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60929. * @param transform defines the transform (view x projection) matrix to use
  60930. * @returns the new Vector3
  60931. */
  60932. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60933. /**
  60934. * Unproject from screen space to object space
  60935. * @param source defines the screen space Vector3 to use
  60936. * @param viewportWidth defines the current width of the viewport
  60937. * @param viewportHeight defines the current height of the viewport
  60938. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60939. * @param view defines the view matrix to use
  60940. * @param projection defines the projection matrix to use
  60941. * @returns the new Vector3
  60942. */
  60943. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60944. /**
  60945. * Unproject from screen space to object space
  60946. * @param source defines the screen space Vector3 to use
  60947. * @param viewportWidth defines the current width of the viewport
  60948. * @param viewportHeight defines the current height of the viewport
  60949. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60950. * @param view defines the view matrix to use
  60951. * @param projection defines the projection matrix to use
  60952. * @param result defines the Vector3 where to store the result
  60953. */
  60954. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60955. /**
  60956. * Unproject from screen space to object space
  60957. * @param sourceX defines the screen space x coordinate to use
  60958. * @param sourceY defines the screen space y coordinate to use
  60959. * @param sourceZ defines the screen space z coordinate to use
  60960. * @param viewportWidth defines the current width of the viewport
  60961. * @param viewportHeight defines the current height of the viewport
  60962. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60963. * @param view defines the view matrix to use
  60964. * @param projection defines the projection matrix to use
  60965. * @param result defines the Vector3 where to store the result
  60966. */
  60967. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60968. /**
  60969. * Gets the minimal coordinate values between two Vector3
  60970. * @param left defines the first operand
  60971. * @param right defines the second operand
  60972. * @returns the new Vector3
  60973. */
  60974. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60975. /**
  60976. * Gets the maximal coordinate values between two Vector3
  60977. * @param left defines the first operand
  60978. * @param right defines the second operand
  60979. * @returns the new Vector3
  60980. */
  60981. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60982. /**
  60983. * Returns the distance between the vectors "value1" and "value2"
  60984. * @param value1 defines the first operand
  60985. * @param value2 defines the second operand
  60986. * @returns the distance
  60987. */
  60988. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60989. /**
  60990. * Returns the squared distance between the vectors "value1" and "value2"
  60991. * @param value1 defines the first operand
  60992. * @param value2 defines the second operand
  60993. * @returns the squared distance
  60994. */
  60995. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60996. /**
  60997. * Returns a new Vector3 located at the center between "value1" and "value2"
  60998. * @param value1 defines the first operand
  60999. * @param value2 defines the second operand
  61000. * @returns the new Vector3
  61001. */
  61002. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61003. /**
  61004. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61005. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61006. * to something in order to rotate it from its local system to the given target system
  61007. * Note: axis1, axis2 and axis3 are normalized during this operation
  61008. * @param axis1 defines the first axis
  61009. * @param axis2 defines the second axis
  61010. * @param axis3 defines the third axis
  61011. * @returns a new Vector3
  61012. */
  61013. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61014. /**
  61015. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61016. * @param axis1 defines the first axis
  61017. * @param axis2 defines the second axis
  61018. * @param axis3 defines the third axis
  61019. * @param ref defines the Vector3 where to store the result
  61020. */
  61021. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61022. }
  61023. /**
  61024. * Vector4 class created for EulerAngle class conversion to Quaternion
  61025. */
  61026. export class Vector4 {
  61027. /** x value of the vector */
  61028. x: number;
  61029. /** y value of the vector */
  61030. y: number;
  61031. /** z value of the vector */
  61032. z: number;
  61033. /** w value of the vector */
  61034. w: number;
  61035. /**
  61036. * Creates a Vector4 object from the given floats.
  61037. * @param x x value of the vector
  61038. * @param y y value of the vector
  61039. * @param z z value of the vector
  61040. * @param w w value of the vector
  61041. */
  61042. constructor(
  61043. /** x value of the vector */
  61044. x: number,
  61045. /** y value of the vector */
  61046. y: number,
  61047. /** z value of the vector */
  61048. z: number,
  61049. /** w value of the vector */
  61050. w: number);
  61051. /**
  61052. * Returns the string with the Vector4 coordinates.
  61053. * @returns a string containing all the vector values
  61054. */
  61055. toString(): string;
  61056. /**
  61057. * Returns the string "Vector4".
  61058. * @returns "Vector4"
  61059. */
  61060. getClassName(): string;
  61061. /**
  61062. * Returns the Vector4 hash code.
  61063. * @returns a unique hash code
  61064. */
  61065. getHashCode(): number;
  61066. /**
  61067. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61068. * @returns the resulting array
  61069. */
  61070. asArray(): number[];
  61071. /**
  61072. * Populates the given array from the given index with the Vector4 coordinates.
  61073. * @param array array to populate
  61074. * @param index index of the array to start at (default: 0)
  61075. * @returns the Vector4.
  61076. */
  61077. toArray(array: FloatArray, index?: number): Vector4;
  61078. /**
  61079. * Adds the given vector to the current Vector4.
  61080. * @param otherVector the vector to add
  61081. * @returns the updated Vector4.
  61082. */
  61083. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61084. /**
  61085. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61086. * @param otherVector the vector to add
  61087. * @returns the resulting vector
  61088. */
  61089. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61090. /**
  61091. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61092. * @param otherVector the vector to add
  61093. * @param result the vector to store the result
  61094. * @returns the current Vector4.
  61095. */
  61096. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61097. /**
  61098. * Subtract in place the given vector from the current Vector4.
  61099. * @param otherVector the vector to subtract
  61100. * @returns the updated Vector4.
  61101. */
  61102. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61103. /**
  61104. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61105. * @param otherVector the vector to add
  61106. * @returns the new vector with the result
  61107. */
  61108. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61109. /**
  61110. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61111. * @param otherVector the vector to subtract
  61112. * @param result the vector to store the result
  61113. * @returns the current Vector4.
  61114. */
  61115. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61116. /**
  61117. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61118. */
  61119. /**
  61120. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61121. * @param x value to subtract
  61122. * @param y value to subtract
  61123. * @param z value to subtract
  61124. * @param w value to subtract
  61125. * @returns new vector containing the result
  61126. */
  61127. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61128. /**
  61129. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61130. * @param x value to subtract
  61131. * @param y value to subtract
  61132. * @param z value to subtract
  61133. * @param w value to subtract
  61134. * @param result the vector to store the result in
  61135. * @returns the current Vector4.
  61136. */
  61137. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61138. /**
  61139. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61140. * @returns a new vector with the negated values
  61141. */
  61142. negate(): Vector4;
  61143. /**
  61144. * Multiplies the current Vector4 coordinates by scale (float).
  61145. * @param scale the number to scale with
  61146. * @returns the updated Vector4.
  61147. */
  61148. scaleInPlace(scale: number): Vector4;
  61149. /**
  61150. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61151. * @param scale the number to scale with
  61152. * @returns a new vector with the result
  61153. */
  61154. scale(scale: number): Vector4;
  61155. /**
  61156. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61157. * @param scale the number to scale with
  61158. * @param result a vector to store the result in
  61159. * @returns the current Vector4.
  61160. */
  61161. scaleToRef(scale: number, result: Vector4): Vector4;
  61162. /**
  61163. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61164. * @param scale defines the scale factor
  61165. * @param result defines the Vector4 object where to store the result
  61166. * @returns the unmodified current Vector4
  61167. */
  61168. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61169. /**
  61170. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61171. * @param otherVector the vector to compare against
  61172. * @returns true if they are equal
  61173. */
  61174. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61175. /**
  61176. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61177. * @param otherVector vector to compare against
  61178. * @param epsilon (Default: very small number)
  61179. * @returns true if they are equal
  61180. */
  61181. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61182. /**
  61183. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61184. * @param x x value to compare against
  61185. * @param y y value to compare against
  61186. * @param z z value to compare against
  61187. * @param w w value to compare against
  61188. * @returns true if equal
  61189. */
  61190. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61191. /**
  61192. * Multiplies in place the current Vector4 by the given one.
  61193. * @param otherVector vector to multiple with
  61194. * @returns the updated Vector4.
  61195. */
  61196. multiplyInPlace(otherVector: Vector4): Vector4;
  61197. /**
  61198. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61199. * @param otherVector vector to multiple with
  61200. * @returns resulting new vector
  61201. */
  61202. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61203. /**
  61204. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61205. * @param otherVector vector to multiple with
  61206. * @param result vector to store the result
  61207. * @returns the current Vector4.
  61208. */
  61209. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61210. /**
  61211. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61212. * @param x x value multiply with
  61213. * @param y y value multiply with
  61214. * @param z z value multiply with
  61215. * @param w w value multiply with
  61216. * @returns resulting new vector
  61217. */
  61218. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61219. /**
  61220. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61221. * @param otherVector vector to devide with
  61222. * @returns resulting new vector
  61223. */
  61224. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61225. /**
  61226. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61227. * @param otherVector vector to devide with
  61228. * @param result vector to store the result
  61229. * @returns the current Vector4.
  61230. */
  61231. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61232. /**
  61233. * Divides the current Vector3 coordinates by the given ones.
  61234. * @param otherVector vector to devide with
  61235. * @returns the updated Vector3.
  61236. */
  61237. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61238. /**
  61239. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61240. * @param other defines the second operand
  61241. * @returns the current updated Vector4
  61242. */
  61243. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61244. /**
  61245. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61246. * @param other defines the second operand
  61247. * @returns the current updated Vector4
  61248. */
  61249. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61250. /**
  61251. * Gets a new Vector4 from current Vector4 floored values
  61252. * @returns a new Vector4
  61253. */
  61254. floor(): Vector4;
  61255. /**
  61256. * Gets a new Vector4 from current Vector3 floored values
  61257. * @returns a new Vector4
  61258. */
  61259. fract(): Vector4;
  61260. /**
  61261. * Returns the Vector4 length (float).
  61262. * @returns the length
  61263. */
  61264. length(): number;
  61265. /**
  61266. * Returns the Vector4 squared length (float).
  61267. * @returns the length squared
  61268. */
  61269. lengthSquared(): number;
  61270. /**
  61271. * Normalizes in place the Vector4.
  61272. * @returns the updated Vector4.
  61273. */
  61274. normalize(): Vector4;
  61275. /**
  61276. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61277. * @returns this converted to a new vector3
  61278. */
  61279. toVector3(): Vector3;
  61280. /**
  61281. * Returns a new Vector4 copied from the current one.
  61282. * @returns the new cloned vector
  61283. */
  61284. clone(): Vector4;
  61285. /**
  61286. * Updates the current Vector4 with the given one coordinates.
  61287. * @param source the source vector to copy from
  61288. * @returns the updated Vector4.
  61289. */
  61290. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61291. /**
  61292. * Updates the current Vector4 coordinates with the given floats.
  61293. * @param x float to copy from
  61294. * @param y float to copy from
  61295. * @param z float to copy from
  61296. * @param w float to copy from
  61297. * @returns the updated Vector4.
  61298. */
  61299. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61300. /**
  61301. * Updates the current Vector4 coordinates with the given floats.
  61302. * @param x float to set from
  61303. * @param y float to set from
  61304. * @param z float to set from
  61305. * @param w float to set from
  61306. * @returns the updated Vector4.
  61307. */
  61308. set(x: number, y: number, z: number, w: number): Vector4;
  61309. /**
  61310. * Copies the given float to the current Vector3 coordinates
  61311. * @param v defines the x, y, z and w coordinates of the operand
  61312. * @returns the current updated Vector3
  61313. */
  61314. setAll(v: number): Vector4;
  61315. /**
  61316. * Returns a new Vector4 set from the starting index of the given array.
  61317. * @param array the array to pull values from
  61318. * @param offset the offset into the array to start at
  61319. * @returns the new vector
  61320. */
  61321. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61322. /**
  61323. * Updates the given vector "result" from the starting index of the given array.
  61324. * @param array the array to pull values from
  61325. * @param offset the offset into the array to start at
  61326. * @param result the vector to store the result in
  61327. */
  61328. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61329. /**
  61330. * Updates the given vector "result" from the starting index of the given Float32Array.
  61331. * @param array the array to pull values from
  61332. * @param offset the offset into the array to start at
  61333. * @param result the vector to store the result in
  61334. */
  61335. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61336. /**
  61337. * Updates the given vector "result" coordinates from the given floats.
  61338. * @param x float to set from
  61339. * @param y float to set from
  61340. * @param z float to set from
  61341. * @param w float to set from
  61342. * @param result the vector to the floats in
  61343. */
  61344. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61345. /**
  61346. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61347. * @returns the new vector
  61348. */
  61349. static Zero(): Vector4;
  61350. /**
  61351. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61352. * @returns the new vector
  61353. */
  61354. static One(): Vector4;
  61355. /**
  61356. * Returns a new normalized Vector4 from the given one.
  61357. * @param vector the vector to normalize
  61358. * @returns the vector
  61359. */
  61360. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61361. /**
  61362. * Updates the given vector "result" from the normalization of the given one.
  61363. * @param vector the vector to normalize
  61364. * @param result the vector to store the result in
  61365. */
  61366. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61367. /**
  61368. * Returns a vector with the minimum values from the left and right vectors
  61369. * @param left left vector to minimize
  61370. * @param right right vector to minimize
  61371. * @returns a new vector with the minimum of the left and right vector values
  61372. */
  61373. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61374. /**
  61375. * Returns a vector with the maximum values from the left and right vectors
  61376. * @param left left vector to maximize
  61377. * @param right right vector to maximize
  61378. * @returns a new vector with the maximum of the left and right vector values
  61379. */
  61380. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61381. /**
  61382. * Returns the distance (float) between the vectors "value1" and "value2".
  61383. * @param value1 value to calulate the distance between
  61384. * @param value2 value to calulate the distance between
  61385. * @return the distance between the two vectors
  61386. */
  61387. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61388. /**
  61389. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61390. * @param value1 value to calulate the distance between
  61391. * @param value2 value to calulate the distance between
  61392. * @return the distance between the two vectors squared
  61393. */
  61394. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61395. /**
  61396. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61397. * @param value1 value to calulate the center between
  61398. * @param value2 value to calulate the center between
  61399. * @return the center between the two vectors
  61400. */
  61401. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61402. /**
  61403. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61404. * This methods computes transformed normalized direction vectors only.
  61405. * @param vector the vector to transform
  61406. * @param transformation the transformation matrix to apply
  61407. * @returns the new vector
  61408. */
  61409. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61410. /**
  61411. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61412. * This methods computes transformed normalized direction vectors only.
  61413. * @param vector the vector to transform
  61414. * @param transformation the transformation matrix to apply
  61415. * @param result the vector to store the result in
  61416. */
  61417. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61418. /**
  61419. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61420. * This methods computes transformed normalized direction vectors only.
  61421. * @param x value to transform
  61422. * @param y value to transform
  61423. * @param z value to transform
  61424. * @param w value to transform
  61425. * @param transformation the transformation matrix to apply
  61426. * @param result the vector to store the results in
  61427. */
  61428. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61429. /**
  61430. * Creates a new Vector4 from a Vector3
  61431. * @param source defines the source data
  61432. * @param w defines the 4th component (default is 0)
  61433. * @returns a new Vector4
  61434. */
  61435. static FromVector3(source: Vector3, w?: number): Vector4;
  61436. }
  61437. /**
  61438. * Interface for the size containing width and height
  61439. */
  61440. export interface ISize {
  61441. /**
  61442. * Width
  61443. */
  61444. width: number;
  61445. /**
  61446. * Heighht
  61447. */
  61448. height: number;
  61449. }
  61450. /**
  61451. * Size containing widht and height
  61452. */
  61453. export class Size implements ISize {
  61454. /**
  61455. * Width
  61456. */
  61457. width: number;
  61458. /**
  61459. * Height
  61460. */
  61461. height: number;
  61462. /**
  61463. * Creates a Size object from the given width and height (floats).
  61464. * @param width width of the new size
  61465. * @param height height of the new size
  61466. */
  61467. constructor(width: number, height: number);
  61468. /**
  61469. * Returns a string with the Size width and height
  61470. * @returns a string with the Size width and height
  61471. */
  61472. toString(): string;
  61473. /**
  61474. * "Size"
  61475. * @returns the string "Size"
  61476. */
  61477. getClassName(): string;
  61478. /**
  61479. * Returns the Size hash code.
  61480. * @returns a hash code for a unique width and height
  61481. */
  61482. getHashCode(): number;
  61483. /**
  61484. * Updates the current size from the given one.
  61485. * @param src the given size
  61486. */
  61487. copyFrom(src: Size): void;
  61488. /**
  61489. * Updates in place the current Size from the given floats.
  61490. * @param width width of the new size
  61491. * @param height height of the new size
  61492. * @returns the updated Size.
  61493. */
  61494. copyFromFloats(width: number, height: number): Size;
  61495. /**
  61496. * Updates in place the current Size from the given floats.
  61497. * @param width width to set
  61498. * @param height height to set
  61499. * @returns the updated Size.
  61500. */
  61501. set(width: number, height: number): Size;
  61502. /**
  61503. * Multiplies the width and height by numbers
  61504. * @param w factor to multiple the width by
  61505. * @param h factor to multiple the height by
  61506. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61507. */
  61508. multiplyByFloats(w: number, h: number): Size;
  61509. /**
  61510. * Clones the size
  61511. * @returns a new Size copied from the given one.
  61512. */
  61513. clone(): Size;
  61514. /**
  61515. * True if the current Size and the given one width and height are strictly equal.
  61516. * @param other the other size to compare against
  61517. * @returns True if the current Size and the given one width and height are strictly equal.
  61518. */
  61519. equals(other: Size): boolean;
  61520. /**
  61521. * The surface of the Size : width * height (float).
  61522. */
  61523. readonly surface: number;
  61524. /**
  61525. * Create a new size of zero
  61526. * @returns a new Size set to (0.0, 0.0)
  61527. */
  61528. static Zero(): Size;
  61529. /**
  61530. * Sums the width and height of two sizes
  61531. * @param otherSize size to add to this size
  61532. * @returns a new Size set as the addition result of the current Size and the given one.
  61533. */
  61534. add(otherSize: Size): Size;
  61535. /**
  61536. * Subtracts the width and height of two
  61537. * @param otherSize size to subtract to this size
  61538. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61539. */
  61540. subtract(otherSize: Size): Size;
  61541. /**
  61542. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61543. * @param start starting size to lerp between
  61544. * @param end end size to lerp between
  61545. * @param amount amount to lerp between the start and end values
  61546. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61547. */
  61548. static Lerp(start: Size, end: Size, amount: number): Size;
  61549. }
  61550. /**
  61551. * Class used to store quaternion data
  61552. * @see https://en.wikipedia.org/wiki/Quaternion
  61553. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61554. */
  61555. export class Quaternion {
  61556. /** defines the first component (0 by default) */
  61557. x: number;
  61558. /** defines the second component (0 by default) */
  61559. y: number;
  61560. /** defines the third component (0 by default) */
  61561. z: number;
  61562. /** defines the fourth component (1.0 by default) */
  61563. w: number;
  61564. /**
  61565. * Creates a new Quaternion from the given floats
  61566. * @param x defines the first component (0 by default)
  61567. * @param y defines the second component (0 by default)
  61568. * @param z defines the third component (0 by default)
  61569. * @param w defines the fourth component (1.0 by default)
  61570. */
  61571. constructor(
  61572. /** defines the first component (0 by default) */
  61573. x?: number,
  61574. /** defines the second component (0 by default) */
  61575. y?: number,
  61576. /** defines the third component (0 by default) */
  61577. z?: number,
  61578. /** defines the fourth component (1.0 by default) */
  61579. w?: number);
  61580. /**
  61581. * Gets a string representation for the current quaternion
  61582. * @returns a string with the Quaternion coordinates
  61583. */
  61584. toString(): string;
  61585. /**
  61586. * Gets the class name of the quaternion
  61587. * @returns the string "Quaternion"
  61588. */
  61589. getClassName(): string;
  61590. /**
  61591. * Gets a hash code for this quaternion
  61592. * @returns the quaternion hash code
  61593. */
  61594. getHashCode(): number;
  61595. /**
  61596. * Copy the quaternion to an array
  61597. * @returns a new array populated with 4 elements from the quaternion coordinates
  61598. */
  61599. asArray(): number[];
  61600. /**
  61601. * Check if two quaternions are equals
  61602. * @param otherQuaternion defines the second operand
  61603. * @return true if the current quaternion and the given one coordinates are strictly equals
  61604. */
  61605. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61606. /**
  61607. * Clone the current quaternion
  61608. * @returns a new quaternion copied from the current one
  61609. */
  61610. clone(): Quaternion;
  61611. /**
  61612. * Copy a quaternion to the current one
  61613. * @param other defines the other quaternion
  61614. * @returns the updated current quaternion
  61615. */
  61616. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61617. /**
  61618. * Updates the current quaternion with the given float coordinates
  61619. * @param x defines the x coordinate
  61620. * @param y defines the y coordinate
  61621. * @param z defines the z coordinate
  61622. * @param w defines the w coordinate
  61623. * @returns the updated current quaternion
  61624. */
  61625. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61626. /**
  61627. * Updates the current quaternion from the given float coordinates
  61628. * @param x defines the x coordinate
  61629. * @param y defines the y coordinate
  61630. * @param z defines the z coordinate
  61631. * @param w defines the w coordinate
  61632. * @returns the updated current quaternion
  61633. */
  61634. set(x: number, y: number, z: number, w: number): Quaternion;
  61635. /**
  61636. * Adds two quaternions
  61637. * @param other defines the second operand
  61638. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61639. */
  61640. add(other: DeepImmutable<Quaternion>): Quaternion;
  61641. /**
  61642. * Add a quaternion to the current one
  61643. * @param other defines the quaternion to add
  61644. * @returns the current quaternion
  61645. */
  61646. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61647. /**
  61648. * Subtract two quaternions
  61649. * @param other defines the second operand
  61650. * @returns a new quaternion as the subtraction result of the given one from the current one
  61651. */
  61652. subtract(other: Quaternion): Quaternion;
  61653. /**
  61654. * Multiplies the current quaternion by a scale factor
  61655. * @param value defines the scale factor
  61656. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61657. */
  61658. scale(value: number): Quaternion;
  61659. /**
  61660. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61661. * @param scale defines the scale factor
  61662. * @param result defines the Quaternion object where to store the result
  61663. * @returns the unmodified current quaternion
  61664. */
  61665. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61666. /**
  61667. * Multiplies in place the current quaternion by a scale factor
  61668. * @param value defines the scale factor
  61669. * @returns the current modified quaternion
  61670. */
  61671. scaleInPlace(value: number): Quaternion;
  61672. /**
  61673. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61674. * @param scale defines the scale factor
  61675. * @param result defines the Quaternion object where to store the result
  61676. * @returns the unmodified current quaternion
  61677. */
  61678. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61679. /**
  61680. * Multiplies two quaternions
  61681. * @param q1 defines the second operand
  61682. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61683. */
  61684. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61685. /**
  61686. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61687. * @param q1 defines the second operand
  61688. * @param result defines the target quaternion
  61689. * @returns the current quaternion
  61690. */
  61691. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61692. /**
  61693. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61694. * @param q1 defines the second operand
  61695. * @returns the currentupdated quaternion
  61696. */
  61697. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61698. /**
  61699. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61700. * @param ref defines the target quaternion
  61701. * @returns the current quaternion
  61702. */
  61703. conjugateToRef(ref: Quaternion): Quaternion;
  61704. /**
  61705. * Conjugates in place (1-q) the current quaternion
  61706. * @returns the current updated quaternion
  61707. */
  61708. conjugateInPlace(): Quaternion;
  61709. /**
  61710. * Conjugates in place (1-q) the current quaternion
  61711. * @returns a new quaternion
  61712. */
  61713. conjugate(): Quaternion;
  61714. /**
  61715. * Gets length of current quaternion
  61716. * @returns the quaternion length (float)
  61717. */
  61718. length(): number;
  61719. /**
  61720. * Normalize in place the current quaternion
  61721. * @returns the current updated quaternion
  61722. */
  61723. normalize(): Quaternion;
  61724. /**
  61725. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61726. * @param order is a reserved parameter and is ignore for now
  61727. * @returns a new Vector3 containing the Euler angles
  61728. */
  61729. toEulerAngles(order?: string): Vector3;
  61730. /**
  61731. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61732. * @param result defines the vector which will be filled with the Euler angles
  61733. * @param order is a reserved parameter and is ignore for now
  61734. * @returns the current unchanged quaternion
  61735. */
  61736. toEulerAnglesToRef(result: Vector3): Quaternion;
  61737. /**
  61738. * Updates the given rotation matrix with the current quaternion values
  61739. * @param result defines the target matrix
  61740. * @returns the current unchanged quaternion
  61741. */
  61742. toRotationMatrix(result: Matrix): Quaternion;
  61743. /**
  61744. * Updates the current quaternion from the given rotation matrix values
  61745. * @param matrix defines the source matrix
  61746. * @returns the current updated quaternion
  61747. */
  61748. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61749. /**
  61750. * Creates a new quaternion from a rotation matrix
  61751. * @param matrix defines the source matrix
  61752. * @returns a new quaternion created from the given rotation matrix values
  61753. */
  61754. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61755. /**
  61756. * Updates the given quaternion with the given rotation matrix values
  61757. * @param matrix defines the source matrix
  61758. * @param result defines the target quaternion
  61759. */
  61760. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61761. /**
  61762. * Returns the dot product (float) between the quaternions "left" and "right"
  61763. * @param left defines the left operand
  61764. * @param right defines the right operand
  61765. * @returns the dot product
  61766. */
  61767. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61768. /**
  61769. * Checks if the two quaternions are close to each other
  61770. * @param quat0 defines the first quaternion to check
  61771. * @param quat1 defines the second quaternion to check
  61772. * @returns true if the two quaternions are close to each other
  61773. */
  61774. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61775. /**
  61776. * Creates an empty quaternion
  61777. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61778. */
  61779. static Zero(): Quaternion;
  61780. /**
  61781. * Inverse a given quaternion
  61782. * @param q defines the source quaternion
  61783. * @returns a new quaternion as the inverted current quaternion
  61784. */
  61785. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61786. /**
  61787. * Inverse a given quaternion
  61788. * @param q defines the source quaternion
  61789. * @param result the quaternion the result will be stored in
  61790. * @returns the result quaternion
  61791. */
  61792. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61793. /**
  61794. * Creates an identity quaternion
  61795. * @returns the identity quaternion
  61796. */
  61797. static Identity(): Quaternion;
  61798. /**
  61799. * Gets a boolean indicating if the given quaternion is identity
  61800. * @param quaternion defines the quaternion to check
  61801. * @returns true if the quaternion is identity
  61802. */
  61803. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61804. /**
  61805. * Creates a quaternion from a rotation around an axis
  61806. * @param axis defines the axis to use
  61807. * @param angle defines the angle to use
  61808. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61809. */
  61810. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61811. /**
  61812. * Creates a rotation around an axis and stores it into the given quaternion
  61813. * @param axis defines the axis to use
  61814. * @param angle defines the angle to use
  61815. * @param result defines the target quaternion
  61816. * @returns the target quaternion
  61817. */
  61818. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61819. /**
  61820. * Creates a new quaternion from data stored into an array
  61821. * @param array defines the data source
  61822. * @param offset defines the offset in the source array where the data starts
  61823. * @returns a new quaternion
  61824. */
  61825. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61826. /**
  61827. * Create a quaternion from Euler rotation angles
  61828. * @param x Pitch
  61829. * @param y Yaw
  61830. * @param z Roll
  61831. * @returns the new Quaternion
  61832. */
  61833. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61834. /**
  61835. * Updates a quaternion from Euler rotation angles
  61836. * @param x Pitch
  61837. * @param y Yaw
  61838. * @param z Roll
  61839. * @param result the quaternion to store the result
  61840. * @returns the updated quaternion
  61841. */
  61842. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61843. /**
  61844. * Create a quaternion from Euler rotation vector
  61845. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61846. * @returns the new Quaternion
  61847. */
  61848. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61849. /**
  61850. * Updates a quaternion from Euler rotation vector
  61851. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61852. * @param result the quaternion to store the result
  61853. * @returns the updated quaternion
  61854. */
  61855. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61856. /**
  61857. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61858. * @param yaw defines the rotation around Y axis
  61859. * @param pitch defines the rotation around X axis
  61860. * @param roll defines the rotation around Z axis
  61861. * @returns the new quaternion
  61862. */
  61863. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61864. /**
  61865. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61866. * @param yaw defines the rotation around Y axis
  61867. * @param pitch defines the rotation around X axis
  61868. * @param roll defines the rotation around Z axis
  61869. * @param result defines the target quaternion
  61870. */
  61871. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61872. /**
  61873. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61874. * @param alpha defines the rotation around first axis
  61875. * @param beta defines the rotation around second axis
  61876. * @param gamma defines the rotation around third axis
  61877. * @returns the new quaternion
  61878. */
  61879. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61880. /**
  61881. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61882. * @param alpha defines the rotation around first axis
  61883. * @param beta defines the rotation around second axis
  61884. * @param gamma defines the rotation around third axis
  61885. * @param result defines the target quaternion
  61886. */
  61887. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61888. /**
  61889. * 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)
  61890. * @param axis1 defines the first axis
  61891. * @param axis2 defines the second axis
  61892. * @param axis3 defines the third axis
  61893. * @returns the new quaternion
  61894. */
  61895. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61896. /**
  61897. * 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
  61898. * @param axis1 defines the first axis
  61899. * @param axis2 defines the second axis
  61900. * @param axis3 defines the third axis
  61901. * @param ref defines the target quaternion
  61902. */
  61903. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61904. /**
  61905. * Interpolates between two quaternions
  61906. * @param left defines first quaternion
  61907. * @param right defines second quaternion
  61908. * @param amount defines the gradient to use
  61909. * @returns the new interpolated quaternion
  61910. */
  61911. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61912. /**
  61913. * Interpolates between two quaternions and stores it into a target quaternion
  61914. * @param left defines first quaternion
  61915. * @param right defines second quaternion
  61916. * @param amount defines the gradient to use
  61917. * @param result defines the target quaternion
  61918. */
  61919. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61920. /**
  61921. * Interpolate between two quaternions using Hermite interpolation
  61922. * @param value1 defines first quaternion
  61923. * @param tangent1 defines the incoming tangent
  61924. * @param value2 defines second quaternion
  61925. * @param tangent2 defines the outgoing tangent
  61926. * @param amount defines the target quaternion
  61927. * @returns the new interpolated quaternion
  61928. */
  61929. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61930. }
  61931. /**
  61932. * Class used to store matrix data (4x4)
  61933. */
  61934. export class Matrix {
  61935. private static _updateFlagSeed;
  61936. private static _identityReadOnly;
  61937. private _isIdentity;
  61938. private _isIdentityDirty;
  61939. private _isIdentity3x2;
  61940. private _isIdentity3x2Dirty;
  61941. /**
  61942. * Gets the update flag of the matrix which is an unique number for the matrix.
  61943. * It will be incremented every time the matrix data change.
  61944. * You can use it to speed the comparison between two versions of the same matrix.
  61945. */
  61946. updateFlag: number;
  61947. private readonly _m;
  61948. /**
  61949. * Gets the internal data of the matrix
  61950. */
  61951. readonly m: DeepImmutable<Float32Array>;
  61952. /** @hidden */
  61953. _markAsUpdated(): void;
  61954. /** @hidden */
  61955. private _updateIdentityStatus;
  61956. /**
  61957. * Creates an empty matrix (filled with zeros)
  61958. */
  61959. constructor();
  61960. /**
  61961. * Check if the current matrix is identity
  61962. * @returns true is the matrix is the identity matrix
  61963. */
  61964. isIdentity(): boolean;
  61965. /**
  61966. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61967. * @returns true is the matrix is the identity matrix
  61968. */
  61969. isIdentityAs3x2(): boolean;
  61970. /**
  61971. * Gets the determinant of the matrix
  61972. * @returns the matrix determinant
  61973. */
  61974. determinant(): number;
  61975. /**
  61976. * Returns the matrix as a Float32Array
  61977. * @returns the matrix underlying array
  61978. */
  61979. toArray(): DeepImmutable<Float32Array>;
  61980. /**
  61981. * Returns the matrix as a Float32Array
  61982. * @returns the matrix underlying array.
  61983. */
  61984. asArray(): DeepImmutable<Float32Array>;
  61985. /**
  61986. * Inverts the current matrix in place
  61987. * @returns the current inverted matrix
  61988. */
  61989. invert(): Matrix;
  61990. /**
  61991. * Sets all the matrix elements to zero
  61992. * @returns the current matrix
  61993. */
  61994. reset(): Matrix;
  61995. /**
  61996. * Adds the current matrix with a second one
  61997. * @param other defines the matrix to add
  61998. * @returns a new matrix as the addition of the current matrix and the given one
  61999. */
  62000. add(other: DeepImmutable<Matrix>): Matrix;
  62001. /**
  62002. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62003. * @param other defines the matrix to add
  62004. * @param result defines the target matrix
  62005. * @returns the current matrix
  62006. */
  62007. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62008. /**
  62009. * Adds in place the given matrix to the current matrix
  62010. * @param other defines the second operand
  62011. * @returns the current updated matrix
  62012. */
  62013. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62014. /**
  62015. * Sets the given matrix to the current inverted Matrix
  62016. * @param other defines the target matrix
  62017. * @returns the unmodified current matrix
  62018. */
  62019. invertToRef(other: Matrix): Matrix;
  62020. /**
  62021. * add a value at the specified position in the current Matrix
  62022. * @param index the index of the value within the matrix. between 0 and 15.
  62023. * @param value the value to be added
  62024. * @returns the current updated matrix
  62025. */
  62026. addAtIndex(index: number, value: number): Matrix;
  62027. /**
  62028. * mutiply the specified position in the current Matrix by a value
  62029. * @param index the index of the value within the matrix. between 0 and 15.
  62030. * @param value the value to be added
  62031. * @returns the current updated matrix
  62032. */
  62033. multiplyAtIndex(index: number, value: number): Matrix;
  62034. /**
  62035. * Inserts the translation vector (using 3 floats) in the current matrix
  62036. * @param x defines the 1st component of the translation
  62037. * @param y defines the 2nd component of the translation
  62038. * @param z defines the 3rd component of the translation
  62039. * @returns the current updated matrix
  62040. */
  62041. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62042. /**
  62043. * Inserts the translation vector in the current matrix
  62044. * @param vector3 defines the translation to insert
  62045. * @returns the current updated matrix
  62046. */
  62047. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62048. /**
  62049. * Gets the translation value of the current matrix
  62050. * @returns a new Vector3 as the extracted translation from the matrix
  62051. */
  62052. getTranslation(): Vector3;
  62053. /**
  62054. * Fill a Vector3 with the extracted translation from the matrix
  62055. * @param result defines the Vector3 where to store the translation
  62056. * @returns the current matrix
  62057. */
  62058. getTranslationToRef(result: Vector3): Matrix;
  62059. /**
  62060. * Remove rotation and scaling part from the matrix
  62061. * @returns the updated matrix
  62062. */
  62063. removeRotationAndScaling(): Matrix;
  62064. /**
  62065. * Multiply two matrices
  62066. * @param other defines the second operand
  62067. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62068. */
  62069. multiply(other: DeepImmutable<Matrix>): Matrix;
  62070. /**
  62071. * Copy the current matrix from the given one
  62072. * @param other defines the source matrix
  62073. * @returns the current updated matrix
  62074. */
  62075. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62076. /**
  62077. * Populates the given array from the starting index with the current matrix values
  62078. * @param array defines the target array
  62079. * @param offset defines the offset in the target array where to start storing values
  62080. * @returns the current matrix
  62081. */
  62082. copyToArray(array: Float32Array, offset?: number): Matrix;
  62083. /**
  62084. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62085. * @param other defines the second operand
  62086. * @param result defines the matrix where to store the multiplication
  62087. * @returns the current matrix
  62088. */
  62089. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62090. /**
  62091. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62092. * @param other defines the second operand
  62093. * @param result defines the array where to store the multiplication
  62094. * @param offset defines the offset in the target array where to start storing values
  62095. * @returns the current matrix
  62096. */
  62097. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62098. /**
  62099. * Check equality between this matrix and a second one
  62100. * @param value defines the second matrix to compare
  62101. * @returns true is the current matrix and the given one values are strictly equal
  62102. */
  62103. equals(value: DeepImmutable<Matrix>): boolean;
  62104. /**
  62105. * Clone the current matrix
  62106. * @returns a new matrix from the current matrix
  62107. */
  62108. clone(): Matrix;
  62109. /**
  62110. * Returns the name of the current matrix class
  62111. * @returns the string "Matrix"
  62112. */
  62113. getClassName(): string;
  62114. /**
  62115. * Gets the hash code of the current matrix
  62116. * @returns the hash code
  62117. */
  62118. getHashCode(): number;
  62119. /**
  62120. * Decomposes the current Matrix into a translation, rotation and scaling components
  62121. * @param scale defines the scale vector3 given as a reference to update
  62122. * @param rotation defines the rotation quaternion given as a reference to update
  62123. * @param translation defines the translation vector3 given as a reference to update
  62124. * @returns true if operation was successful
  62125. */
  62126. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62127. /**
  62128. * Gets specific row of the matrix
  62129. * @param index defines the number of the row to get
  62130. * @returns the index-th row of the current matrix as a new Vector4
  62131. */
  62132. getRow(index: number): Nullable<Vector4>;
  62133. /**
  62134. * Sets the index-th row of the current matrix to the vector4 values
  62135. * @param index defines the number of the row to set
  62136. * @param row defines the target vector4
  62137. * @returns the updated current matrix
  62138. */
  62139. setRow(index: number, row: Vector4): Matrix;
  62140. /**
  62141. * Compute the transpose of the matrix
  62142. * @returns the new transposed matrix
  62143. */
  62144. transpose(): Matrix;
  62145. /**
  62146. * Compute the transpose of the matrix and store it in a given matrix
  62147. * @param result defines the target matrix
  62148. * @returns the current matrix
  62149. */
  62150. transposeToRef(result: Matrix): Matrix;
  62151. /**
  62152. * Sets the index-th row of the current matrix with the given 4 x float values
  62153. * @param index defines the row index
  62154. * @param x defines the x component to set
  62155. * @param y defines the y component to set
  62156. * @param z defines the z component to set
  62157. * @param w defines the w component to set
  62158. * @returns the updated current matrix
  62159. */
  62160. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62161. /**
  62162. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62163. * @param scale defines the scale factor
  62164. * @returns a new matrix
  62165. */
  62166. scale(scale: number): Matrix;
  62167. /**
  62168. * Scale the current matrix values by a factor to a given result matrix
  62169. * @param scale defines the scale factor
  62170. * @param result defines the matrix to store the result
  62171. * @returns the current matrix
  62172. */
  62173. scaleToRef(scale: number, result: Matrix): Matrix;
  62174. /**
  62175. * Scale the current matrix values by a factor and add the result to a given matrix
  62176. * @param scale defines the scale factor
  62177. * @param result defines the Matrix to store the result
  62178. * @returns the current matrix
  62179. */
  62180. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62181. /**
  62182. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62183. * @param ref matrix to store the result
  62184. */
  62185. toNormalMatrix(ref: Matrix): void;
  62186. /**
  62187. * Gets only rotation part of the current matrix
  62188. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62189. */
  62190. getRotationMatrix(): Matrix;
  62191. /**
  62192. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62193. * @param result defines the target matrix to store data to
  62194. * @returns the current matrix
  62195. */
  62196. getRotationMatrixToRef(result: Matrix): Matrix;
  62197. /**
  62198. * Toggles model matrix from being right handed to left handed in place and vice versa
  62199. */
  62200. toggleModelMatrixHandInPlace(): void;
  62201. /**
  62202. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62203. */
  62204. toggleProjectionMatrixHandInPlace(): void;
  62205. /**
  62206. * Creates a matrix from an array
  62207. * @param array defines the source array
  62208. * @param offset defines an offset in the source array
  62209. * @returns a new Matrix set from the starting index of the given array
  62210. */
  62211. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62212. /**
  62213. * Copy the content of an array into a given matrix
  62214. * @param array defines the source array
  62215. * @param offset defines an offset in the source array
  62216. * @param result defines the target matrix
  62217. */
  62218. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62219. /**
  62220. * Stores an array into a matrix after having multiplied each component by a given factor
  62221. * @param array defines the source array
  62222. * @param offset defines the offset in the source array
  62223. * @param scale defines the scaling factor
  62224. * @param result defines the target matrix
  62225. */
  62226. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62227. /**
  62228. * Gets an identity matrix that must not be updated
  62229. */
  62230. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62231. /**
  62232. * Stores a list of values (16) inside a given matrix
  62233. * @param initialM11 defines 1st value of 1st row
  62234. * @param initialM12 defines 2nd value of 1st row
  62235. * @param initialM13 defines 3rd value of 1st row
  62236. * @param initialM14 defines 4th value of 1st row
  62237. * @param initialM21 defines 1st value of 2nd row
  62238. * @param initialM22 defines 2nd value of 2nd row
  62239. * @param initialM23 defines 3rd value of 2nd row
  62240. * @param initialM24 defines 4th value of 2nd row
  62241. * @param initialM31 defines 1st value of 3rd row
  62242. * @param initialM32 defines 2nd value of 3rd row
  62243. * @param initialM33 defines 3rd value of 3rd row
  62244. * @param initialM34 defines 4th value of 3rd row
  62245. * @param initialM41 defines 1st value of 4th row
  62246. * @param initialM42 defines 2nd value of 4th row
  62247. * @param initialM43 defines 3rd value of 4th row
  62248. * @param initialM44 defines 4th value of 4th row
  62249. * @param result defines the target matrix
  62250. */
  62251. 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;
  62252. /**
  62253. * Creates new matrix from a list of values (16)
  62254. * @param initialM11 defines 1st value of 1st row
  62255. * @param initialM12 defines 2nd value of 1st row
  62256. * @param initialM13 defines 3rd value of 1st row
  62257. * @param initialM14 defines 4th value of 1st row
  62258. * @param initialM21 defines 1st value of 2nd row
  62259. * @param initialM22 defines 2nd value of 2nd row
  62260. * @param initialM23 defines 3rd value of 2nd row
  62261. * @param initialM24 defines 4th value of 2nd row
  62262. * @param initialM31 defines 1st value of 3rd row
  62263. * @param initialM32 defines 2nd value of 3rd row
  62264. * @param initialM33 defines 3rd value of 3rd row
  62265. * @param initialM34 defines 4th value of 3rd row
  62266. * @param initialM41 defines 1st value of 4th row
  62267. * @param initialM42 defines 2nd value of 4th row
  62268. * @param initialM43 defines 3rd value of 4th row
  62269. * @param initialM44 defines 4th value of 4th row
  62270. * @returns the new matrix
  62271. */
  62272. 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;
  62273. /**
  62274. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62275. * @param scale defines the scale vector3
  62276. * @param rotation defines the rotation quaternion
  62277. * @param translation defines the translation vector3
  62278. * @returns a new matrix
  62279. */
  62280. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62281. /**
  62282. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62283. * @param scale defines the scale vector3
  62284. * @param rotation defines the rotation quaternion
  62285. * @param translation defines the translation vector3
  62286. * @param result defines the target matrix
  62287. */
  62288. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62289. /**
  62290. * Creates a new identity matrix
  62291. * @returns a new identity matrix
  62292. */
  62293. static Identity(): Matrix;
  62294. /**
  62295. * Creates a new identity matrix and stores the result in a given matrix
  62296. * @param result defines the target matrix
  62297. */
  62298. static IdentityToRef(result: Matrix): void;
  62299. /**
  62300. * Creates a new zero matrix
  62301. * @returns a new zero matrix
  62302. */
  62303. static Zero(): Matrix;
  62304. /**
  62305. * Creates a new rotation matrix for "angle" radians around the X axis
  62306. * @param angle defines the angle (in radians) to use
  62307. * @return the new matrix
  62308. */
  62309. static RotationX(angle: number): Matrix;
  62310. /**
  62311. * Creates a new matrix as the invert of a given matrix
  62312. * @param source defines the source matrix
  62313. * @returns the new matrix
  62314. */
  62315. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62316. /**
  62317. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62318. * @param angle defines the angle (in radians) to use
  62319. * @param result defines the target matrix
  62320. */
  62321. static RotationXToRef(angle: number, result: Matrix): void;
  62322. /**
  62323. * Creates a new rotation matrix for "angle" radians around the Y axis
  62324. * @param angle defines the angle (in radians) to use
  62325. * @return the new matrix
  62326. */
  62327. static RotationY(angle: number): Matrix;
  62328. /**
  62329. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62330. * @param angle defines the angle (in radians) to use
  62331. * @param result defines the target matrix
  62332. */
  62333. static RotationYToRef(angle: number, result: Matrix): void;
  62334. /**
  62335. * Creates a new rotation matrix for "angle" radians around the Z axis
  62336. * @param angle defines the angle (in radians) to use
  62337. * @return the new matrix
  62338. */
  62339. static RotationZ(angle: number): Matrix;
  62340. /**
  62341. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62342. * @param angle defines the angle (in radians) to use
  62343. * @param result defines the target matrix
  62344. */
  62345. static RotationZToRef(angle: number, result: Matrix): void;
  62346. /**
  62347. * Creates a new rotation matrix for "angle" radians around the given axis
  62348. * @param axis defines the axis to use
  62349. * @param angle defines the angle (in radians) to use
  62350. * @return the new matrix
  62351. */
  62352. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62353. /**
  62354. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62355. * @param axis defines the axis to use
  62356. * @param angle defines the angle (in radians) to use
  62357. * @param result defines the target matrix
  62358. */
  62359. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62360. /**
  62361. * Creates a rotation matrix
  62362. * @param yaw defines the yaw angle in radians (Y axis)
  62363. * @param pitch defines the pitch angle in radians (X axis)
  62364. * @param roll defines the roll angle in radians (X axis)
  62365. * @returns the new rotation matrix
  62366. */
  62367. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62368. /**
  62369. * Creates a rotation matrix and stores it in a given matrix
  62370. * @param yaw defines the yaw angle in radians (Y axis)
  62371. * @param pitch defines the pitch angle in radians (X axis)
  62372. * @param roll defines the roll angle in radians (X axis)
  62373. * @param result defines the target matrix
  62374. */
  62375. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62376. /**
  62377. * Creates a scaling matrix
  62378. * @param x defines the scale factor on X axis
  62379. * @param y defines the scale factor on Y axis
  62380. * @param z defines the scale factor on Z axis
  62381. * @returns the new matrix
  62382. */
  62383. static Scaling(x: number, y: number, z: number): Matrix;
  62384. /**
  62385. * Creates a scaling matrix and stores it in a given matrix
  62386. * @param x defines the scale factor on X axis
  62387. * @param y defines the scale factor on Y axis
  62388. * @param z defines the scale factor on Z axis
  62389. * @param result defines the target matrix
  62390. */
  62391. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62392. /**
  62393. * Creates a translation matrix
  62394. * @param x defines the translation on X axis
  62395. * @param y defines the translation on Y axis
  62396. * @param z defines the translationon Z axis
  62397. * @returns the new matrix
  62398. */
  62399. static Translation(x: number, y: number, z: number): Matrix;
  62400. /**
  62401. * Creates a translation matrix and stores it in a given matrix
  62402. * @param x defines the translation on X axis
  62403. * @param y defines the translation on Y axis
  62404. * @param z defines the translationon Z axis
  62405. * @param result defines the target matrix
  62406. */
  62407. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62408. /**
  62409. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62410. * @param startValue defines the start value
  62411. * @param endValue defines the end value
  62412. * @param gradient defines the gradient factor
  62413. * @returns the new matrix
  62414. */
  62415. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62416. /**
  62417. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62418. * @param startValue defines the start value
  62419. * @param endValue defines the end value
  62420. * @param gradient defines the gradient factor
  62421. * @param result defines the Matrix object where to store data
  62422. */
  62423. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62424. /**
  62425. * Builds a new matrix whose values are computed by:
  62426. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62427. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62428. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62429. * @param startValue defines the first matrix
  62430. * @param endValue defines the second matrix
  62431. * @param gradient defines the gradient between the two matrices
  62432. * @returns the new matrix
  62433. */
  62434. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62435. /**
  62436. * Update a matrix to values which are computed by:
  62437. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62438. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62439. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62440. * @param startValue defines the first matrix
  62441. * @param endValue defines the second matrix
  62442. * @param gradient defines the gradient between the two matrices
  62443. * @param result defines the target matrix
  62444. */
  62445. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62446. /**
  62447. * 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"
  62448. * This function works in left handed mode
  62449. * @param eye defines the final position of the entity
  62450. * @param target defines where the entity should look at
  62451. * @param up defines the up vector for the entity
  62452. * @returns the new matrix
  62453. */
  62454. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62455. /**
  62456. * 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".
  62457. * This function works in left handed mode
  62458. * @param eye defines the final position of the entity
  62459. * @param target defines where the entity should look at
  62460. * @param up defines the up vector for the entity
  62461. * @param result defines the target matrix
  62462. */
  62463. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62464. /**
  62465. * 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"
  62466. * This function works in right handed mode
  62467. * @param eye defines the final position of the entity
  62468. * @param target defines where the entity should look at
  62469. * @param up defines the up vector for the entity
  62470. * @returns the new matrix
  62471. */
  62472. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62473. /**
  62474. * 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".
  62475. * This function works in right handed mode
  62476. * @param eye defines the final position of the entity
  62477. * @param target defines where the entity should look at
  62478. * @param up defines the up vector for the entity
  62479. * @param result defines the target matrix
  62480. */
  62481. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62482. /**
  62483. * Create a left-handed orthographic projection matrix
  62484. * @param width defines the viewport width
  62485. * @param height defines the viewport height
  62486. * @param znear defines the near clip plane
  62487. * @param zfar defines the far clip plane
  62488. * @returns a new matrix as a left-handed orthographic projection matrix
  62489. */
  62490. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62491. /**
  62492. * Store a left-handed orthographic projection to a given matrix
  62493. * @param width defines the viewport width
  62494. * @param height defines the viewport height
  62495. * @param znear defines the near clip plane
  62496. * @param zfar defines the far clip plane
  62497. * @param result defines the target matrix
  62498. */
  62499. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62500. /**
  62501. * Create a left-handed orthographic projection matrix
  62502. * @param left defines the viewport left coordinate
  62503. * @param right defines the viewport right coordinate
  62504. * @param bottom defines the viewport bottom coordinate
  62505. * @param top defines the viewport top coordinate
  62506. * @param znear defines the near clip plane
  62507. * @param zfar defines the far clip plane
  62508. * @returns a new matrix as a left-handed orthographic projection matrix
  62509. */
  62510. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62511. /**
  62512. * Stores a left-handed orthographic projection into a given matrix
  62513. * @param left defines the viewport left coordinate
  62514. * @param right defines the viewport right coordinate
  62515. * @param bottom defines the viewport bottom coordinate
  62516. * @param top defines the viewport top coordinate
  62517. * @param znear defines the near clip plane
  62518. * @param zfar defines the far clip plane
  62519. * @param result defines the target matrix
  62520. */
  62521. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62522. /**
  62523. * Creates a right-handed orthographic projection matrix
  62524. * @param left defines the viewport left coordinate
  62525. * @param right defines the viewport right coordinate
  62526. * @param bottom defines the viewport bottom coordinate
  62527. * @param top defines the viewport top coordinate
  62528. * @param znear defines the near clip plane
  62529. * @param zfar defines the far clip plane
  62530. * @returns a new matrix as a right-handed orthographic projection matrix
  62531. */
  62532. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62533. /**
  62534. * Stores a right-handed orthographic projection into a given matrix
  62535. * @param left defines the viewport left coordinate
  62536. * @param right defines the viewport right coordinate
  62537. * @param bottom defines the viewport bottom coordinate
  62538. * @param top defines the viewport top coordinate
  62539. * @param znear defines the near clip plane
  62540. * @param zfar defines the far clip plane
  62541. * @param result defines the target matrix
  62542. */
  62543. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62544. /**
  62545. * Creates a left-handed perspective projection matrix
  62546. * @param width defines the viewport width
  62547. * @param height defines the viewport height
  62548. * @param znear defines the near clip plane
  62549. * @param zfar defines the far clip plane
  62550. * @returns a new matrix as a left-handed perspective projection matrix
  62551. */
  62552. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62553. /**
  62554. * Creates a left-handed perspective projection matrix
  62555. * @param fov defines the horizontal field of view
  62556. * @param aspect defines the aspect ratio
  62557. * @param znear defines the near clip plane
  62558. * @param zfar defines the far clip plane
  62559. * @returns a new matrix as a left-handed perspective projection matrix
  62560. */
  62561. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62562. /**
  62563. * Stores a left-handed perspective projection into a given matrix
  62564. * @param fov defines the horizontal field of view
  62565. * @param aspect defines the aspect ratio
  62566. * @param znear defines the near clip plane
  62567. * @param zfar defines the far clip plane
  62568. * @param result defines the target matrix
  62569. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62570. */
  62571. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62572. /**
  62573. * Creates a right-handed perspective projection matrix
  62574. * @param fov defines the horizontal field of view
  62575. * @param aspect defines the aspect ratio
  62576. * @param znear defines the near clip plane
  62577. * @param zfar defines the far clip plane
  62578. * @returns a new matrix as a right-handed perspective projection matrix
  62579. */
  62580. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62581. /**
  62582. * Stores a right-handed perspective projection into a given matrix
  62583. * @param fov defines the horizontal field of view
  62584. * @param aspect defines the aspect ratio
  62585. * @param znear defines the near clip plane
  62586. * @param zfar defines the far clip plane
  62587. * @param result defines the target matrix
  62588. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62589. */
  62590. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62591. /**
  62592. * Stores a perspective projection for WebVR info a given matrix
  62593. * @param fov defines the field of view
  62594. * @param znear defines the near clip plane
  62595. * @param zfar defines the far clip plane
  62596. * @param result defines the target matrix
  62597. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62598. */
  62599. static PerspectiveFovWebVRToRef(fov: {
  62600. upDegrees: number;
  62601. downDegrees: number;
  62602. leftDegrees: number;
  62603. rightDegrees: number;
  62604. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62605. /**
  62606. * Computes a complete transformation matrix
  62607. * @param viewport defines the viewport to use
  62608. * @param world defines the world matrix
  62609. * @param view defines the view matrix
  62610. * @param projection defines the projection matrix
  62611. * @param zmin defines the near clip plane
  62612. * @param zmax defines the far clip plane
  62613. * @returns the transformation matrix
  62614. */
  62615. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62616. /**
  62617. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62618. * @param matrix defines the matrix to use
  62619. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62620. */
  62621. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62622. /**
  62623. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62624. * @param matrix defines the matrix to use
  62625. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62626. */
  62627. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62628. /**
  62629. * Compute the transpose of a given matrix
  62630. * @param matrix defines the matrix to transpose
  62631. * @returns the new matrix
  62632. */
  62633. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62634. /**
  62635. * Compute the transpose of a matrix and store it in a target matrix
  62636. * @param matrix defines the matrix to transpose
  62637. * @param result defines the target matrix
  62638. */
  62639. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62640. /**
  62641. * Computes a reflection matrix from a plane
  62642. * @param plane defines the reflection plane
  62643. * @returns a new matrix
  62644. */
  62645. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62646. /**
  62647. * Computes a reflection matrix from a plane
  62648. * @param plane defines the reflection plane
  62649. * @param result defines the target matrix
  62650. */
  62651. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62652. /**
  62653. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62654. * @param xaxis defines the value of the 1st axis
  62655. * @param yaxis defines the value of the 2nd axis
  62656. * @param zaxis defines the value of the 3rd axis
  62657. * @param result defines the target matrix
  62658. */
  62659. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62660. /**
  62661. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62662. * @param quat defines the quaternion to use
  62663. * @param result defines the target matrix
  62664. */
  62665. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62666. }
  62667. /**
  62668. * Represens a plane by the equation ax + by + cz + d = 0
  62669. */
  62670. export class Plane {
  62671. /**
  62672. * Normal of the plane (a,b,c)
  62673. */
  62674. normal: Vector3;
  62675. /**
  62676. * d component of the plane
  62677. */
  62678. d: number;
  62679. /**
  62680. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62681. * @param a a component of the plane
  62682. * @param b b component of the plane
  62683. * @param c c component of the plane
  62684. * @param d d component of the plane
  62685. */
  62686. constructor(a: number, b: number, c: number, d: number);
  62687. /**
  62688. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62689. */
  62690. asArray(): number[];
  62691. /**
  62692. * @returns a new plane copied from the current Plane.
  62693. */
  62694. clone(): Plane;
  62695. /**
  62696. * @returns the string "Plane".
  62697. */
  62698. getClassName(): string;
  62699. /**
  62700. * @returns the Plane hash code.
  62701. */
  62702. getHashCode(): number;
  62703. /**
  62704. * Normalize the current Plane in place.
  62705. * @returns the updated Plane.
  62706. */
  62707. normalize(): Plane;
  62708. /**
  62709. * Applies a transformation the plane and returns the result
  62710. * @param transformation the transformation matrix to be applied to the plane
  62711. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62712. */
  62713. transform(transformation: DeepImmutable<Matrix>): Plane;
  62714. /**
  62715. * Calcualtte the dot product between the point and the plane normal
  62716. * @param point point to calculate the dot product with
  62717. * @returns the dot product (float) of the point coordinates and the plane normal.
  62718. */
  62719. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62720. /**
  62721. * Updates the current Plane from the plane defined by the three given points.
  62722. * @param point1 one of the points used to contruct the plane
  62723. * @param point2 one of the points used to contruct the plane
  62724. * @param point3 one of the points used to contruct the plane
  62725. * @returns the updated Plane.
  62726. */
  62727. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62728. /**
  62729. * Checks if the plane is facing a given direction
  62730. * @param direction the direction to check if the plane is facing
  62731. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62732. * @returns True is the vector "direction" is the same side than the plane normal.
  62733. */
  62734. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62735. /**
  62736. * Calculates the distance to a point
  62737. * @param point point to calculate distance to
  62738. * @returns the signed distance (float) from the given point to the Plane.
  62739. */
  62740. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62741. /**
  62742. * Creates a plane from an array
  62743. * @param array the array to create a plane from
  62744. * @returns a new Plane from the given array.
  62745. */
  62746. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62747. /**
  62748. * Creates a plane from three points
  62749. * @param point1 point used to create the plane
  62750. * @param point2 point used to create the plane
  62751. * @param point3 point used to create the plane
  62752. * @returns a new Plane defined by the three given points.
  62753. */
  62754. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62755. /**
  62756. * Creates a plane from an origin point and a normal
  62757. * @param origin origin of the plane to be constructed
  62758. * @param normal normal of the plane to be constructed
  62759. * @returns a new Plane the normal vector to this plane at the given origin point.
  62760. * Note : the vector "normal" is updated because normalized.
  62761. */
  62762. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62763. /**
  62764. * Calculates the distance from a plane and a point
  62765. * @param origin origin of the plane to be constructed
  62766. * @param normal normal of the plane to be constructed
  62767. * @param point point to calculate distance to
  62768. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62769. */
  62770. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62771. }
  62772. /**
  62773. * Class used to represent a viewport on screen
  62774. */
  62775. export class Viewport {
  62776. /** viewport left coordinate */
  62777. x: number;
  62778. /** viewport top coordinate */
  62779. y: number;
  62780. /**viewport width */
  62781. width: number;
  62782. /** viewport height */
  62783. height: number;
  62784. /**
  62785. * Creates a Viewport object located at (x, y) and sized (width, height)
  62786. * @param x defines viewport left coordinate
  62787. * @param y defines viewport top coordinate
  62788. * @param width defines the viewport width
  62789. * @param height defines the viewport height
  62790. */
  62791. constructor(
  62792. /** viewport left coordinate */
  62793. x: number,
  62794. /** viewport top coordinate */
  62795. y: number,
  62796. /**viewport width */
  62797. width: number,
  62798. /** viewport height */
  62799. height: number);
  62800. /**
  62801. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62802. * @param renderWidth defines the rendering width
  62803. * @param renderHeight defines the rendering height
  62804. * @returns a new Viewport
  62805. */
  62806. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62807. /**
  62808. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62809. * @param renderWidth defines the rendering width
  62810. * @param renderHeight defines the rendering height
  62811. * @param ref defines the target viewport
  62812. * @returns the current viewport
  62813. */
  62814. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62815. /**
  62816. * Returns a new Viewport copied from the current one
  62817. * @returns a new Viewport
  62818. */
  62819. clone(): Viewport;
  62820. }
  62821. /**
  62822. * Reprasents a camera frustum
  62823. */
  62824. export class Frustum {
  62825. /**
  62826. * Gets the planes representing the frustum
  62827. * @param transform matrix to be applied to the returned planes
  62828. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62829. */
  62830. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62831. /**
  62832. * Gets the near frustum plane transformed by the transform matrix
  62833. * @param transform transformation matrix to be applied to the resulting frustum plane
  62834. * @param frustumPlane the resuling frustum plane
  62835. */
  62836. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62837. /**
  62838. * Gets the far frustum plane transformed by the transform matrix
  62839. * @param transform transformation matrix to be applied to the resulting frustum plane
  62840. * @param frustumPlane the resuling frustum plane
  62841. */
  62842. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62843. /**
  62844. * Gets the left frustum plane transformed by the transform matrix
  62845. * @param transform transformation matrix to be applied to the resulting frustum plane
  62846. * @param frustumPlane the resuling frustum plane
  62847. */
  62848. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62849. /**
  62850. * Gets the right frustum plane transformed by the transform matrix
  62851. * @param transform transformation matrix to be applied to the resulting frustum plane
  62852. * @param frustumPlane the resuling frustum plane
  62853. */
  62854. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62855. /**
  62856. * Gets the top frustum plane transformed by the transform matrix
  62857. * @param transform transformation matrix to be applied to the resulting frustum plane
  62858. * @param frustumPlane the resuling frustum plane
  62859. */
  62860. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62861. /**
  62862. * Gets the bottom frustum plane transformed by the transform matrix
  62863. * @param transform transformation matrix to be applied to the resulting frustum plane
  62864. * @param frustumPlane the resuling frustum plane
  62865. */
  62866. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62867. /**
  62868. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62869. * @param transform transformation matrix to be applied to the resulting frustum planes
  62870. * @param frustumPlanes the resuling frustum planes
  62871. */
  62872. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62873. }
  62874. /** Defines supported spaces */
  62875. export enum Space {
  62876. /** Local (object) space */
  62877. LOCAL = 0,
  62878. /** World space */
  62879. WORLD = 1,
  62880. /** Bone space */
  62881. BONE = 2
  62882. }
  62883. /** Defines the 3 main axes */
  62884. export class Axis {
  62885. /** X axis */
  62886. static X: Vector3;
  62887. /** Y axis */
  62888. static Y: Vector3;
  62889. /** Z axis */
  62890. static Z: Vector3;
  62891. }
  62892. /** Class used to represent a Bezier curve */
  62893. export class BezierCurve {
  62894. /**
  62895. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62896. * @param t defines the time
  62897. * @param x1 defines the left coordinate on X axis
  62898. * @param y1 defines the left coordinate on Y axis
  62899. * @param x2 defines the right coordinate on X axis
  62900. * @param y2 defines the right coordinate on Y axis
  62901. * @returns the interpolated value
  62902. */
  62903. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62904. }
  62905. /**
  62906. * Defines potential orientation for back face culling
  62907. */
  62908. export enum Orientation {
  62909. /**
  62910. * Clockwise
  62911. */
  62912. CW = 0,
  62913. /** Counter clockwise */
  62914. CCW = 1
  62915. }
  62916. /**
  62917. * Defines angle representation
  62918. */
  62919. export class Angle {
  62920. private _radians;
  62921. /**
  62922. * Creates an Angle object of "radians" radians (float).
  62923. * @param radians the angle in radians
  62924. */
  62925. constructor(radians: number);
  62926. /**
  62927. * Get value in degrees
  62928. * @returns the Angle value in degrees (float)
  62929. */
  62930. degrees(): number;
  62931. /**
  62932. * Get value in radians
  62933. * @returns the Angle value in radians (float)
  62934. */
  62935. radians(): number;
  62936. /**
  62937. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62938. * @param a defines first vector
  62939. * @param b defines second vector
  62940. * @returns a new Angle
  62941. */
  62942. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62943. /**
  62944. * Gets a new Angle object from the given float in radians
  62945. * @param radians defines the angle value in radians
  62946. * @returns a new Angle
  62947. */
  62948. static FromRadians(radians: number): Angle;
  62949. /**
  62950. * Gets a new Angle object from the given float in degrees
  62951. * @param degrees defines the angle value in degrees
  62952. * @returns a new Angle
  62953. */
  62954. static FromDegrees(degrees: number): Angle;
  62955. }
  62956. /**
  62957. * This represents an arc in a 2d space.
  62958. */
  62959. export class Arc2 {
  62960. /** Defines the start point of the arc */
  62961. startPoint: Vector2;
  62962. /** Defines the mid point of the arc */
  62963. midPoint: Vector2;
  62964. /** Defines the end point of the arc */
  62965. endPoint: Vector2;
  62966. /**
  62967. * Defines the center point of the arc.
  62968. */
  62969. centerPoint: Vector2;
  62970. /**
  62971. * Defines the radius of the arc.
  62972. */
  62973. radius: number;
  62974. /**
  62975. * Defines the angle of the arc (from mid point to end point).
  62976. */
  62977. angle: Angle;
  62978. /**
  62979. * Defines the start angle of the arc (from start point to middle point).
  62980. */
  62981. startAngle: Angle;
  62982. /**
  62983. * Defines the orientation of the arc (clock wise/counter clock wise).
  62984. */
  62985. orientation: Orientation;
  62986. /**
  62987. * Creates an Arc object from the three given points : start, middle and end.
  62988. * @param startPoint Defines the start point of the arc
  62989. * @param midPoint Defines the midlle point of the arc
  62990. * @param endPoint Defines the end point of the arc
  62991. */
  62992. constructor(
  62993. /** Defines the start point of the arc */
  62994. startPoint: Vector2,
  62995. /** Defines the mid point of the arc */
  62996. midPoint: Vector2,
  62997. /** Defines the end point of the arc */
  62998. endPoint: Vector2);
  62999. }
  63000. /**
  63001. * Represents a 2D path made up of multiple 2D points
  63002. */
  63003. export class Path2 {
  63004. private _points;
  63005. private _length;
  63006. /**
  63007. * If the path start and end point are the same
  63008. */
  63009. closed: boolean;
  63010. /**
  63011. * Creates a Path2 object from the starting 2D coordinates x and y.
  63012. * @param x the starting points x value
  63013. * @param y the starting points y value
  63014. */
  63015. constructor(x: number, y: number);
  63016. /**
  63017. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63018. * @param x the added points x value
  63019. * @param y the added points y value
  63020. * @returns the updated Path2.
  63021. */
  63022. addLineTo(x: number, y: number): Path2;
  63023. /**
  63024. * 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.
  63025. * @param midX middle point x value
  63026. * @param midY middle point y value
  63027. * @param endX end point x value
  63028. * @param endY end point y value
  63029. * @param numberOfSegments (default: 36)
  63030. * @returns the updated Path2.
  63031. */
  63032. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63033. /**
  63034. * Closes the Path2.
  63035. * @returns the Path2.
  63036. */
  63037. close(): Path2;
  63038. /**
  63039. * Gets the sum of the distance between each sequential point in the path
  63040. * @returns the Path2 total length (float).
  63041. */
  63042. length(): number;
  63043. /**
  63044. * Gets the points which construct the path
  63045. * @returns the Path2 internal array of points.
  63046. */
  63047. getPoints(): Vector2[];
  63048. /**
  63049. * Retreives the point at the distance aways from the starting point
  63050. * @param normalizedLengthPosition the length along the path to retreive the point from
  63051. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63052. */
  63053. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63054. /**
  63055. * Creates a new path starting from an x and y position
  63056. * @param x starting x value
  63057. * @param y starting y value
  63058. * @returns a new Path2 starting at the coordinates (x, y).
  63059. */
  63060. static StartingAt(x: number, y: number): Path2;
  63061. }
  63062. /**
  63063. * Represents a 3D path made up of multiple 3D points
  63064. */
  63065. export class Path3D {
  63066. /**
  63067. * an array of Vector3, the curve axis of the Path3D
  63068. */
  63069. path: Vector3[];
  63070. private _curve;
  63071. private _distances;
  63072. private _tangents;
  63073. private _normals;
  63074. private _binormals;
  63075. private _raw;
  63076. /**
  63077. * new Path3D(path, normal, raw)
  63078. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63079. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63080. * @param path an array of Vector3, the curve axis of the Path3D
  63081. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63082. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63083. */
  63084. constructor(
  63085. /**
  63086. * an array of Vector3, the curve axis of the Path3D
  63087. */
  63088. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63089. /**
  63090. * Returns the Path3D array of successive Vector3 designing its curve.
  63091. * @returns the Path3D array of successive Vector3 designing its curve.
  63092. */
  63093. getCurve(): Vector3[];
  63094. /**
  63095. * Returns an array populated with tangent vectors on each Path3D curve point.
  63096. * @returns an array populated with tangent vectors on each Path3D curve point.
  63097. */
  63098. getTangents(): Vector3[];
  63099. /**
  63100. * Returns an array populated with normal vectors on each Path3D curve point.
  63101. * @returns an array populated with normal vectors on each Path3D curve point.
  63102. */
  63103. getNormals(): Vector3[];
  63104. /**
  63105. * Returns an array populated with binormal vectors on each Path3D curve point.
  63106. * @returns an array populated with binormal vectors on each Path3D curve point.
  63107. */
  63108. getBinormals(): Vector3[];
  63109. /**
  63110. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63111. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63112. */
  63113. getDistances(): number[];
  63114. /**
  63115. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63116. * @param path path which all values are copied into the curves points
  63117. * @param firstNormal which should be projected onto the curve
  63118. * @returns the same object updated.
  63119. */
  63120. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63121. private _compute;
  63122. private _getFirstNonNullVector;
  63123. private _getLastNonNullVector;
  63124. private _normalVector;
  63125. }
  63126. /**
  63127. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63128. * A Curve3 is designed from a series of successive Vector3.
  63129. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63130. */
  63131. export class Curve3 {
  63132. private _points;
  63133. private _length;
  63134. /**
  63135. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63136. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63137. * @param v1 (Vector3) the control point
  63138. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63139. * @param nbPoints (integer) the wanted number of points in the curve
  63140. * @returns the created Curve3
  63141. */
  63142. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63143. /**
  63144. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63145. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63146. * @param v1 (Vector3) the first control point
  63147. * @param v2 (Vector3) the second control point
  63148. * @param v3 (Vector3) the end point of the Cubic Bezier
  63149. * @param nbPoints (integer) the wanted number of points in the curve
  63150. * @returns the created Curve3
  63151. */
  63152. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63153. /**
  63154. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63155. * @param p1 (Vector3) the origin point of the Hermite Spline
  63156. * @param t1 (Vector3) the tangent vector at the origin point
  63157. * @param p2 (Vector3) the end point of the Hermite Spline
  63158. * @param t2 (Vector3) the tangent vector at the end point
  63159. * @param nbPoints (integer) the wanted number of points in the curve
  63160. * @returns the created Curve3
  63161. */
  63162. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63163. /**
  63164. * Returns a Curve3 object along a CatmullRom Spline curve :
  63165. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63166. * @param nbPoints (integer) the wanted number of points between each curve control points
  63167. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63168. * @returns the created Curve3
  63169. */
  63170. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63171. /**
  63172. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63173. * A Curve3 is designed from a series of successive Vector3.
  63174. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63175. * @param points points which make up the curve
  63176. */
  63177. constructor(points: Vector3[]);
  63178. /**
  63179. * @returns the Curve3 stored array of successive Vector3
  63180. */
  63181. getPoints(): Vector3[];
  63182. /**
  63183. * @returns the computed length (float) of the curve.
  63184. */
  63185. length(): number;
  63186. /**
  63187. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63188. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63189. * curveA and curveB keep unchanged.
  63190. * @param curve the curve to continue from this curve
  63191. * @returns the newly constructed curve
  63192. */
  63193. continue(curve: DeepImmutable<Curve3>): Curve3;
  63194. private _computeLength;
  63195. }
  63196. /**
  63197. * Contains position and normal vectors for a vertex
  63198. */
  63199. export class PositionNormalVertex {
  63200. /** the position of the vertex (defaut: 0,0,0) */
  63201. position: Vector3;
  63202. /** the normal of the vertex (defaut: 0,1,0) */
  63203. normal: Vector3;
  63204. /**
  63205. * Creates a PositionNormalVertex
  63206. * @param position the position of the vertex (defaut: 0,0,0)
  63207. * @param normal the normal of the vertex (defaut: 0,1,0)
  63208. */
  63209. constructor(
  63210. /** the position of the vertex (defaut: 0,0,0) */
  63211. position?: Vector3,
  63212. /** the normal of the vertex (defaut: 0,1,0) */
  63213. normal?: Vector3);
  63214. /**
  63215. * Clones the PositionNormalVertex
  63216. * @returns the cloned PositionNormalVertex
  63217. */
  63218. clone(): PositionNormalVertex;
  63219. }
  63220. /**
  63221. * Contains position, normal and uv vectors for a vertex
  63222. */
  63223. export class PositionNormalTextureVertex {
  63224. /** the position of the vertex (defaut: 0,0,0) */
  63225. position: Vector3;
  63226. /** the normal of the vertex (defaut: 0,1,0) */
  63227. normal: Vector3;
  63228. /** the uv of the vertex (default: 0,0) */
  63229. uv: Vector2;
  63230. /**
  63231. * Creates a PositionNormalTextureVertex
  63232. * @param position the position of the vertex (defaut: 0,0,0)
  63233. * @param normal the normal of the vertex (defaut: 0,1,0)
  63234. * @param uv the uv of the vertex (default: 0,0)
  63235. */
  63236. constructor(
  63237. /** the position of the vertex (defaut: 0,0,0) */
  63238. position?: Vector3,
  63239. /** the normal of the vertex (defaut: 0,1,0) */
  63240. normal?: Vector3,
  63241. /** the uv of the vertex (default: 0,0) */
  63242. uv?: Vector2);
  63243. /**
  63244. * Clones the PositionNormalTextureVertex
  63245. * @returns the cloned PositionNormalTextureVertex
  63246. */
  63247. clone(): PositionNormalTextureVertex;
  63248. }
  63249. /**
  63250. * @hidden
  63251. */
  63252. export class Tmp {
  63253. static Color3: Color3[];
  63254. static Color4: Color4[];
  63255. static Vector2: Vector2[];
  63256. static Vector3: Vector3[];
  63257. static Vector4: Vector4[];
  63258. static Quaternion: Quaternion[];
  63259. static Matrix: Matrix[];
  63260. }
  63261. }
  63262. declare module BABYLON {
  63263. /**
  63264. * Class used to enable access to offline support
  63265. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63266. */
  63267. export interface IOfflineProvider {
  63268. /**
  63269. * Gets a boolean indicating if scene must be saved in the database
  63270. */
  63271. enableSceneOffline: boolean;
  63272. /**
  63273. * Gets a boolean indicating if textures must be saved in the database
  63274. */
  63275. enableTexturesOffline: boolean;
  63276. /**
  63277. * Open the offline support and make it available
  63278. * @param successCallback defines the callback to call on success
  63279. * @param errorCallback defines the callback to call on error
  63280. */
  63281. open(successCallback: () => void, errorCallback: () => void): void;
  63282. /**
  63283. * Loads an image from the offline support
  63284. * @param url defines the url to load from
  63285. * @param image defines the target DOM image
  63286. */
  63287. loadImage(url: string, image: HTMLImageElement): void;
  63288. /**
  63289. * Loads a file from offline support
  63290. * @param url defines the URL to load from
  63291. * @param sceneLoaded defines a callback to call on success
  63292. * @param progressCallBack defines a callback to call when progress changed
  63293. * @param errorCallback defines a callback to call on error
  63294. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63295. */
  63296. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63297. }
  63298. }
  63299. declare module BABYLON {
  63300. /**
  63301. * A class serves as a medium between the observable and its observers
  63302. */
  63303. export class EventState {
  63304. /**
  63305. * Create a new EventState
  63306. * @param mask defines the mask associated with this state
  63307. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63308. * @param target defines the original target of the state
  63309. * @param currentTarget defines the current target of the state
  63310. */
  63311. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63312. /**
  63313. * Initialize the current event state
  63314. * @param mask defines the mask associated with this state
  63315. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63316. * @param target defines the original target of the state
  63317. * @param currentTarget defines the current target of the state
  63318. * @returns the current event state
  63319. */
  63320. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63321. /**
  63322. * An Observer can set this property to true to prevent subsequent observers of being notified
  63323. */
  63324. skipNextObservers: boolean;
  63325. /**
  63326. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63327. */
  63328. mask: number;
  63329. /**
  63330. * The object that originally notified the event
  63331. */
  63332. target?: any;
  63333. /**
  63334. * The current object in the bubbling phase
  63335. */
  63336. currentTarget?: any;
  63337. /**
  63338. * This will be populated with the return value of the last function that was executed.
  63339. * If it is the first function in the callback chain it will be the event data.
  63340. */
  63341. lastReturnValue?: any;
  63342. }
  63343. /**
  63344. * Represent an Observer registered to a given Observable object.
  63345. */
  63346. export class Observer<T> {
  63347. /**
  63348. * Defines the callback to call when the observer is notified
  63349. */
  63350. callback: (eventData: T, eventState: EventState) => void;
  63351. /**
  63352. * Defines the mask of the observer (used to filter notifications)
  63353. */
  63354. mask: number;
  63355. /**
  63356. * Defines the current scope used to restore the JS context
  63357. */
  63358. scope: any;
  63359. /** @hidden */
  63360. _willBeUnregistered: boolean;
  63361. /**
  63362. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63363. */
  63364. unregisterOnNextCall: boolean;
  63365. /**
  63366. * Creates a new observer
  63367. * @param callback defines the callback to call when the observer is notified
  63368. * @param mask defines the mask of the observer (used to filter notifications)
  63369. * @param scope defines the current scope used to restore the JS context
  63370. */
  63371. constructor(
  63372. /**
  63373. * Defines the callback to call when the observer is notified
  63374. */
  63375. callback: (eventData: T, eventState: EventState) => void,
  63376. /**
  63377. * Defines the mask of the observer (used to filter notifications)
  63378. */
  63379. mask: number,
  63380. /**
  63381. * Defines the current scope used to restore the JS context
  63382. */
  63383. scope?: any);
  63384. }
  63385. /**
  63386. * Represent a list of observers registered to multiple Observables object.
  63387. */
  63388. export class MultiObserver<T> {
  63389. private _observers;
  63390. private _observables;
  63391. /**
  63392. * Release associated resources
  63393. */
  63394. dispose(): void;
  63395. /**
  63396. * Raise a callback when one of the observable will notify
  63397. * @param observables defines a list of observables to watch
  63398. * @param callback defines the callback to call on notification
  63399. * @param mask defines the mask used to filter notifications
  63400. * @param scope defines the current scope used to restore the JS context
  63401. * @returns the new MultiObserver
  63402. */
  63403. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63404. }
  63405. /**
  63406. * The Observable class is a simple implementation of the Observable pattern.
  63407. *
  63408. * 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.
  63409. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63410. * 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).
  63411. * 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.
  63412. */
  63413. export class Observable<T> {
  63414. private _observers;
  63415. private _eventState;
  63416. private _onObserverAdded;
  63417. /**
  63418. * Creates a new observable
  63419. * @param onObserverAdded defines a callback to call when a new observer is added
  63420. */
  63421. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63422. /**
  63423. * Create a new Observer with the specified callback
  63424. * @param callback the callback that will be executed for that Observer
  63425. * @param mask the mask used to filter observers
  63426. * @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.
  63427. * @param scope optional scope for the callback to be called from
  63428. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63429. * @returns the new observer created for the callback
  63430. */
  63431. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63432. /**
  63433. * Create a new Observer with the specified callback and unregisters after the next notification
  63434. * @param callback the callback that will be executed for that Observer
  63435. * @returns the new observer created for the callback
  63436. */
  63437. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63438. /**
  63439. * Remove an Observer from the Observable object
  63440. * @param observer the instance of the Observer to remove
  63441. * @returns false if it doesn't belong to this Observable
  63442. */
  63443. remove(observer: Nullable<Observer<T>>): boolean;
  63444. /**
  63445. * Remove a callback from the Observable object
  63446. * @param callback the callback to remove
  63447. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63448. * @returns false if it doesn't belong to this Observable
  63449. */
  63450. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63451. private _deferUnregister;
  63452. private _remove;
  63453. /**
  63454. * Moves the observable to the top of the observer list making it get called first when notified
  63455. * @param observer the observer to move
  63456. */
  63457. makeObserverTopPriority(observer: Observer<T>): void;
  63458. /**
  63459. * Moves the observable to the bottom of the observer list making it get called last when notified
  63460. * @param observer the observer to move
  63461. */
  63462. makeObserverBottomPriority(observer: Observer<T>): void;
  63463. /**
  63464. * Notify all Observers by calling their respective callback with the given data
  63465. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63466. * @param eventData defines the data to send to all observers
  63467. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63468. * @param target defines the original target of the state
  63469. * @param currentTarget defines the current target of the state
  63470. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63471. */
  63472. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63473. /**
  63474. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63475. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63476. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63477. * and it is crucial that all callbacks will be executed.
  63478. * The order of the callbacks is kept, callbacks are not executed parallel.
  63479. *
  63480. * @param eventData The data to be sent to each callback
  63481. * @param mask is used to filter observers defaults to -1
  63482. * @param target defines the callback target (see EventState)
  63483. * @param currentTarget defines he current object in the bubbling phase
  63484. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63485. */
  63486. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63487. /**
  63488. * Notify a specific observer
  63489. * @param observer defines the observer to notify
  63490. * @param eventData defines the data to be sent to each callback
  63491. * @param mask is used to filter observers defaults to -1
  63492. */
  63493. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63494. /**
  63495. * Gets a boolean indicating if the observable has at least one observer
  63496. * @returns true is the Observable has at least one Observer registered
  63497. */
  63498. hasObservers(): boolean;
  63499. /**
  63500. * Clear the list of observers
  63501. */
  63502. clear(): void;
  63503. /**
  63504. * Clone the current observable
  63505. * @returns a new observable
  63506. */
  63507. clone(): Observable<T>;
  63508. /**
  63509. * Does this observable handles observer registered with a given mask
  63510. * @param mask defines the mask to be tested
  63511. * @return whether or not one observer registered with the given mask is handeled
  63512. **/
  63513. hasSpecificMask(mask?: number): boolean;
  63514. }
  63515. }
  63516. declare module BABYLON {
  63517. /**
  63518. * Class used to help managing file picking and drag'n'drop
  63519. * File Storage
  63520. */
  63521. export class FilesInputStore {
  63522. /**
  63523. * List of files ready to be loaded
  63524. */
  63525. static FilesToLoad: {
  63526. [key: string]: File;
  63527. };
  63528. }
  63529. }
  63530. declare module BABYLON {
  63531. /** Defines the cross module used constants to avoid circular dependncies */
  63532. export class Constants {
  63533. /** Defines that alpha blending is disabled */
  63534. static readonly ALPHA_DISABLE: number;
  63535. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63536. static readonly ALPHA_ADD: number;
  63537. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63538. static readonly ALPHA_COMBINE: number;
  63539. /** Defines that alpha blending to DEST - SRC * DEST */
  63540. static readonly ALPHA_SUBTRACT: number;
  63541. /** Defines that alpha blending to SRC * DEST */
  63542. static readonly ALPHA_MULTIPLY: number;
  63543. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63544. static readonly ALPHA_MAXIMIZED: number;
  63545. /** Defines that alpha blending to SRC + DEST */
  63546. static readonly ALPHA_ONEONE: number;
  63547. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63548. static readonly ALPHA_PREMULTIPLIED: number;
  63549. /**
  63550. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63551. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63552. */
  63553. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63554. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63555. static readonly ALPHA_INTERPOLATE: number;
  63556. /**
  63557. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63558. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63559. */
  63560. static readonly ALPHA_SCREENMODE: number;
  63561. /** Defines that the ressource is not delayed*/
  63562. static readonly DELAYLOADSTATE_NONE: number;
  63563. /** Defines that the ressource was successfully delay loaded */
  63564. static readonly DELAYLOADSTATE_LOADED: number;
  63565. /** Defines that the ressource is currently delay loading */
  63566. static readonly DELAYLOADSTATE_LOADING: number;
  63567. /** Defines that the ressource is delayed and has not started loading */
  63568. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63570. static readonly NEVER: number;
  63571. /** 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 */
  63572. static readonly ALWAYS: number;
  63573. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63574. static readonly LESS: number;
  63575. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63576. static readonly EQUAL: number;
  63577. /** 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 */
  63578. static readonly LEQUAL: number;
  63579. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63580. static readonly GREATER: number;
  63581. /** 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 */
  63582. static readonly GEQUAL: number;
  63583. /** 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 */
  63584. static readonly NOTEQUAL: number;
  63585. /** Passed to stencilOperation to specify that stencil value must be kept */
  63586. static readonly KEEP: number;
  63587. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63588. static readonly REPLACE: number;
  63589. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63590. static readonly INCR: number;
  63591. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63592. static readonly DECR: number;
  63593. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63594. static readonly INVERT: number;
  63595. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63596. static readonly INCR_WRAP: number;
  63597. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63598. static readonly DECR_WRAP: number;
  63599. /** Texture is not repeating outside of 0..1 UVs */
  63600. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63601. /** Texture is repeating outside of 0..1 UVs */
  63602. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63603. /** Texture is repeating and mirrored */
  63604. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63605. /** ALPHA */
  63606. static readonly TEXTUREFORMAT_ALPHA: number;
  63607. /** LUMINANCE */
  63608. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63609. /** LUMINANCE_ALPHA */
  63610. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63611. /** RGB */
  63612. static readonly TEXTUREFORMAT_RGB: number;
  63613. /** RGBA */
  63614. static readonly TEXTUREFORMAT_RGBA: number;
  63615. /** RED */
  63616. static readonly TEXTUREFORMAT_RED: number;
  63617. /** RED (2nd reference) */
  63618. static readonly TEXTUREFORMAT_R: number;
  63619. /** RG */
  63620. static readonly TEXTUREFORMAT_RG: number;
  63621. /** RED_INTEGER */
  63622. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63623. /** RED_INTEGER (2nd reference) */
  63624. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63625. /** RG_INTEGER */
  63626. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63627. /** RGB_INTEGER */
  63628. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63629. /** RGBA_INTEGER */
  63630. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63631. /** UNSIGNED_BYTE */
  63632. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63633. /** UNSIGNED_BYTE (2nd reference) */
  63634. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63635. /** FLOAT */
  63636. static readonly TEXTURETYPE_FLOAT: number;
  63637. /** HALF_FLOAT */
  63638. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63639. /** BYTE */
  63640. static readonly TEXTURETYPE_BYTE: number;
  63641. /** SHORT */
  63642. static readonly TEXTURETYPE_SHORT: number;
  63643. /** UNSIGNED_SHORT */
  63644. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63645. /** INT */
  63646. static readonly TEXTURETYPE_INT: number;
  63647. /** UNSIGNED_INT */
  63648. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63649. /** UNSIGNED_SHORT_4_4_4_4 */
  63650. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63651. /** UNSIGNED_SHORT_5_5_5_1 */
  63652. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63653. /** UNSIGNED_SHORT_5_6_5 */
  63654. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63655. /** UNSIGNED_INT_2_10_10_10_REV */
  63656. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63657. /** UNSIGNED_INT_24_8 */
  63658. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63659. /** UNSIGNED_INT_10F_11F_11F_REV */
  63660. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63661. /** UNSIGNED_INT_5_9_9_9_REV */
  63662. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63663. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63664. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63665. /** nearest is mag = nearest and min = nearest and mip = linear */
  63666. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63667. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63668. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63669. /** Trilinear is mag = linear and min = linear and mip = linear */
  63670. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63671. /** nearest is mag = nearest and min = nearest and mip = linear */
  63672. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63673. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63674. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63675. /** Trilinear is mag = linear and min = linear and mip = linear */
  63676. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63677. /** mag = nearest and min = nearest and mip = nearest */
  63678. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63679. /** mag = nearest and min = linear and mip = nearest */
  63680. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63681. /** mag = nearest and min = linear and mip = linear */
  63682. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63683. /** mag = nearest and min = linear and mip = none */
  63684. static readonly TEXTURE_NEAREST_LINEAR: number;
  63685. /** mag = nearest and min = nearest and mip = none */
  63686. static readonly TEXTURE_NEAREST_NEAREST: number;
  63687. /** mag = linear and min = nearest and mip = nearest */
  63688. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63689. /** mag = linear and min = nearest and mip = linear */
  63690. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63691. /** mag = linear and min = linear and mip = none */
  63692. static readonly TEXTURE_LINEAR_LINEAR: number;
  63693. /** mag = linear and min = nearest and mip = none */
  63694. static readonly TEXTURE_LINEAR_NEAREST: number;
  63695. /** Explicit coordinates mode */
  63696. static readonly TEXTURE_EXPLICIT_MODE: number;
  63697. /** Spherical coordinates mode */
  63698. static readonly TEXTURE_SPHERICAL_MODE: number;
  63699. /** Planar coordinates mode */
  63700. static readonly TEXTURE_PLANAR_MODE: number;
  63701. /** Cubic coordinates mode */
  63702. static readonly TEXTURE_CUBIC_MODE: number;
  63703. /** Projection coordinates mode */
  63704. static readonly TEXTURE_PROJECTION_MODE: number;
  63705. /** Skybox coordinates mode */
  63706. static readonly TEXTURE_SKYBOX_MODE: number;
  63707. /** Inverse Cubic coordinates mode */
  63708. static readonly TEXTURE_INVCUBIC_MODE: number;
  63709. /** Equirectangular coordinates mode */
  63710. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63711. /** Equirectangular Fixed coordinates mode */
  63712. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63713. /** Equirectangular Fixed Mirrored coordinates mode */
  63714. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63715. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63716. static readonly SCALEMODE_FLOOR: number;
  63717. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63718. static readonly SCALEMODE_NEAREST: number;
  63719. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63720. static readonly SCALEMODE_CEILING: number;
  63721. /**
  63722. * The dirty texture flag value
  63723. */
  63724. static readonly MATERIAL_TextureDirtyFlag: number;
  63725. /**
  63726. * The dirty light flag value
  63727. */
  63728. static readonly MATERIAL_LightDirtyFlag: number;
  63729. /**
  63730. * The dirty fresnel flag value
  63731. */
  63732. static readonly MATERIAL_FresnelDirtyFlag: number;
  63733. /**
  63734. * The dirty attribute flag value
  63735. */
  63736. static readonly MATERIAL_AttributesDirtyFlag: number;
  63737. /**
  63738. * The dirty misc flag value
  63739. */
  63740. static readonly MATERIAL_MiscDirtyFlag: number;
  63741. /**
  63742. * The all dirty flag value
  63743. */
  63744. static readonly MATERIAL_AllDirtyFlag: number;
  63745. /**
  63746. * Returns the triangle fill mode
  63747. */
  63748. static readonly MATERIAL_TriangleFillMode: number;
  63749. /**
  63750. * Returns the wireframe mode
  63751. */
  63752. static readonly MATERIAL_WireFrameFillMode: number;
  63753. /**
  63754. * Returns the point fill mode
  63755. */
  63756. static readonly MATERIAL_PointFillMode: number;
  63757. /**
  63758. * Returns the point list draw mode
  63759. */
  63760. static readonly MATERIAL_PointListDrawMode: number;
  63761. /**
  63762. * Returns the line list draw mode
  63763. */
  63764. static readonly MATERIAL_LineListDrawMode: number;
  63765. /**
  63766. * Returns the line loop draw mode
  63767. */
  63768. static readonly MATERIAL_LineLoopDrawMode: number;
  63769. /**
  63770. * Returns the line strip draw mode
  63771. */
  63772. static readonly MATERIAL_LineStripDrawMode: number;
  63773. /**
  63774. * Returns the triangle strip draw mode
  63775. */
  63776. static readonly MATERIAL_TriangleStripDrawMode: number;
  63777. /**
  63778. * Returns the triangle fan draw mode
  63779. */
  63780. static readonly MATERIAL_TriangleFanDrawMode: number;
  63781. /**
  63782. * Stores the clock-wise side orientation
  63783. */
  63784. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63785. /**
  63786. * Stores the counter clock-wise side orientation
  63787. */
  63788. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63789. /**
  63790. * Nothing
  63791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63792. */
  63793. static readonly ACTION_NothingTrigger: number;
  63794. /**
  63795. * On pick
  63796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63797. */
  63798. static readonly ACTION_OnPickTrigger: number;
  63799. /**
  63800. * On left pick
  63801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63802. */
  63803. static readonly ACTION_OnLeftPickTrigger: number;
  63804. /**
  63805. * On right pick
  63806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63807. */
  63808. static readonly ACTION_OnRightPickTrigger: number;
  63809. /**
  63810. * On center pick
  63811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63812. */
  63813. static readonly ACTION_OnCenterPickTrigger: number;
  63814. /**
  63815. * On pick down
  63816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63817. */
  63818. static readonly ACTION_OnPickDownTrigger: number;
  63819. /**
  63820. * On double pick
  63821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63822. */
  63823. static readonly ACTION_OnDoublePickTrigger: number;
  63824. /**
  63825. * On pick up
  63826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63827. */
  63828. static readonly ACTION_OnPickUpTrigger: number;
  63829. /**
  63830. * On pick out.
  63831. * This trigger will only be raised if you also declared a OnPickDown
  63832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63833. */
  63834. static readonly ACTION_OnPickOutTrigger: number;
  63835. /**
  63836. * On long press
  63837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63838. */
  63839. static readonly ACTION_OnLongPressTrigger: number;
  63840. /**
  63841. * On pointer over
  63842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63843. */
  63844. static readonly ACTION_OnPointerOverTrigger: number;
  63845. /**
  63846. * On pointer out
  63847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63848. */
  63849. static readonly ACTION_OnPointerOutTrigger: number;
  63850. /**
  63851. * On every frame
  63852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63853. */
  63854. static readonly ACTION_OnEveryFrameTrigger: number;
  63855. /**
  63856. * On intersection enter
  63857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63858. */
  63859. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63860. /**
  63861. * On intersection exit
  63862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63863. */
  63864. static readonly ACTION_OnIntersectionExitTrigger: number;
  63865. /**
  63866. * On key down
  63867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63868. */
  63869. static readonly ACTION_OnKeyDownTrigger: number;
  63870. /**
  63871. * On key up
  63872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63873. */
  63874. static readonly ACTION_OnKeyUpTrigger: number;
  63875. /**
  63876. * Billboard mode will only apply to Y axis
  63877. */
  63878. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63879. /**
  63880. * Billboard mode will apply to all axes
  63881. */
  63882. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63883. /**
  63884. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63885. */
  63886. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63887. /**
  63888. * Gets or sets base Assets URL
  63889. */
  63890. static readonly PARTICLES_BaseAssetsUrl: string;
  63891. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63892. * Test order :
  63893. * Is the bounding sphere outside the frustum ?
  63894. * If not, are the bounding box vertices outside the frustum ?
  63895. * It not, then the cullable object is in the frustum.
  63896. */
  63897. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63898. /** Culling strategy : Bounding Sphere Only.
  63899. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63900. * It's also less accurate than the standard because some not visible objects can still be selected.
  63901. * Test : is the bounding sphere outside the frustum ?
  63902. * If not, then the cullable object is in the frustum.
  63903. */
  63904. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63905. /** Culling strategy : Optimistic Inclusion.
  63906. * This in an inclusion test first, then the standard exclusion test.
  63907. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63908. * 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.
  63909. * Anyway, it's as accurate as the standard strategy.
  63910. * Test :
  63911. * Is the cullable object bounding sphere center in the frustum ?
  63912. * If not, apply the default culling strategy.
  63913. */
  63914. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63915. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63916. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63917. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63918. * 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.
  63919. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63920. * Test :
  63921. * Is the cullable object bounding sphere center in the frustum ?
  63922. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63923. */
  63924. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63925. /**
  63926. * No logging while loading
  63927. */
  63928. static readonly SCENELOADER_NO_LOGGING: number;
  63929. /**
  63930. * Minimal logging while loading
  63931. */
  63932. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63933. /**
  63934. * Summary logging while loading
  63935. */
  63936. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63937. /**
  63938. * Detailled logging while loading
  63939. */
  63940. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63941. }
  63942. }
  63943. declare module BABYLON {
  63944. /**
  63945. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63946. * Babylon.js
  63947. */
  63948. export class DomManagement {
  63949. /**
  63950. * Checks if the window object exists
  63951. * @returns true if the window object exists
  63952. */
  63953. static IsWindowObjectExist(): boolean;
  63954. /**
  63955. * Extracts text content from a DOM element hierarchy
  63956. * @param element defines the root element
  63957. * @returns a string
  63958. */
  63959. static GetDOMTextContent(element: HTMLElement): string;
  63960. }
  63961. }
  63962. declare module BABYLON {
  63963. /**
  63964. * Logger used througouht the application to allow configuration of
  63965. * the log level required for the messages.
  63966. */
  63967. export class Logger {
  63968. /**
  63969. * No log
  63970. */
  63971. static readonly NoneLogLevel: number;
  63972. /**
  63973. * Only message logs
  63974. */
  63975. static readonly MessageLogLevel: number;
  63976. /**
  63977. * Only warning logs
  63978. */
  63979. static readonly WarningLogLevel: number;
  63980. /**
  63981. * Only error logs
  63982. */
  63983. static readonly ErrorLogLevel: number;
  63984. /**
  63985. * All logs
  63986. */
  63987. static readonly AllLogLevel: number;
  63988. private static _LogCache;
  63989. /**
  63990. * Gets a value indicating the number of loading errors
  63991. * @ignorenaming
  63992. */
  63993. static errorsCount: number;
  63994. /**
  63995. * Callback called when a new log is added
  63996. */
  63997. static OnNewCacheEntry: (entry: string) => void;
  63998. private static _AddLogEntry;
  63999. private static _FormatMessage;
  64000. private static _LogDisabled;
  64001. private static _LogEnabled;
  64002. private static _WarnDisabled;
  64003. private static _WarnEnabled;
  64004. private static _ErrorDisabled;
  64005. private static _ErrorEnabled;
  64006. /**
  64007. * Log a message to the console
  64008. */
  64009. static Log: (message: string) => void;
  64010. /**
  64011. * Write a warning message to the console
  64012. */
  64013. static Warn: (message: string) => void;
  64014. /**
  64015. * Write an error message to the console
  64016. */
  64017. static Error: (message: string) => void;
  64018. /**
  64019. * Gets current log cache (list of logs)
  64020. */
  64021. static readonly LogCache: string;
  64022. /**
  64023. * Clears the log cache
  64024. */
  64025. static ClearLogCache(): void;
  64026. /**
  64027. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64028. */
  64029. static LogLevels: number;
  64030. }
  64031. }
  64032. declare module BABYLON {
  64033. /** @hidden */
  64034. export class _TypeStore {
  64035. /** @hidden */
  64036. static RegisteredTypes: {
  64037. [key: string]: Object;
  64038. };
  64039. /** @hidden */
  64040. static GetClass(fqdn: string): any;
  64041. }
  64042. }
  64043. declare module BABYLON {
  64044. /**
  64045. * Class containing a set of static utilities functions for deep copy.
  64046. */
  64047. export class DeepCopier {
  64048. /**
  64049. * Tries to copy an object by duplicating every property
  64050. * @param source defines the source object
  64051. * @param destination defines the target object
  64052. * @param doNotCopyList defines a list of properties to avoid
  64053. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64054. */
  64055. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64056. }
  64057. }
  64058. declare module BABYLON {
  64059. /**
  64060. * Class containing a set of static utilities functions for precision date
  64061. */
  64062. export class PrecisionDate {
  64063. /**
  64064. * Gets either window.performance.now() if supported or Date.now() else
  64065. */
  64066. static readonly Now: number;
  64067. }
  64068. }
  64069. declare module BABYLON {
  64070. /** @hidden */
  64071. export class _DevTools {
  64072. static WarnImport(name: string): string;
  64073. }
  64074. }
  64075. declare module BABYLON {
  64076. /**
  64077. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64078. */
  64079. export class WebRequest {
  64080. private _xhr;
  64081. /**
  64082. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64083. * i.e. when loading files, where the server/service expects an Authorization header
  64084. */
  64085. static CustomRequestHeaders: {
  64086. [key: string]: string;
  64087. };
  64088. /**
  64089. * Add callback functions in this array to update all the requests before they get sent to the network
  64090. */
  64091. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64092. private _injectCustomRequestHeaders;
  64093. /**
  64094. * Gets or sets a function to be called when loading progress changes
  64095. */
  64096. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64097. /**
  64098. * Returns client's state
  64099. */
  64100. readonly readyState: number;
  64101. /**
  64102. * Returns client's status
  64103. */
  64104. readonly status: number;
  64105. /**
  64106. * Returns client's status as a text
  64107. */
  64108. readonly statusText: string;
  64109. /**
  64110. * Returns client's response
  64111. */
  64112. readonly response: any;
  64113. /**
  64114. * Returns client's response url
  64115. */
  64116. readonly responseURL: string;
  64117. /**
  64118. * Returns client's response as text
  64119. */
  64120. readonly responseText: string;
  64121. /**
  64122. * Gets or sets the expected response type
  64123. */
  64124. responseType: XMLHttpRequestResponseType;
  64125. /** @hidden */
  64126. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64127. /** @hidden */
  64128. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64129. /**
  64130. * Cancels any network activity
  64131. */
  64132. abort(): void;
  64133. /**
  64134. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64135. * @param body defines an optional request body
  64136. */
  64137. send(body?: Document | BodyInit | null): void;
  64138. /**
  64139. * Sets the request method, request URL
  64140. * @param method defines the method to use (GET, POST, etc..)
  64141. * @param url defines the url to connect with
  64142. */
  64143. open(method: string, url: string): void;
  64144. }
  64145. }
  64146. declare module BABYLON {
  64147. /**
  64148. * Class used to evalaute queries containing `and` and `or` operators
  64149. */
  64150. export class AndOrNotEvaluator {
  64151. /**
  64152. * Evaluate a query
  64153. * @param query defines the query to evaluate
  64154. * @param evaluateCallback defines the callback used to filter result
  64155. * @returns true if the query matches
  64156. */
  64157. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64158. private static _HandleParenthesisContent;
  64159. private static _SimplifyNegation;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * Class used to store custom tags
  64165. */
  64166. export class Tags {
  64167. /**
  64168. * Adds support for tags on the given object
  64169. * @param obj defines the object to use
  64170. */
  64171. static EnableFor(obj: any): void;
  64172. /**
  64173. * Removes tags support
  64174. * @param obj defines the object to use
  64175. */
  64176. static DisableFor(obj: any): void;
  64177. /**
  64178. * Gets a boolean indicating if the given object has tags
  64179. * @param obj defines the object to use
  64180. * @returns a boolean
  64181. */
  64182. static HasTags(obj: any): boolean;
  64183. /**
  64184. * Gets the tags available on a given object
  64185. * @param obj defines the object to use
  64186. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64187. * @returns the tags
  64188. */
  64189. static GetTags(obj: any, asString?: boolean): any;
  64190. /**
  64191. * Adds tags to an object
  64192. * @param obj defines the object to use
  64193. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64194. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64195. */
  64196. static AddTagsTo(obj: any, tagsString: string): void;
  64197. /**
  64198. * @hidden
  64199. */
  64200. static _AddTagTo(obj: any, tag: string): void;
  64201. /**
  64202. * Removes specific tags from a specific object
  64203. * @param obj defines the object to use
  64204. * @param tagsString defines the tags to remove
  64205. */
  64206. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64207. /**
  64208. * @hidden
  64209. */
  64210. static _RemoveTagFrom(obj: any, tag: string): void;
  64211. /**
  64212. * Defines if tags hosted on an object match a given query
  64213. * @param obj defines the object to use
  64214. * @param tagsQuery defines the tag query
  64215. * @returns a boolean
  64216. */
  64217. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64218. }
  64219. }
  64220. declare module BABYLON {
  64221. /**
  64222. * Manages the defines for the Material
  64223. */
  64224. export class MaterialDefines {
  64225. private _keys;
  64226. private _isDirty;
  64227. /** @hidden */
  64228. _renderId: number;
  64229. /** @hidden */
  64230. _areLightsDirty: boolean;
  64231. /** @hidden */
  64232. _areAttributesDirty: boolean;
  64233. /** @hidden */
  64234. _areTexturesDirty: boolean;
  64235. /** @hidden */
  64236. _areFresnelDirty: boolean;
  64237. /** @hidden */
  64238. _areMiscDirty: boolean;
  64239. /** @hidden */
  64240. _areImageProcessingDirty: boolean;
  64241. /** @hidden */
  64242. _normals: boolean;
  64243. /** @hidden */
  64244. _uvs: boolean;
  64245. /** @hidden */
  64246. _needNormals: boolean;
  64247. /** @hidden */
  64248. _needUVs: boolean;
  64249. /**
  64250. * Specifies if the material needs to be re-calculated
  64251. */
  64252. readonly isDirty: boolean;
  64253. /**
  64254. * Marks the material to indicate that it has been re-calculated
  64255. */
  64256. markAsProcessed(): void;
  64257. /**
  64258. * Marks the material to indicate that it needs to be re-calculated
  64259. */
  64260. markAsUnprocessed(): void;
  64261. /**
  64262. * Marks the material to indicate all of its defines need to be re-calculated
  64263. */
  64264. markAllAsDirty(): void;
  64265. /**
  64266. * Marks the material to indicate that image processing needs to be re-calculated
  64267. */
  64268. markAsImageProcessingDirty(): void;
  64269. /**
  64270. * Marks the material to indicate the lights need to be re-calculated
  64271. */
  64272. markAsLightDirty(): void;
  64273. /**
  64274. * Marks the attribute state as changed
  64275. */
  64276. markAsAttributesDirty(): void;
  64277. /**
  64278. * Marks the texture state as changed
  64279. */
  64280. markAsTexturesDirty(): void;
  64281. /**
  64282. * Marks the fresnel state as changed
  64283. */
  64284. markAsFresnelDirty(): void;
  64285. /**
  64286. * Marks the misc state as changed
  64287. */
  64288. markAsMiscDirty(): void;
  64289. /**
  64290. * Rebuilds the material defines
  64291. */
  64292. rebuild(): void;
  64293. /**
  64294. * Specifies if two material defines are equal
  64295. * @param other - A material define instance to compare to
  64296. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64297. */
  64298. isEqual(other: MaterialDefines): boolean;
  64299. /**
  64300. * Clones this instance's defines to another instance
  64301. * @param other - material defines to clone values to
  64302. */
  64303. cloneTo(other: MaterialDefines): void;
  64304. /**
  64305. * Resets the material define values
  64306. */
  64307. reset(): void;
  64308. /**
  64309. * Converts the material define values to a string
  64310. * @returns - String of material define information
  64311. */
  64312. toString(): string;
  64313. }
  64314. }
  64315. declare module BABYLON {
  64316. /**
  64317. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64318. */
  64319. export class PerformanceMonitor {
  64320. private _enabled;
  64321. private _rollingFrameTime;
  64322. private _lastFrameTimeMs;
  64323. /**
  64324. * constructor
  64325. * @param frameSampleSize The number of samples required to saturate the sliding window
  64326. */
  64327. constructor(frameSampleSize?: number);
  64328. /**
  64329. * Samples current frame
  64330. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64331. */
  64332. sampleFrame(timeMs?: number): void;
  64333. /**
  64334. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64335. */
  64336. readonly averageFrameTime: number;
  64337. /**
  64338. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64339. */
  64340. readonly averageFrameTimeVariance: number;
  64341. /**
  64342. * Returns the frame time of the most recent frame
  64343. */
  64344. readonly instantaneousFrameTime: number;
  64345. /**
  64346. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64347. */
  64348. readonly averageFPS: number;
  64349. /**
  64350. * Returns the average framerate in frames per second using the most recent frame time
  64351. */
  64352. readonly instantaneousFPS: number;
  64353. /**
  64354. * Returns true if enough samples have been taken to completely fill the sliding window
  64355. */
  64356. readonly isSaturated: boolean;
  64357. /**
  64358. * Enables contributions to the sliding window sample set
  64359. */
  64360. enable(): void;
  64361. /**
  64362. * Disables contributions to the sliding window sample set
  64363. * Samples will not be interpolated over the disabled period
  64364. */
  64365. disable(): void;
  64366. /**
  64367. * Returns true if sampling is enabled
  64368. */
  64369. readonly isEnabled: boolean;
  64370. /**
  64371. * Resets performance monitor
  64372. */
  64373. reset(): void;
  64374. }
  64375. /**
  64376. * RollingAverage
  64377. *
  64378. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64379. */
  64380. export class RollingAverage {
  64381. /**
  64382. * Current average
  64383. */
  64384. average: number;
  64385. /**
  64386. * Current variance
  64387. */
  64388. variance: number;
  64389. protected _samples: Array<number>;
  64390. protected _sampleCount: number;
  64391. protected _pos: number;
  64392. protected _m2: number;
  64393. /**
  64394. * constructor
  64395. * @param length The number of samples required to saturate the sliding window
  64396. */
  64397. constructor(length: number);
  64398. /**
  64399. * Adds a sample to the sample set
  64400. * @param v The sample value
  64401. */
  64402. add(v: number): void;
  64403. /**
  64404. * Returns previously added values or null if outside of history or outside the sliding window domain
  64405. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64406. * @return Value previously recorded with add() or null if outside of range
  64407. */
  64408. history(i: number): number;
  64409. /**
  64410. * Returns true if enough samples have been taken to completely fill the sliding window
  64411. * @return true if sample-set saturated
  64412. */
  64413. isSaturated(): boolean;
  64414. /**
  64415. * Resets the rolling average (equivalent to 0 samples taken so far)
  64416. */
  64417. reset(): void;
  64418. /**
  64419. * Wraps a value around the sample range boundaries
  64420. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64421. * @return Wrapped position in sample range
  64422. */
  64423. protected _wrapPosition(i: number): number;
  64424. }
  64425. }
  64426. declare module BABYLON {
  64427. /**
  64428. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64429. * The underlying implementation relies on an associative array to ensure the best performances.
  64430. * The value can be anything including 'null' but except 'undefined'
  64431. */
  64432. export class StringDictionary<T> {
  64433. /**
  64434. * This will clear this dictionary and copy the content from the 'source' one.
  64435. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64436. * @param source the dictionary to take the content from and copy to this dictionary
  64437. */
  64438. copyFrom(source: StringDictionary<T>): void;
  64439. /**
  64440. * Get a value based from its key
  64441. * @param key the given key to get the matching value from
  64442. * @return the value if found, otherwise undefined is returned
  64443. */
  64444. get(key: string): T | undefined;
  64445. /**
  64446. * Get a value from its key or add it if it doesn't exist.
  64447. * This method will ensure you that a given key/data will be present in the dictionary.
  64448. * @param key the given key to get the matching value from
  64449. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64450. * The factory will only be invoked if there's no data for the given key.
  64451. * @return the value corresponding to the key.
  64452. */
  64453. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64454. /**
  64455. * Get a value from its key if present in the dictionary otherwise add it
  64456. * @param key the key to get the value from
  64457. * @param val if there's no such key/value pair in the dictionary add it with this value
  64458. * @return the value corresponding to the key
  64459. */
  64460. getOrAdd(key: string, val: T): T;
  64461. /**
  64462. * Check if there's a given key in the dictionary
  64463. * @param key the key to check for
  64464. * @return true if the key is present, false otherwise
  64465. */
  64466. contains(key: string): boolean;
  64467. /**
  64468. * Add a new key and its corresponding value
  64469. * @param key the key to add
  64470. * @param value the value corresponding to the key
  64471. * @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
  64472. */
  64473. add(key: string, value: T): boolean;
  64474. /**
  64475. * Update a specific value associated to a key
  64476. * @param key defines the key to use
  64477. * @param value defines the value to store
  64478. * @returns true if the value was updated (or false if the key was not found)
  64479. */
  64480. set(key: string, value: T): boolean;
  64481. /**
  64482. * Get the element of the given key and remove it from the dictionary
  64483. * @param key defines the key to search
  64484. * @returns the value associated with the key or null if not found
  64485. */
  64486. getAndRemove(key: string): Nullable<T>;
  64487. /**
  64488. * Remove a key/value from the dictionary.
  64489. * @param key the key to remove
  64490. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64491. */
  64492. remove(key: string): boolean;
  64493. /**
  64494. * Clear the whole content of the dictionary
  64495. */
  64496. clear(): void;
  64497. /**
  64498. * Gets the current count
  64499. */
  64500. readonly count: number;
  64501. /**
  64502. * Execute a callback on each key/val of the dictionary.
  64503. * Note that you can remove any element in this dictionary in the callback implementation
  64504. * @param callback the callback to execute on a given key/value pair
  64505. */
  64506. forEach(callback: (key: string, val: T) => void): void;
  64507. /**
  64508. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64509. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64510. * Note that you can remove any element in this dictionary in the callback implementation
  64511. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64512. * @returns the first item
  64513. */
  64514. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64515. private _count;
  64516. private _data;
  64517. }
  64518. }
  64519. declare module BABYLON {
  64520. /**
  64521. * Helper class that provides a small promise polyfill
  64522. */
  64523. export class PromisePolyfill {
  64524. /**
  64525. * Static function used to check if the polyfill is required
  64526. * If this is the case then the function will inject the polyfill to window.Promise
  64527. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64528. */
  64529. static Apply(force?: boolean): void;
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /**
  64534. * Class used to store data that will be store in GPU memory
  64535. */
  64536. export class Buffer {
  64537. private _engine;
  64538. private _buffer;
  64539. /** @hidden */
  64540. _data: Nullable<DataArray>;
  64541. private _updatable;
  64542. private _instanced;
  64543. /**
  64544. * Gets the byte stride.
  64545. */
  64546. readonly byteStride: number;
  64547. /**
  64548. * Constructor
  64549. * @param engine the engine
  64550. * @param data the data to use for this buffer
  64551. * @param updatable whether the data is updatable
  64552. * @param stride the stride (optional)
  64553. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64554. * @param instanced whether the buffer is instanced (optional)
  64555. * @param useBytes set to true if the stride in in bytes (optional)
  64556. */
  64557. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64558. /**
  64559. * Create a new VertexBuffer based on the current buffer
  64560. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64561. * @param offset defines offset in the buffer (0 by default)
  64562. * @param size defines the size in floats of attributes (position is 3 for instance)
  64563. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64564. * @param instanced defines if the vertex buffer contains indexed data
  64565. * @param useBytes defines if the offset and stride are in bytes
  64566. * @returns the new vertex buffer
  64567. */
  64568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64569. /**
  64570. * Gets a boolean indicating if the Buffer is updatable?
  64571. * @returns true if the buffer is updatable
  64572. */
  64573. isUpdatable(): boolean;
  64574. /**
  64575. * Gets current buffer's data
  64576. * @returns a DataArray or null
  64577. */
  64578. getData(): Nullable<DataArray>;
  64579. /**
  64580. * Gets underlying native buffer
  64581. * @returns underlying native buffer
  64582. */
  64583. getBuffer(): Nullable<WebGLBuffer>;
  64584. /**
  64585. * Gets the stride in float32 units (i.e. byte stride / 4).
  64586. * May not be an integer if the byte stride is not divisible by 4.
  64587. * DEPRECATED. Use byteStride instead.
  64588. * @returns the stride in float32 units
  64589. */
  64590. getStrideSize(): number;
  64591. /**
  64592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64593. * @param data defines the data to store
  64594. */
  64595. create(data?: Nullable<DataArray>): void;
  64596. /** @hidden */
  64597. _rebuild(): void;
  64598. /**
  64599. * Update current buffer data
  64600. * @param data defines the data to store
  64601. */
  64602. update(data: DataArray): void;
  64603. /**
  64604. * Updates the data directly.
  64605. * @param data the new data
  64606. * @param offset the new offset
  64607. * @param vertexCount the vertex count (optional)
  64608. * @param useBytes set to true if the offset is in bytes
  64609. */
  64610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64611. /**
  64612. * Release all resources
  64613. */
  64614. dispose(): void;
  64615. }
  64616. /**
  64617. * Specialized buffer used to store vertex data
  64618. */
  64619. export class VertexBuffer {
  64620. /** @hidden */
  64621. _buffer: Buffer;
  64622. private _kind;
  64623. private _size;
  64624. private _ownsBuffer;
  64625. private _instanced;
  64626. private _instanceDivisor;
  64627. /**
  64628. * The byte type.
  64629. */
  64630. static readonly BYTE: number;
  64631. /**
  64632. * The unsigned byte type.
  64633. */
  64634. static readonly UNSIGNED_BYTE: number;
  64635. /**
  64636. * The short type.
  64637. */
  64638. static readonly SHORT: number;
  64639. /**
  64640. * The unsigned short type.
  64641. */
  64642. static readonly UNSIGNED_SHORT: number;
  64643. /**
  64644. * The integer type.
  64645. */
  64646. static readonly INT: number;
  64647. /**
  64648. * The unsigned integer type.
  64649. */
  64650. static readonly UNSIGNED_INT: number;
  64651. /**
  64652. * The float type.
  64653. */
  64654. static readonly FLOAT: number;
  64655. /**
  64656. * Gets or sets the instance divisor when in instanced mode
  64657. */
  64658. instanceDivisor: number;
  64659. /**
  64660. * Gets the byte stride.
  64661. */
  64662. readonly byteStride: number;
  64663. /**
  64664. * Gets the byte offset.
  64665. */
  64666. readonly byteOffset: number;
  64667. /**
  64668. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64669. */
  64670. readonly normalized: boolean;
  64671. /**
  64672. * Gets the data type of each component in the array.
  64673. */
  64674. readonly type: number;
  64675. /**
  64676. * Constructor
  64677. * @param engine the engine
  64678. * @param data the data to use for this vertex buffer
  64679. * @param kind the vertex buffer kind
  64680. * @param updatable whether the data is updatable
  64681. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64682. * @param stride the stride (optional)
  64683. * @param instanced whether the buffer is instanced (optional)
  64684. * @param offset the offset of the data (optional)
  64685. * @param size the number of components (optional)
  64686. * @param type the type of the component (optional)
  64687. * @param normalized whether the data contains normalized data (optional)
  64688. * @param useBytes set to true if stride and offset are in bytes (optional)
  64689. */
  64690. 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);
  64691. /** @hidden */
  64692. _rebuild(): void;
  64693. /**
  64694. * Returns the kind of the VertexBuffer (string)
  64695. * @returns a string
  64696. */
  64697. getKind(): string;
  64698. /**
  64699. * Gets a boolean indicating if the VertexBuffer is updatable?
  64700. * @returns true if the buffer is updatable
  64701. */
  64702. isUpdatable(): boolean;
  64703. /**
  64704. * Gets current buffer's data
  64705. * @returns a DataArray or null
  64706. */
  64707. getData(): Nullable<DataArray>;
  64708. /**
  64709. * Gets underlying native buffer
  64710. * @returns underlying native buffer
  64711. */
  64712. getBuffer(): Nullable<WebGLBuffer>;
  64713. /**
  64714. * Gets the stride in float32 units (i.e. byte stride / 4).
  64715. * May not be an integer if the byte stride is not divisible by 4.
  64716. * DEPRECATED. Use byteStride instead.
  64717. * @returns the stride in float32 units
  64718. */
  64719. getStrideSize(): number;
  64720. /**
  64721. * Returns the offset as a multiple of the type byte length.
  64722. * DEPRECATED. Use byteOffset instead.
  64723. * @returns the offset in bytes
  64724. */
  64725. getOffset(): number;
  64726. /**
  64727. * Returns the number of components per vertex attribute (integer)
  64728. * @returns the size in float
  64729. */
  64730. getSize(): number;
  64731. /**
  64732. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64733. * @returns true if this buffer is instanced
  64734. */
  64735. getIsInstanced(): boolean;
  64736. /**
  64737. * Returns the instancing divisor, zero for non-instanced (integer).
  64738. * @returns a number
  64739. */
  64740. getInstanceDivisor(): number;
  64741. /**
  64742. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64743. * @param data defines the data to store
  64744. */
  64745. create(data?: DataArray): void;
  64746. /**
  64747. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64748. * This function will create a new buffer if the current one is not updatable
  64749. * @param data defines the data to store
  64750. */
  64751. update(data: DataArray): void;
  64752. /**
  64753. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64754. * Returns the directly updated WebGLBuffer.
  64755. * @param data the new data
  64756. * @param offset the new offset
  64757. * @param useBytes set to true if the offset is in bytes
  64758. */
  64759. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64760. /**
  64761. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64762. */
  64763. dispose(): void;
  64764. /**
  64765. * Enumerates each value of this vertex buffer as numbers.
  64766. * @param count the number of values to enumerate
  64767. * @param callback the callback function called for each value
  64768. */
  64769. forEach(count: number, callback: (value: number, index: number) => void): void;
  64770. /**
  64771. * Positions
  64772. */
  64773. static readonly PositionKind: string;
  64774. /**
  64775. * Normals
  64776. */
  64777. static readonly NormalKind: string;
  64778. /**
  64779. * Tangents
  64780. */
  64781. static readonly TangentKind: string;
  64782. /**
  64783. * Texture coordinates
  64784. */
  64785. static readonly UVKind: string;
  64786. /**
  64787. * Texture coordinates 2
  64788. */
  64789. static readonly UV2Kind: string;
  64790. /**
  64791. * Texture coordinates 3
  64792. */
  64793. static readonly UV3Kind: string;
  64794. /**
  64795. * Texture coordinates 4
  64796. */
  64797. static readonly UV4Kind: string;
  64798. /**
  64799. * Texture coordinates 5
  64800. */
  64801. static readonly UV5Kind: string;
  64802. /**
  64803. * Texture coordinates 6
  64804. */
  64805. static readonly UV6Kind: string;
  64806. /**
  64807. * Colors
  64808. */
  64809. static readonly ColorKind: string;
  64810. /**
  64811. * Matrix indices (for bones)
  64812. */
  64813. static readonly MatricesIndicesKind: string;
  64814. /**
  64815. * Matrix weights (for bones)
  64816. */
  64817. static readonly MatricesWeightsKind: string;
  64818. /**
  64819. * Additional matrix indices (for bones)
  64820. */
  64821. static readonly MatricesIndicesExtraKind: string;
  64822. /**
  64823. * Additional matrix weights (for bones)
  64824. */
  64825. static readonly MatricesWeightsExtraKind: string;
  64826. /**
  64827. * Deduces the stride given a kind.
  64828. * @param kind The kind string to deduce
  64829. * @returns The deduced stride
  64830. */
  64831. static DeduceStride(kind: string): number;
  64832. /**
  64833. * Gets the byte length of the given type.
  64834. * @param type the type
  64835. * @returns the number of bytes
  64836. */
  64837. static GetTypeByteLength(type: number): number;
  64838. /**
  64839. * Enumerates each value of the given parameters as numbers.
  64840. * @param data the data to enumerate
  64841. * @param byteOffset the byte offset of the data
  64842. * @param byteStride the byte stride of the data
  64843. * @param componentCount the number of components per element
  64844. * @param componentType the type of the component
  64845. * @param count the total number of components
  64846. * @param normalized whether the data is normalized
  64847. * @param callback the callback function called for each value
  64848. */
  64849. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64850. private static _GetFloatValue;
  64851. }
  64852. }
  64853. declare module BABYLON {
  64854. /**
  64855. * Class representing spherical polynomial coefficients to the 3rd degree
  64856. */
  64857. export class SphericalPolynomial {
  64858. /**
  64859. * The x coefficients of the spherical polynomial
  64860. */
  64861. x: Vector3;
  64862. /**
  64863. * The y coefficients of the spherical polynomial
  64864. */
  64865. y: Vector3;
  64866. /**
  64867. * The z coefficients of the spherical polynomial
  64868. */
  64869. z: Vector3;
  64870. /**
  64871. * The xx coefficients of the spherical polynomial
  64872. */
  64873. xx: Vector3;
  64874. /**
  64875. * The yy coefficients of the spherical polynomial
  64876. */
  64877. yy: Vector3;
  64878. /**
  64879. * The zz coefficients of the spherical polynomial
  64880. */
  64881. zz: Vector3;
  64882. /**
  64883. * The xy coefficients of the spherical polynomial
  64884. */
  64885. xy: Vector3;
  64886. /**
  64887. * The yz coefficients of the spherical polynomial
  64888. */
  64889. yz: Vector3;
  64890. /**
  64891. * The zx coefficients of the spherical polynomial
  64892. */
  64893. zx: Vector3;
  64894. /**
  64895. * Adds an ambient color to the spherical polynomial
  64896. * @param color the color to add
  64897. */
  64898. addAmbient(color: Color3): void;
  64899. /**
  64900. * Scales the spherical polynomial by the given amount
  64901. * @param scale the amount to scale
  64902. */
  64903. scale(scale: number): void;
  64904. /**
  64905. * Gets the spherical polynomial from harmonics
  64906. * @param harmonics the spherical harmonics
  64907. * @returns the spherical polynomial
  64908. */
  64909. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64910. /**
  64911. * Constructs a spherical polynomial from an array.
  64912. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64913. * @returns the spherical polynomial
  64914. */
  64915. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64916. }
  64917. /**
  64918. * Class representing spherical harmonics coefficients to the 3rd degree
  64919. */
  64920. export class SphericalHarmonics {
  64921. /**
  64922. * The l0,0 coefficients of the spherical harmonics
  64923. */
  64924. l00: Vector3;
  64925. /**
  64926. * The l1,-1 coefficients of the spherical harmonics
  64927. */
  64928. l1_1: Vector3;
  64929. /**
  64930. * The l1,0 coefficients of the spherical harmonics
  64931. */
  64932. l10: Vector3;
  64933. /**
  64934. * The l1,1 coefficients of the spherical harmonics
  64935. */
  64936. l11: Vector3;
  64937. /**
  64938. * The l2,-2 coefficients of the spherical harmonics
  64939. */
  64940. l2_2: Vector3;
  64941. /**
  64942. * The l2,-1 coefficients of the spherical harmonics
  64943. */
  64944. l2_1: Vector3;
  64945. /**
  64946. * The l2,0 coefficients of the spherical harmonics
  64947. */
  64948. l20: Vector3;
  64949. /**
  64950. * The l2,1 coefficients of the spherical harmonics
  64951. */
  64952. l21: Vector3;
  64953. /**
  64954. * The l2,2 coefficients of the spherical harmonics
  64955. */
  64956. lL22: Vector3;
  64957. /**
  64958. * Adds a light to the spherical harmonics
  64959. * @param direction the direction of the light
  64960. * @param color the color of the light
  64961. * @param deltaSolidAngle the delta solid angle of the light
  64962. */
  64963. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64964. /**
  64965. * Scales the spherical harmonics by the given amount
  64966. * @param scale the amount to scale
  64967. */
  64968. scale(scale: number): void;
  64969. /**
  64970. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64971. *
  64972. * ```
  64973. * E_lm = A_l * L_lm
  64974. * ```
  64975. *
  64976. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64977. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64978. * the scaling factors are given in equation 9.
  64979. */
  64980. convertIncidentRadianceToIrradiance(): void;
  64981. /**
  64982. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64983. *
  64984. * ```
  64985. * L = (1/pi) * E * rho
  64986. * ```
  64987. *
  64988. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64989. */
  64990. convertIrradianceToLambertianRadiance(): void;
  64991. /**
  64992. * Gets the spherical harmonics from polynomial
  64993. * @param polynomial the spherical polynomial
  64994. * @returns the spherical harmonics
  64995. */
  64996. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64997. /**
  64998. * Constructs a spherical harmonics from an array.
  64999. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65000. * @returns the spherical harmonics
  65001. */
  65002. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65003. }
  65004. }
  65005. declare module BABYLON {
  65006. /**
  65007. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65008. */
  65009. export interface CubeMapInfo {
  65010. /**
  65011. * The pixel array for the front face.
  65012. * This is stored in format, left to right, up to down format.
  65013. */
  65014. front: Nullable<ArrayBufferView>;
  65015. /**
  65016. * The pixel array for the back face.
  65017. * This is stored in format, left to right, up to down format.
  65018. */
  65019. back: Nullable<ArrayBufferView>;
  65020. /**
  65021. * The pixel array for the left face.
  65022. * This is stored in format, left to right, up to down format.
  65023. */
  65024. left: Nullable<ArrayBufferView>;
  65025. /**
  65026. * The pixel array for the right face.
  65027. * This is stored in format, left to right, up to down format.
  65028. */
  65029. right: Nullable<ArrayBufferView>;
  65030. /**
  65031. * The pixel array for the up face.
  65032. * This is stored in format, left to right, up to down format.
  65033. */
  65034. up: Nullable<ArrayBufferView>;
  65035. /**
  65036. * The pixel array for the down face.
  65037. * This is stored in format, left to right, up to down format.
  65038. */
  65039. down: Nullable<ArrayBufferView>;
  65040. /**
  65041. * The size of the cubemap stored.
  65042. *
  65043. * Each faces will be size * size pixels.
  65044. */
  65045. size: number;
  65046. /**
  65047. * The format of the texture.
  65048. *
  65049. * RGBA, RGB.
  65050. */
  65051. format: number;
  65052. /**
  65053. * The type of the texture data.
  65054. *
  65055. * UNSIGNED_INT, FLOAT.
  65056. */
  65057. type: number;
  65058. /**
  65059. * Specifies whether the texture is in gamma space.
  65060. */
  65061. gammaSpace: boolean;
  65062. }
  65063. /**
  65064. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65065. */
  65066. export class PanoramaToCubeMapTools {
  65067. private static FACE_FRONT;
  65068. private static FACE_BACK;
  65069. private static FACE_RIGHT;
  65070. private static FACE_LEFT;
  65071. private static FACE_DOWN;
  65072. private static FACE_UP;
  65073. /**
  65074. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65075. *
  65076. * @param float32Array The source data.
  65077. * @param inputWidth The width of the input panorama.
  65078. * @param inputHeight The height of the input panorama.
  65079. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65080. * @return The cubemap data
  65081. */
  65082. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65083. private static CreateCubemapTexture;
  65084. private static CalcProjectionSpherical;
  65085. }
  65086. }
  65087. declare module BABYLON {
  65088. /**
  65089. * Helper class dealing with the extraction of spherical polynomial dataArray
  65090. * from a cube map.
  65091. */
  65092. export class CubeMapToSphericalPolynomialTools {
  65093. private static FileFaces;
  65094. /**
  65095. * Converts a texture to the according Spherical Polynomial data.
  65096. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65097. *
  65098. * @param texture The texture to extract the information from.
  65099. * @return The Spherical Polynomial data.
  65100. */
  65101. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65102. /**
  65103. * Converts a cubemap to the according Spherical Polynomial data.
  65104. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65105. *
  65106. * @param cubeInfo The Cube map to extract the information from.
  65107. * @return The Spherical Polynomial data.
  65108. */
  65109. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65110. }
  65111. }
  65112. declare module BABYLON {
  65113. /**
  65114. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65115. * during the life time of the application.
  65116. */
  65117. export class EngineStore {
  65118. /** Gets the list of created engines */
  65119. static Instances: Engine[];
  65120. /**
  65121. * Gets the latest created engine
  65122. */
  65123. static readonly LastCreatedEngine: Nullable<Engine>;
  65124. /**
  65125. * Gets the latest created scene
  65126. */
  65127. static readonly LastCreatedScene: Nullable<Scene>;
  65128. }
  65129. }
  65130. declare module BABYLON {
  65131. /**
  65132. * Define options used to create a render target texture
  65133. */
  65134. export class RenderTargetCreationOptions {
  65135. /**
  65136. * Specifies is mipmaps must be generated
  65137. */
  65138. generateMipMaps?: boolean;
  65139. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65140. generateDepthBuffer?: boolean;
  65141. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65142. generateStencilBuffer?: boolean;
  65143. /** Defines texture type (int by default) */
  65144. type?: number;
  65145. /** Defines sampling mode (trilinear by default) */
  65146. samplingMode?: number;
  65147. /** Defines format (RGBA by default) */
  65148. format?: number;
  65149. }
  65150. }
  65151. declare module BABYLON {
  65152. /**
  65153. * @hidden
  65154. **/
  65155. export class _AlphaState {
  65156. private _isAlphaBlendDirty;
  65157. private _isBlendFunctionParametersDirty;
  65158. private _isBlendEquationParametersDirty;
  65159. private _isBlendConstantsDirty;
  65160. private _alphaBlend;
  65161. private _blendFunctionParameters;
  65162. private _blendEquationParameters;
  65163. private _blendConstants;
  65164. /**
  65165. * Initializes the state.
  65166. */
  65167. constructor();
  65168. readonly isDirty: boolean;
  65169. alphaBlend: boolean;
  65170. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65171. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65172. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65173. reset(): void;
  65174. apply(gl: WebGLRenderingContext): void;
  65175. }
  65176. }
  65177. declare module BABYLON {
  65178. /**
  65179. * @hidden
  65180. **/
  65181. export class _DepthCullingState {
  65182. private _isDepthTestDirty;
  65183. private _isDepthMaskDirty;
  65184. private _isDepthFuncDirty;
  65185. private _isCullFaceDirty;
  65186. private _isCullDirty;
  65187. private _isZOffsetDirty;
  65188. private _isFrontFaceDirty;
  65189. private _depthTest;
  65190. private _depthMask;
  65191. private _depthFunc;
  65192. private _cull;
  65193. private _cullFace;
  65194. private _zOffset;
  65195. private _frontFace;
  65196. /**
  65197. * Initializes the state.
  65198. */
  65199. constructor();
  65200. readonly isDirty: boolean;
  65201. zOffset: number;
  65202. cullFace: Nullable<number>;
  65203. cull: Nullable<boolean>;
  65204. depthFunc: Nullable<number>;
  65205. depthMask: boolean;
  65206. depthTest: boolean;
  65207. frontFace: Nullable<number>;
  65208. reset(): void;
  65209. apply(gl: WebGLRenderingContext): void;
  65210. }
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * @hidden
  65215. **/
  65216. export class _StencilState {
  65217. /** 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 */
  65218. static readonly ALWAYS: number;
  65219. /** Passed to stencilOperation to specify that stencil value must be kept */
  65220. static readonly KEEP: number;
  65221. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65222. static readonly REPLACE: number;
  65223. private _isStencilTestDirty;
  65224. private _isStencilMaskDirty;
  65225. private _isStencilFuncDirty;
  65226. private _isStencilOpDirty;
  65227. private _stencilTest;
  65228. private _stencilMask;
  65229. private _stencilFunc;
  65230. private _stencilFuncRef;
  65231. private _stencilFuncMask;
  65232. private _stencilOpStencilFail;
  65233. private _stencilOpDepthFail;
  65234. private _stencilOpStencilDepthPass;
  65235. readonly isDirty: boolean;
  65236. stencilFunc: number;
  65237. stencilFuncRef: number;
  65238. stencilFuncMask: number;
  65239. stencilOpStencilFail: number;
  65240. stencilOpDepthFail: number;
  65241. stencilOpStencilDepthPass: number;
  65242. stencilMask: number;
  65243. stencilTest: boolean;
  65244. constructor();
  65245. reset(): void;
  65246. apply(gl: WebGLRenderingContext): void;
  65247. }
  65248. }
  65249. declare module BABYLON {
  65250. /**
  65251. * @hidden
  65252. **/
  65253. export class _TimeToken {
  65254. _startTimeQuery: Nullable<WebGLQuery>;
  65255. _endTimeQuery: Nullable<WebGLQuery>;
  65256. _timeElapsedQuery: Nullable<WebGLQuery>;
  65257. _timeElapsedQueryEnded: boolean;
  65258. }
  65259. }
  65260. declare module BABYLON {
  65261. /**
  65262. * Internal interface used to track InternalTexture already bound to the GL context
  65263. */
  65264. export interface IInternalTextureTracker {
  65265. /**
  65266. * Gets or set the previous tracker in the list
  65267. */
  65268. previous: Nullable<IInternalTextureTracker>;
  65269. /**
  65270. * Gets or set the next tracker in the list
  65271. */
  65272. next: Nullable<IInternalTextureTracker>;
  65273. }
  65274. /**
  65275. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  65276. */
  65277. export class DummyInternalTextureTracker {
  65278. /**
  65279. * Gets or set the previous tracker in the list
  65280. */
  65281. previous: Nullable<IInternalTextureTracker>;
  65282. /**
  65283. * Gets or set the next tracker in the list
  65284. */
  65285. next: Nullable<IInternalTextureTracker>;
  65286. }
  65287. }
  65288. declare module BABYLON {
  65289. /**
  65290. * Class used to store data associated with WebGL texture data for the engine
  65291. * This class should not be used directly
  65292. */
  65293. export class InternalTexture implements IInternalTextureTracker {
  65294. /** hidden */
  65295. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65296. /**
  65297. * The source of the texture data is unknown
  65298. */
  65299. static DATASOURCE_UNKNOWN: number;
  65300. /**
  65301. * Texture data comes from an URL
  65302. */
  65303. static DATASOURCE_URL: number;
  65304. /**
  65305. * Texture data is only used for temporary storage
  65306. */
  65307. static DATASOURCE_TEMP: number;
  65308. /**
  65309. * Texture data comes from raw data (ArrayBuffer)
  65310. */
  65311. static DATASOURCE_RAW: number;
  65312. /**
  65313. * Texture content is dynamic (video or dynamic texture)
  65314. */
  65315. static DATASOURCE_DYNAMIC: number;
  65316. /**
  65317. * Texture content is generated by rendering to it
  65318. */
  65319. static DATASOURCE_RENDERTARGET: number;
  65320. /**
  65321. * Texture content is part of a multi render target process
  65322. */
  65323. static DATASOURCE_MULTIRENDERTARGET: number;
  65324. /**
  65325. * Texture data comes from a cube data file
  65326. */
  65327. static DATASOURCE_CUBE: number;
  65328. /**
  65329. * Texture data comes from a raw cube data
  65330. */
  65331. static DATASOURCE_CUBERAW: number;
  65332. /**
  65333. * Texture data come from a prefiltered cube data file
  65334. */
  65335. static DATASOURCE_CUBEPREFILTERED: number;
  65336. /**
  65337. * Texture content is raw 3D data
  65338. */
  65339. static DATASOURCE_RAW3D: number;
  65340. /**
  65341. * Texture content is a depth texture
  65342. */
  65343. static DATASOURCE_DEPTHTEXTURE: number;
  65344. /**
  65345. * Texture data comes from a raw cube data encoded with RGBD
  65346. */
  65347. static DATASOURCE_CUBERAW_RGBD: number;
  65348. /**
  65349. * Defines if the texture is ready
  65350. */
  65351. isReady: boolean;
  65352. /**
  65353. * Defines if the texture is a cube texture
  65354. */
  65355. isCube: boolean;
  65356. /**
  65357. * Defines if the texture contains 3D data
  65358. */
  65359. is3D: boolean;
  65360. /**
  65361. * Defines if the texture contains multiview data
  65362. */
  65363. isMultiview: boolean;
  65364. /**
  65365. * Gets the URL used to load this texture
  65366. */
  65367. url: string;
  65368. /**
  65369. * Gets the sampling mode of the texture
  65370. */
  65371. samplingMode: number;
  65372. /**
  65373. * Gets a boolean indicating if the texture needs mipmaps generation
  65374. */
  65375. generateMipMaps: boolean;
  65376. /**
  65377. * Gets the number of samples used by the texture (WebGL2+ only)
  65378. */
  65379. samples: number;
  65380. /**
  65381. * Gets the type of the texture (int, float...)
  65382. */
  65383. type: number;
  65384. /**
  65385. * Gets the format of the texture (RGB, RGBA...)
  65386. */
  65387. format: number;
  65388. /**
  65389. * Observable called when the texture is loaded
  65390. */
  65391. onLoadedObservable: Observable<InternalTexture>;
  65392. /**
  65393. * Gets the width of the texture
  65394. */
  65395. width: number;
  65396. /**
  65397. * Gets the height of the texture
  65398. */
  65399. height: number;
  65400. /**
  65401. * Gets the depth of the texture
  65402. */
  65403. depth: number;
  65404. /**
  65405. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65406. */
  65407. baseWidth: number;
  65408. /**
  65409. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65410. */
  65411. baseHeight: number;
  65412. /**
  65413. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65414. */
  65415. baseDepth: number;
  65416. /**
  65417. * Gets a boolean indicating if the texture is inverted on Y axis
  65418. */
  65419. invertY: boolean;
  65420. /**
  65421. * Gets or set the previous tracker in the list
  65422. */
  65423. previous: Nullable<IInternalTextureTracker>;
  65424. /**
  65425. * Gets or set the next tracker in the list
  65426. */
  65427. next: Nullable<IInternalTextureTracker>;
  65428. /** @hidden */
  65429. _invertVScale: boolean;
  65430. /** @hidden */
  65431. _initialSlot: number;
  65432. /** @hidden */
  65433. _designatedSlot: number;
  65434. /** @hidden */
  65435. _dataSource: number;
  65436. /** @hidden */
  65437. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65438. /** @hidden */
  65439. _bufferView: Nullable<ArrayBufferView>;
  65440. /** @hidden */
  65441. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65442. /** @hidden */
  65443. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65444. /** @hidden */
  65445. _size: number;
  65446. /** @hidden */
  65447. _extension: string;
  65448. /** @hidden */
  65449. _files: Nullable<string[]>;
  65450. /** @hidden */
  65451. _workingCanvas: HTMLCanvasElement;
  65452. /** @hidden */
  65453. _workingContext: CanvasRenderingContext2D;
  65454. /** @hidden */
  65455. _framebuffer: Nullable<WebGLFramebuffer>;
  65456. /** @hidden */
  65457. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65458. /** @hidden */
  65459. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65460. /** @hidden */
  65461. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65462. /** @hidden */
  65463. _attachments: Nullable<number[]>;
  65464. /** @hidden */
  65465. _cachedCoordinatesMode: Nullable<number>;
  65466. /** @hidden */
  65467. _cachedWrapU: Nullable<number>;
  65468. /** @hidden */
  65469. _cachedWrapV: Nullable<number>;
  65470. /** @hidden */
  65471. _cachedWrapR: Nullable<number>;
  65472. /** @hidden */
  65473. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65474. /** @hidden */
  65475. _isDisabled: boolean;
  65476. /** @hidden */
  65477. _compression: Nullable<string>;
  65478. /** @hidden */
  65479. _generateStencilBuffer: boolean;
  65480. /** @hidden */
  65481. _generateDepthBuffer: boolean;
  65482. /** @hidden */
  65483. _comparisonFunction: number;
  65484. /** @hidden */
  65485. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65486. /** @hidden */
  65487. _lodGenerationScale: number;
  65488. /** @hidden */
  65489. _lodGenerationOffset: number;
  65490. /** @hidden */
  65491. _colorTextureArray: Nullable<WebGLTexture>;
  65492. /** @hidden */
  65493. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65494. /** @hidden */
  65495. _lodTextureHigh: BaseTexture;
  65496. /** @hidden */
  65497. _lodTextureMid: BaseTexture;
  65498. /** @hidden */
  65499. _lodTextureLow: BaseTexture;
  65500. /** @hidden */
  65501. _isRGBD: boolean;
  65502. /** @hidden */
  65503. _webGLTexture: Nullable<WebGLTexture>;
  65504. /** @hidden */
  65505. _references: number;
  65506. private _engine;
  65507. /**
  65508. * Gets the Engine the texture belongs to.
  65509. * @returns The babylon engine
  65510. */
  65511. getEngine(): Engine;
  65512. /**
  65513. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65514. */
  65515. readonly dataSource: number;
  65516. /**
  65517. * Creates a new InternalTexture
  65518. * @param engine defines the engine to use
  65519. * @param dataSource defines the type of data that will be used
  65520. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65521. */
  65522. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65523. /**
  65524. * Increments the number of references (ie. the number of Texture that point to it)
  65525. */
  65526. incrementReferences(): void;
  65527. /**
  65528. * Change the size of the texture (not the size of the content)
  65529. * @param width defines the new width
  65530. * @param height defines the new height
  65531. * @param depth defines the new depth (1 by default)
  65532. */
  65533. updateSize(width: int, height: int, depth?: int): void;
  65534. /** @hidden */
  65535. _rebuild(): void;
  65536. /** @hidden */
  65537. _swapAndDie(target: InternalTexture): void;
  65538. /**
  65539. * Dispose the current allocated resources
  65540. */
  65541. dispose(): void;
  65542. }
  65543. }
  65544. declare module BABYLON {
  65545. /**
  65546. * This represents the main contract an easing function should follow.
  65547. * Easing functions are used throughout the animation system.
  65548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65549. */
  65550. export interface IEasingFunction {
  65551. /**
  65552. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65553. * of the easing function.
  65554. * The link below provides some of the most common examples of easing functions.
  65555. * @see https://easings.net/
  65556. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65557. * @returns the corresponding value on the curve defined by the easing function
  65558. */
  65559. ease(gradient: number): number;
  65560. }
  65561. /**
  65562. * Base class used for every default easing function.
  65563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65564. */
  65565. export class EasingFunction implements IEasingFunction {
  65566. /**
  65567. * Interpolation follows the mathematical formula associated with the easing function.
  65568. */
  65569. static readonly EASINGMODE_EASEIN: number;
  65570. /**
  65571. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65572. */
  65573. static readonly EASINGMODE_EASEOUT: number;
  65574. /**
  65575. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65576. */
  65577. static readonly EASINGMODE_EASEINOUT: number;
  65578. private _easingMode;
  65579. /**
  65580. * Sets the easing mode of the current function.
  65581. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65582. */
  65583. setEasingMode(easingMode: number): void;
  65584. /**
  65585. * Gets the current easing mode.
  65586. * @returns the easing mode
  65587. */
  65588. getEasingMode(): number;
  65589. /**
  65590. * @hidden
  65591. */
  65592. easeInCore(gradient: number): number;
  65593. /**
  65594. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65595. * of the easing function.
  65596. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65597. * @returns the corresponding value on the curve defined by the easing function
  65598. */
  65599. ease(gradient: number): number;
  65600. }
  65601. /**
  65602. * Easing function with a circle shape (see link below).
  65603. * @see https://easings.net/#easeInCirc
  65604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65605. */
  65606. export class CircleEase extends EasingFunction implements IEasingFunction {
  65607. /** @hidden */
  65608. easeInCore(gradient: number): number;
  65609. }
  65610. /**
  65611. * Easing function with a ease back shape (see link below).
  65612. * @see https://easings.net/#easeInBack
  65613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65614. */
  65615. export class BackEase extends EasingFunction implements IEasingFunction {
  65616. /** Defines the amplitude of the function */
  65617. amplitude: number;
  65618. /**
  65619. * Instantiates a back ease easing
  65620. * @see https://easings.net/#easeInBack
  65621. * @param amplitude Defines the amplitude of the function
  65622. */
  65623. constructor(
  65624. /** Defines the amplitude of the function */
  65625. amplitude?: number);
  65626. /** @hidden */
  65627. easeInCore(gradient: number): number;
  65628. }
  65629. /**
  65630. * Easing function with a bouncing shape (see link below).
  65631. * @see https://easings.net/#easeInBounce
  65632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65633. */
  65634. export class BounceEase extends EasingFunction implements IEasingFunction {
  65635. /** Defines the number of bounces */
  65636. bounces: number;
  65637. /** Defines the amplitude of the bounce */
  65638. bounciness: number;
  65639. /**
  65640. * Instantiates a bounce easing
  65641. * @see https://easings.net/#easeInBounce
  65642. * @param bounces Defines the number of bounces
  65643. * @param bounciness Defines the amplitude of the bounce
  65644. */
  65645. constructor(
  65646. /** Defines the number of bounces */
  65647. bounces?: number,
  65648. /** Defines the amplitude of the bounce */
  65649. bounciness?: number);
  65650. /** @hidden */
  65651. easeInCore(gradient: number): number;
  65652. }
  65653. /**
  65654. * Easing function with a power of 3 shape (see link below).
  65655. * @see https://easings.net/#easeInCubic
  65656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65657. */
  65658. export class CubicEase extends EasingFunction implements IEasingFunction {
  65659. /** @hidden */
  65660. easeInCore(gradient: number): number;
  65661. }
  65662. /**
  65663. * Easing function with an elastic shape (see link below).
  65664. * @see https://easings.net/#easeInElastic
  65665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65666. */
  65667. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65668. /** Defines the number of oscillations*/
  65669. oscillations: number;
  65670. /** Defines the amplitude of the oscillations*/
  65671. springiness: number;
  65672. /**
  65673. * Instantiates an elastic easing function
  65674. * @see https://easings.net/#easeInElastic
  65675. * @param oscillations Defines the number of oscillations
  65676. * @param springiness Defines the amplitude of the oscillations
  65677. */
  65678. constructor(
  65679. /** Defines the number of oscillations*/
  65680. oscillations?: number,
  65681. /** Defines the amplitude of the oscillations*/
  65682. springiness?: number);
  65683. /** @hidden */
  65684. easeInCore(gradient: number): number;
  65685. }
  65686. /**
  65687. * Easing function with an exponential shape (see link below).
  65688. * @see https://easings.net/#easeInExpo
  65689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65690. */
  65691. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65692. /** Defines the exponent of the function */
  65693. exponent: number;
  65694. /**
  65695. * Instantiates an exponential easing function
  65696. * @see https://easings.net/#easeInExpo
  65697. * @param exponent Defines the exponent of the function
  65698. */
  65699. constructor(
  65700. /** Defines the exponent of the function */
  65701. exponent?: number);
  65702. /** @hidden */
  65703. easeInCore(gradient: number): number;
  65704. }
  65705. /**
  65706. * Easing function with a power shape (see link below).
  65707. * @see https://easings.net/#easeInQuad
  65708. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65709. */
  65710. export class PowerEase extends EasingFunction implements IEasingFunction {
  65711. /** Defines the power of the function */
  65712. power: number;
  65713. /**
  65714. * Instantiates an power base easing function
  65715. * @see https://easings.net/#easeInQuad
  65716. * @param power Defines the power of the function
  65717. */
  65718. constructor(
  65719. /** Defines the power of the function */
  65720. power?: number);
  65721. /** @hidden */
  65722. easeInCore(gradient: number): number;
  65723. }
  65724. /**
  65725. * Easing function with a power of 2 shape (see link below).
  65726. * @see https://easings.net/#easeInQuad
  65727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65728. */
  65729. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65730. /** @hidden */
  65731. easeInCore(gradient: number): number;
  65732. }
  65733. /**
  65734. * Easing function with a power of 4 shape (see link below).
  65735. * @see https://easings.net/#easeInQuart
  65736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65737. */
  65738. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65739. /** @hidden */
  65740. easeInCore(gradient: number): number;
  65741. }
  65742. /**
  65743. * Easing function with a power of 5 shape (see link below).
  65744. * @see https://easings.net/#easeInQuint
  65745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65746. */
  65747. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65748. /** @hidden */
  65749. easeInCore(gradient: number): number;
  65750. }
  65751. /**
  65752. * Easing function with a sin shape (see link below).
  65753. * @see https://easings.net/#easeInSine
  65754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65755. */
  65756. export class SineEase extends EasingFunction implements IEasingFunction {
  65757. /** @hidden */
  65758. easeInCore(gradient: number): number;
  65759. }
  65760. /**
  65761. * Easing function with a bezier shape (see link below).
  65762. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65764. */
  65765. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65766. /** Defines the x component of the start tangent in the bezier curve */
  65767. x1: number;
  65768. /** Defines the y component of the start tangent in the bezier curve */
  65769. y1: number;
  65770. /** Defines the x component of the end tangent in the bezier curve */
  65771. x2: number;
  65772. /** Defines the y component of the end tangent in the bezier curve */
  65773. y2: number;
  65774. /**
  65775. * Instantiates a bezier function
  65776. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65777. * @param x1 Defines the x component of the start tangent in the bezier curve
  65778. * @param y1 Defines the y component of the start tangent in the bezier curve
  65779. * @param x2 Defines the x component of the end tangent in the bezier curve
  65780. * @param y2 Defines the y component of the end tangent in the bezier curve
  65781. */
  65782. constructor(
  65783. /** Defines the x component of the start tangent in the bezier curve */
  65784. x1?: number,
  65785. /** Defines the y component of the start tangent in the bezier curve */
  65786. y1?: number,
  65787. /** Defines the x component of the end tangent in the bezier curve */
  65788. x2?: number,
  65789. /** Defines the y component of the end tangent in the bezier curve */
  65790. y2?: number);
  65791. /** @hidden */
  65792. easeInCore(gradient: number): number;
  65793. }
  65794. }
  65795. declare module BABYLON {
  65796. /**
  65797. * Defines an interface which represents an animation key frame
  65798. */
  65799. export interface IAnimationKey {
  65800. /**
  65801. * Frame of the key frame
  65802. */
  65803. frame: number;
  65804. /**
  65805. * Value at the specifies key frame
  65806. */
  65807. value: any;
  65808. /**
  65809. * The input tangent for the cubic hermite spline
  65810. */
  65811. inTangent?: any;
  65812. /**
  65813. * The output tangent for the cubic hermite spline
  65814. */
  65815. outTangent?: any;
  65816. /**
  65817. * The animation interpolation type
  65818. */
  65819. interpolation?: AnimationKeyInterpolation;
  65820. }
  65821. /**
  65822. * Enum for the animation key frame interpolation type
  65823. */
  65824. export enum AnimationKeyInterpolation {
  65825. /**
  65826. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65827. */
  65828. STEP = 1
  65829. }
  65830. }
  65831. declare module BABYLON {
  65832. /**
  65833. * Represents the range of an animation
  65834. */
  65835. export class AnimationRange {
  65836. /**The name of the animation range**/
  65837. name: string;
  65838. /**The starting frame of the animation */
  65839. from: number;
  65840. /**The ending frame of the animation*/
  65841. to: number;
  65842. /**
  65843. * Initializes the range of an animation
  65844. * @param name The name of the animation range
  65845. * @param from The starting frame of the animation
  65846. * @param to The ending frame of the animation
  65847. */
  65848. constructor(
  65849. /**The name of the animation range**/
  65850. name: string,
  65851. /**The starting frame of the animation */
  65852. from: number,
  65853. /**The ending frame of the animation*/
  65854. to: number);
  65855. /**
  65856. * Makes a copy of the animation range
  65857. * @returns A copy of the animation range
  65858. */
  65859. clone(): AnimationRange;
  65860. }
  65861. }
  65862. declare module BABYLON {
  65863. /**
  65864. * Composed of a frame, and an action function
  65865. */
  65866. export class AnimationEvent {
  65867. /** The frame for which the event is triggered **/
  65868. frame: number;
  65869. /** The event to perform when triggered **/
  65870. action: (currentFrame: number) => void;
  65871. /** Specifies if the event should be triggered only once**/
  65872. onlyOnce?: boolean | undefined;
  65873. /**
  65874. * Specifies if the animation event is done
  65875. */
  65876. isDone: boolean;
  65877. /**
  65878. * Initializes the animation event
  65879. * @param frame The frame for which the event is triggered
  65880. * @param action The event to perform when triggered
  65881. * @param onlyOnce Specifies if the event should be triggered only once
  65882. */
  65883. constructor(
  65884. /** The frame for which the event is triggered **/
  65885. frame: number,
  65886. /** The event to perform when triggered **/
  65887. action: (currentFrame: number) => void,
  65888. /** Specifies if the event should be triggered only once**/
  65889. onlyOnce?: boolean | undefined);
  65890. /** @hidden */
  65891. _clone(): AnimationEvent;
  65892. }
  65893. }
  65894. declare module BABYLON {
  65895. /**
  65896. * Interface used to define a behavior
  65897. */
  65898. export interface Behavior<T> {
  65899. /** gets or sets behavior's name */
  65900. name: string;
  65901. /**
  65902. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65903. */
  65904. init(): void;
  65905. /**
  65906. * Called when the behavior is attached to a target
  65907. * @param target defines the target where the behavior is attached to
  65908. */
  65909. attach(target: T): void;
  65910. /**
  65911. * Called when the behavior is detached from its target
  65912. */
  65913. detach(): void;
  65914. }
  65915. /**
  65916. * Interface implemented by classes supporting behaviors
  65917. */
  65918. export interface IBehaviorAware<T> {
  65919. /**
  65920. * Attach a behavior
  65921. * @param behavior defines the behavior to attach
  65922. * @returns the current host
  65923. */
  65924. addBehavior(behavior: Behavior<T>): T;
  65925. /**
  65926. * Remove a behavior from the current object
  65927. * @param behavior defines the behavior to detach
  65928. * @returns the current host
  65929. */
  65930. removeBehavior(behavior: Behavior<T>): T;
  65931. /**
  65932. * Gets a behavior using its name to search
  65933. * @param name defines the name to search
  65934. * @returns the behavior or null if not found
  65935. */
  65936. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65937. }
  65938. }
  65939. declare module BABYLON {
  65940. /**
  65941. * @hidden
  65942. */
  65943. export class IntersectionInfo {
  65944. bu: Nullable<number>;
  65945. bv: Nullable<number>;
  65946. distance: number;
  65947. faceId: number;
  65948. subMeshId: number;
  65949. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65950. }
  65951. }
  65952. declare module BABYLON {
  65953. /**
  65954. * Class used to store bounding sphere information
  65955. */
  65956. export class BoundingSphere {
  65957. /**
  65958. * Gets the center of the bounding sphere in local space
  65959. */
  65960. readonly center: Vector3;
  65961. /**
  65962. * Radius of the bounding sphere in local space
  65963. */
  65964. radius: number;
  65965. /**
  65966. * Gets the center of the bounding sphere in world space
  65967. */
  65968. readonly centerWorld: Vector3;
  65969. /**
  65970. * Radius of the bounding sphere in world space
  65971. */
  65972. radiusWorld: number;
  65973. /**
  65974. * Gets the minimum vector in local space
  65975. */
  65976. readonly minimum: Vector3;
  65977. /**
  65978. * Gets the maximum vector in local space
  65979. */
  65980. readonly maximum: Vector3;
  65981. private _worldMatrix;
  65982. private static readonly TmpVector3;
  65983. /**
  65984. * Creates a new bounding sphere
  65985. * @param min defines the minimum vector (in local space)
  65986. * @param max defines the maximum vector (in local space)
  65987. * @param worldMatrix defines the new world matrix
  65988. */
  65989. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65990. /**
  65991. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65992. * @param min defines the new minimum vector (in local space)
  65993. * @param max defines the new maximum vector (in local space)
  65994. * @param worldMatrix defines the new world matrix
  65995. */
  65996. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65997. /**
  65998. * Scale the current bounding sphere by applying a scale factor
  65999. * @param factor defines the scale factor to apply
  66000. * @returns the current bounding box
  66001. */
  66002. scale(factor: number): BoundingSphere;
  66003. /**
  66004. * Gets the world matrix of the bounding box
  66005. * @returns a matrix
  66006. */
  66007. getWorldMatrix(): DeepImmutable<Matrix>;
  66008. /** @hidden */
  66009. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66010. /**
  66011. * Tests if the bounding sphere is intersecting the frustum planes
  66012. * @param frustumPlanes defines the frustum planes to test
  66013. * @returns true if there is an intersection
  66014. */
  66015. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66016. /**
  66017. * Tests if the bounding sphere center is in between the frustum planes.
  66018. * Used for optimistic fast inclusion.
  66019. * @param frustumPlanes defines the frustum planes to test
  66020. * @returns true if the sphere center is in between the frustum planes
  66021. */
  66022. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66023. /**
  66024. * Tests if a point is inside the bounding sphere
  66025. * @param point defines the point to test
  66026. * @returns true if the point is inside the bounding sphere
  66027. */
  66028. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66029. /**
  66030. * Checks if two sphere intersct
  66031. * @param sphere0 sphere 0
  66032. * @param sphere1 sphere 1
  66033. * @returns true if the speres intersect
  66034. */
  66035. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66036. }
  66037. }
  66038. declare module BABYLON {
  66039. /**
  66040. * Class used to store bounding box information
  66041. */
  66042. export class BoundingBox implements ICullable {
  66043. /**
  66044. * Gets the 8 vectors representing the bounding box in local space
  66045. */
  66046. readonly vectors: Vector3[];
  66047. /**
  66048. * Gets the center of the bounding box in local space
  66049. */
  66050. readonly center: Vector3;
  66051. /**
  66052. * Gets the center of the bounding box in world space
  66053. */
  66054. readonly centerWorld: Vector3;
  66055. /**
  66056. * Gets the extend size in local space
  66057. */
  66058. readonly extendSize: Vector3;
  66059. /**
  66060. * Gets the extend size in world space
  66061. */
  66062. readonly extendSizeWorld: Vector3;
  66063. /**
  66064. * Gets the OBB (object bounding box) directions
  66065. */
  66066. readonly directions: Vector3[];
  66067. /**
  66068. * Gets the 8 vectors representing the bounding box in world space
  66069. */
  66070. readonly vectorsWorld: Vector3[];
  66071. /**
  66072. * Gets the minimum vector in world space
  66073. */
  66074. readonly minimumWorld: Vector3;
  66075. /**
  66076. * Gets the maximum vector in world space
  66077. */
  66078. readonly maximumWorld: Vector3;
  66079. /**
  66080. * Gets the minimum vector in local space
  66081. */
  66082. readonly minimum: Vector3;
  66083. /**
  66084. * Gets the maximum vector in local space
  66085. */
  66086. readonly maximum: Vector3;
  66087. private _worldMatrix;
  66088. private static readonly TmpVector3;
  66089. /**
  66090. * @hidden
  66091. */
  66092. _tag: number;
  66093. /**
  66094. * Creates a new bounding box
  66095. * @param min defines the minimum vector (in local space)
  66096. * @param max defines the maximum vector (in local space)
  66097. * @param worldMatrix defines the new world matrix
  66098. */
  66099. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66100. /**
  66101. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66102. * @param min defines the new minimum vector (in local space)
  66103. * @param max defines the new maximum vector (in local space)
  66104. * @param worldMatrix defines the new world matrix
  66105. */
  66106. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66107. /**
  66108. * Scale the current bounding box by applying a scale factor
  66109. * @param factor defines the scale factor to apply
  66110. * @returns the current bounding box
  66111. */
  66112. scale(factor: number): BoundingBox;
  66113. /**
  66114. * Gets the world matrix of the bounding box
  66115. * @returns a matrix
  66116. */
  66117. getWorldMatrix(): DeepImmutable<Matrix>;
  66118. /** @hidden */
  66119. _update(world: DeepImmutable<Matrix>): void;
  66120. /**
  66121. * Tests if the bounding box is intersecting the frustum planes
  66122. * @param frustumPlanes defines the frustum planes to test
  66123. * @returns true if there is an intersection
  66124. */
  66125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66126. /**
  66127. * Tests if the bounding box is entirely inside the frustum planes
  66128. * @param frustumPlanes defines the frustum planes to test
  66129. * @returns true if there is an inclusion
  66130. */
  66131. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66132. /**
  66133. * Tests if a point is inside the bounding box
  66134. * @param point defines the point to test
  66135. * @returns true if the point is inside the bounding box
  66136. */
  66137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66138. /**
  66139. * Tests if the bounding box intersects with a bounding sphere
  66140. * @param sphere defines the sphere to test
  66141. * @returns true if there is an intersection
  66142. */
  66143. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66144. /**
  66145. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66146. * @param min defines the min vector to use
  66147. * @param max defines the max vector to use
  66148. * @returns true if there is an intersection
  66149. */
  66150. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66151. /**
  66152. * Tests if two bounding boxes are intersections
  66153. * @param box0 defines the first box to test
  66154. * @param box1 defines the second box to test
  66155. * @returns true if there is an intersection
  66156. */
  66157. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66158. /**
  66159. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66160. * @param minPoint defines the minimum vector of the bounding box
  66161. * @param maxPoint defines the maximum vector of the bounding box
  66162. * @param sphereCenter defines the sphere center
  66163. * @param sphereRadius defines the sphere radius
  66164. * @returns true if there is an intersection
  66165. */
  66166. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66167. /**
  66168. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66169. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66170. * @param frustumPlanes defines the frustum planes to test
  66171. * @return true if there is an inclusion
  66172. */
  66173. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66174. /**
  66175. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66176. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66177. * @param frustumPlanes defines the frustum planes to test
  66178. * @return true if there is an intersection
  66179. */
  66180. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66181. }
  66182. }
  66183. declare module BABYLON {
  66184. /** @hidden */
  66185. export class Collider {
  66186. /** Define if a collision was found */
  66187. collisionFound: boolean;
  66188. /**
  66189. * Define last intersection point in local space
  66190. */
  66191. intersectionPoint: Vector3;
  66192. /**
  66193. * Define last collided mesh
  66194. */
  66195. collidedMesh: Nullable<AbstractMesh>;
  66196. private _collisionPoint;
  66197. private _planeIntersectionPoint;
  66198. private _tempVector;
  66199. private _tempVector2;
  66200. private _tempVector3;
  66201. private _tempVector4;
  66202. private _edge;
  66203. private _baseToVertex;
  66204. private _destinationPoint;
  66205. private _slidePlaneNormal;
  66206. private _displacementVector;
  66207. /** @hidden */
  66208. _radius: Vector3;
  66209. /** @hidden */
  66210. _retry: number;
  66211. private _velocity;
  66212. private _basePoint;
  66213. private _epsilon;
  66214. /** @hidden */
  66215. _velocityWorldLength: number;
  66216. /** @hidden */
  66217. _basePointWorld: Vector3;
  66218. private _velocityWorld;
  66219. private _normalizedVelocity;
  66220. /** @hidden */
  66221. _initialVelocity: Vector3;
  66222. /** @hidden */
  66223. _initialPosition: Vector3;
  66224. private _nearestDistance;
  66225. private _collisionMask;
  66226. collisionMask: number;
  66227. /**
  66228. * Gets the plane normal used to compute the sliding response (in local space)
  66229. */
  66230. readonly slidePlaneNormal: Vector3;
  66231. /** @hidden */
  66232. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66233. /** @hidden */
  66234. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66235. /** @hidden */
  66236. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66237. /** @hidden */
  66238. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66239. /** @hidden */
  66240. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66241. /** @hidden */
  66242. _getResponse(pos: Vector3, vel: Vector3): void;
  66243. }
  66244. }
  66245. declare module BABYLON {
  66246. /**
  66247. * Interface for cullable objects
  66248. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66249. */
  66250. export interface ICullable {
  66251. /**
  66252. * Checks if the object or part of the object is in the frustum
  66253. * @param frustumPlanes Camera near/planes
  66254. * @returns true if the object is in frustum otherwise false
  66255. */
  66256. isInFrustum(frustumPlanes: Plane[]): boolean;
  66257. /**
  66258. * Checks if a cullable object (mesh...) is in the camera frustum
  66259. * Unlike isInFrustum this cheks the full bounding box
  66260. * @param frustumPlanes Camera near/planes
  66261. * @returns true if the object is in frustum otherwise false
  66262. */
  66263. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66264. }
  66265. /**
  66266. * Info for a bounding data of a mesh
  66267. */
  66268. export class BoundingInfo implements ICullable {
  66269. /**
  66270. * Bounding box for the mesh
  66271. */
  66272. readonly boundingBox: BoundingBox;
  66273. /**
  66274. * Bounding sphere for the mesh
  66275. */
  66276. readonly boundingSphere: BoundingSphere;
  66277. private _isLocked;
  66278. private static readonly TmpVector3;
  66279. /**
  66280. * Constructs bounding info
  66281. * @param minimum min vector of the bounding box/sphere
  66282. * @param maximum max vector of the bounding box/sphere
  66283. * @param worldMatrix defines the new world matrix
  66284. */
  66285. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66286. /**
  66287. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66288. * @param min defines the new minimum vector (in local space)
  66289. * @param max defines the new maximum vector (in local space)
  66290. * @param worldMatrix defines the new world matrix
  66291. */
  66292. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66293. /**
  66294. * min vector of the bounding box/sphere
  66295. */
  66296. readonly minimum: Vector3;
  66297. /**
  66298. * max vector of the bounding box/sphere
  66299. */
  66300. readonly maximum: Vector3;
  66301. /**
  66302. * If the info is locked and won't be updated to avoid perf overhead
  66303. */
  66304. isLocked: boolean;
  66305. /**
  66306. * Updates the bounding sphere and box
  66307. * @param world world matrix to be used to update
  66308. */
  66309. update(world: DeepImmutable<Matrix>): void;
  66310. /**
  66311. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66312. * @param center New center of the bounding info
  66313. * @param extend New extend of the bounding info
  66314. * @returns the current bounding info
  66315. */
  66316. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66317. /**
  66318. * Scale the current bounding info by applying a scale factor
  66319. * @param factor defines the scale factor to apply
  66320. * @returns the current bounding info
  66321. */
  66322. scale(factor: number): BoundingInfo;
  66323. /**
  66324. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66325. * @param frustumPlanes defines the frustum to test
  66326. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66327. * @returns true if the bounding info is in the frustum planes
  66328. */
  66329. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66330. /**
  66331. * Gets the world distance between the min and max points of the bounding box
  66332. */
  66333. readonly diagonalLength: number;
  66334. /**
  66335. * Checks if a cullable object (mesh...) is in the camera frustum
  66336. * Unlike isInFrustum this cheks the full bounding box
  66337. * @param frustumPlanes Camera near/planes
  66338. * @returns true if the object is in frustum otherwise false
  66339. */
  66340. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66341. /** @hidden */
  66342. _checkCollision(collider: Collider): boolean;
  66343. /**
  66344. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66345. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66346. * @param point the point to check intersection with
  66347. * @returns if the point intersects
  66348. */
  66349. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66350. /**
  66351. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66353. * @param boundingInfo the bounding info to check intersection with
  66354. * @param precise if the intersection should be done using OBB
  66355. * @returns if the bounding info intersects
  66356. */
  66357. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66358. }
  66359. }
  66360. declare module BABYLON {
  66361. /**
  66362. * Defines an array and its length.
  66363. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66364. */
  66365. export interface ISmartArrayLike<T> {
  66366. /**
  66367. * The data of the array.
  66368. */
  66369. data: Array<T>;
  66370. /**
  66371. * The active length of the array.
  66372. */
  66373. length: number;
  66374. }
  66375. /**
  66376. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66377. */
  66378. export class SmartArray<T> implements ISmartArrayLike<T> {
  66379. /**
  66380. * The full set of data from the array.
  66381. */
  66382. data: Array<T>;
  66383. /**
  66384. * The active length of the array.
  66385. */
  66386. length: number;
  66387. protected _id: number;
  66388. /**
  66389. * Instantiates a Smart Array.
  66390. * @param capacity defines the default capacity of the array.
  66391. */
  66392. constructor(capacity: number);
  66393. /**
  66394. * Pushes a value at the end of the active data.
  66395. * @param value defines the object to push in the array.
  66396. */
  66397. push(value: T): void;
  66398. /**
  66399. * Iterates over the active data and apply the lambda to them.
  66400. * @param func defines the action to apply on each value.
  66401. */
  66402. forEach(func: (content: T) => void): void;
  66403. /**
  66404. * Sorts the full sets of data.
  66405. * @param compareFn defines the comparison function to apply.
  66406. */
  66407. sort(compareFn: (a: T, b: T) => number): void;
  66408. /**
  66409. * Resets the active data to an empty array.
  66410. */
  66411. reset(): void;
  66412. /**
  66413. * Releases all the data from the array as well as the array.
  66414. */
  66415. dispose(): void;
  66416. /**
  66417. * Concats the active data with a given array.
  66418. * @param array defines the data to concatenate with.
  66419. */
  66420. concat(array: any): void;
  66421. /**
  66422. * Returns the position of a value in the active data.
  66423. * @param value defines the value to find the index for
  66424. * @returns the index if found in the active data otherwise -1
  66425. */
  66426. indexOf(value: T): number;
  66427. /**
  66428. * Returns whether an element is part of the active data.
  66429. * @param value defines the value to look for
  66430. * @returns true if found in the active data otherwise false
  66431. */
  66432. contains(value: T): boolean;
  66433. private static _GlobalId;
  66434. }
  66435. /**
  66436. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66437. * The data in this array can only be present once
  66438. */
  66439. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66440. private _duplicateId;
  66441. /**
  66442. * Pushes a value at the end of the active data.
  66443. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66444. * @param value defines the object to push in the array.
  66445. */
  66446. push(value: T): void;
  66447. /**
  66448. * Pushes a value at the end of the active data.
  66449. * If the data is already present, it won t be added again
  66450. * @param value defines the object to push in the array.
  66451. * @returns true if added false if it was already present
  66452. */
  66453. pushNoDuplicate(value: T): boolean;
  66454. /**
  66455. * Resets the active data to an empty array.
  66456. */
  66457. reset(): void;
  66458. /**
  66459. * Concats the active data with a given array.
  66460. * This ensures no dupplicate will be present in the result.
  66461. * @param array defines the data to concatenate with.
  66462. */
  66463. concatWithNoDuplicate(array: any): void;
  66464. }
  66465. }
  66466. declare module BABYLON {
  66467. /**
  66468. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66469. * separate meshes. This can be use to improve performances.
  66470. * @see http://doc.babylonjs.com/how_to/multi_materials
  66471. */
  66472. export class MultiMaterial extends Material {
  66473. private _subMaterials;
  66474. /**
  66475. * Gets or Sets the list of Materials used within the multi material.
  66476. * They need to be ordered according to the submeshes order in the associated mesh
  66477. */
  66478. subMaterials: Nullable<Material>[];
  66479. /**
  66480. * Function used to align with Node.getChildren()
  66481. * @returns the list of Materials used within the multi material
  66482. */
  66483. getChildren(): Nullable<Material>[];
  66484. /**
  66485. * Instantiates a new Multi Material
  66486. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66487. * separate meshes. This can be use to improve performances.
  66488. * @see http://doc.babylonjs.com/how_to/multi_materials
  66489. * @param name Define the name in the scene
  66490. * @param scene Define the scene the material belongs to
  66491. */
  66492. constructor(name: string, scene: Scene);
  66493. private _hookArray;
  66494. /**
  66495. * Get one of the submaterial by its index in the submaterials array
  66496. * @param index The index to look the sub material at
  66497. * @returns The Material if the index has been defined
  66498. */
  66499. getSubMaterial(index: number): Nullable<Material>;
  66500. /**
  66501. * Get the list of active textures for the whole sub materials list.
  66502. * @returns All the textures that will be used during the rendering
  66503. */
  66504. getActiveTextures(): BaseTexture[];
  66505. /**
  66506. * Gets the current class name of the material e.g. "MultiMaterial"
  66507. * Mainly use in serialization.
  66508. * @returns the class name
  66509. */
  66510. getClassName(): string;
  66511. /**
  66512. * Checks if the material is ready to render the requested sub mesh
  66513. * @param mesh Define the mesh the submesh belongs to
  66514. * @param subMesh Define the sub mesh to look readyness for
  66515. * @param useInstances Define whether or not the material is used with instances
  66516. * @returns true if ready, otherwise false
  66517. */
  66518. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66519. /**
  66520. * Clones the current material and its related sub materials
  66521. * @param name Define the name of the newly cloned material
  66522. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66523. * @returns the cloned material
  66524. */
  66525. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66526. /**
  66527. * Serializes the materials into a JSON representation.
  66528. * @returns the JSON representation
  66529. */
  66530. serialize(): any;
  66531. /**
  66532. * Dispose the material and release its associated resources
  66533. * @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)
  66534. * @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)
  66535. * @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)
  66536. */
  66537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66538. /**
  66539. * Creates a MultiMaterial from parsed MultiMaterial data.
  66540. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66541. * @param scene defines the hosting scene
  66542. * @returns a new MultiMaterial
  66543. */
  66544. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66545. }
  66546. }
  66547. declare module BABYLON {
  66548. /**
  66549. * Class used to represent data loading progression
  66550. */
  66551. export class SceneLoaderFlags {
  66552. private static _ForceFullSceneLoadingForIncremental;
  66553. private static _ShowLoadingScreen;
  66554. private static _CleanBoneMatrixWeights;
  66555. private static _loggingLevel;
  66556. /**
  66557. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66558. */
  66559. static ForceFullSceneLoadingForIncremental: boolean;
  66560. /**
  66561. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66562. */
  66563. static ShowLoadingScreen: boolean;
  66564. /**
  66565. * Defines the current logging level (while loading the scene)
  66566. * @ignorenaming
  66567. */
  66568. static loggingLevel: number;
  66569. /**
  66570. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66571. */
  66572. static CleanBoneMatrixWeights: boolean;
  66573. }
  66574. }
  66575. declare module BABYLON {
  66576. /**
  66577. * 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.
  66578. * @see https://doc.babylonjs.com/how_to/transformnode
  66579. */
  66580. export class TransformNode extends Node {
  66581. /**
  66582. * Object will not rotate to face the camera
  66583. */
  66584. static BILLBOARDMODE_NONE: number;
  66585. /**
  66586. * Object will rotate to face the camera but only on the x axis
  66587. */
  66588. static BILLBOARDMODE_X: number;
  66589. /**
  66590. * Object will rotate to face the camera but only on the y axis
  66591. */
  66592. static BILLBOARDMODE_Y: number;
  66593. /**
  66594. * Object will rotate to face the camera but only on the z axis
  66595. */
  66596. static BILLBOARDMODE_Z: number;
  66597. /**
  66598. * Object will rotate to face the camera
  66599. */
  66600. static BILLBOARDMODE_ALL: number;
  66601. private _forward;
  66602. private _forwardInverted;
  66603. private _up;
  66604. private _right;
  66605. private _rightInverted;
  66606. private _position;
  66607. private _rotation;
  66608. private _rotationQuaternion;
  66609. protected _scaling: Vector3;
  66610. protected _isDirty: boolean;
  66611. private _transformToBoneReferal;
  66612. /**
  66613. * Set the billboard mode. Default is 0.
  66614. *
  66615. * | Value | Type | Description |
  66616. * | --- | --- | --- |
  66617. * | 0 | BILLBOARDMODE_NONE | |
  66618. * | 1 | BILLBOARDMODE_X | |
  66619. * | 2 | BILLBOARDMODE_Y | |
  66620. * | 4 | BILLBOARDMODE_Z | |
  66621. * | 7 | BILLBOARDMODE_ALL | |
  66622. *
  66623. */
  66624. billboardMode: number;
  66625. /**
  66626. * 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
  66627. */
  66628. scalingDeterminant: number;
  66629. /**
  66630. * Sets the distance of the object to max, often used by skybox
  66631. */
  66632. infiniteDistance: boolean;
  66633. /**
  66634. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66635. * By default the system will update normals to compensate
  66636. */
  66637. ignoreNonUniformScaling: boolean;
  66638. /** @hidden */
  66639. _poseMatrix: Matrix;
  66640. /** @hidden */
  66641. _localMatrix: Matrix;
  66642. private _absolutePosition;
  66643. private _pivotMatrix;
  66644. private _pivotMatrixInverse;
  66645. protected _postMultiplyPivotMatrix: boolean;
  66646. private _tempMatrix;
  66647. private _tempMatrix2;
  66648. protected _isWorldMatrixFrozen: boolean;
  66649. /** @hidden */
  66650. _indexInSceneTransformNodesArray: number;
  66651. /**
  66652. * An event triggered after the world matrix is updated
  66653. */
  66654. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66655. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66656. /**
  66657. * Gets a string identifying the name of the class
  66658. * @returns "TransformNode" string
  66659. */
  66660. getClassName(): string;
  66661. /**
  66662. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66663. */
  66664. position: Vector3;
  66665. /**
  66666. * 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)).
  66667. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66668. */
  66669. rotation: Vector3;
  66670. /**
  66671. * 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)).
  66672. */
  66673. scaling: Vector3;
  66674. /**
  66675. * 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).
  66676. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66677. */
  66678. rotationQuaternion: Nullable<Quaternion>;
  66679. /**
  66680. * The forward direction of that transform in world space.
  66681. */
  66682. readonly forward: Vector3;
  66683. /**
  66684. * The up direction of that transform in world space.
  66685. */
  66686. readonly up: Vector3;
  66687. /**
  66688. * The right direction of that transform in world space.
  66689. */
  66690. readonly right: Vector3;
  66691. /**
  66692. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66693. * @param matrix the matrix to copy the pose from
  66694. * @returns this TransformNode.
  66695. */
  66696. updatePoseMatrix(matrix: Matrix): TransformNode;
  66697. /**
  66698. * Returns the mesh Pose matrix.
  66699. * @returns the pose matrix
  66700. */
  66701. getPoseMatrix(): Matrix;
  66702. /** @hidden */
  66703. _isSynchronized(): boolean;
  66704. /** @hidden */
  66705. _initCache(): void;
  66706. /**
  66707. * Flag the transform node as dirty (Forcing it to update everything)
  66708. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66709. * @returns this transform node
  66710. */
  66711. markAsDirty(property: string): TransformNode;
  66712. /**
  66713. * Returns the current mesh absolute position.
  66714. * Returns a Vector3.
  66715. */
  66716. readonly absolutePosition: Vector3;
  66717. /**
  66718. * Sets a new matrix to apply before all other transformation
  66719. * @param matrix defines the transform matrix
  66720. * @returns the current TransformNode
  66721. */
  66722. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66723. /**
  66724. * Sets a new pivot matrix to the current node
  66725. * @param matrix defines the new pivot matrix to use
  66726. * @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
  66727. * @returns the current TransformNode
  66728. */
  66729. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66730. /**
  66731. * Returns the mesh pivot matrix.
  66732. * Default : Identity.
  66733. * @returns the matrix
  66734. */
  66735. getPivotMatrix(): Matrix;
  66736. /**
  66737. * Prevents the World matrix to be computed any longer.
  66738. * @returns the TransformNode.
  66739. */
  66740. freezeWorldMatrix(): TransformNode;
  66741. /**
  66742. * Allows back the World matrix computation.
  66743. * @returns the TransformNode.
  66744. */
  66745. unfreezeWorldMatrix(): this;
  66746. /**
  66747. * True if the World matrix has been frozen.
  66748. */
  66749. readonly isWorldMatrixFrozen: boolean;
  66750. /**
  66751. * Retuns the mesh absolute position in the World.
  66752. * @returns a Vector3.
  66753. */
  66754. getAbsolutePosition(): Vector3;
  66755. /**
  66756. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66757. * @param absolutePosition the absolute position to set
  66758. * @returns the TransformNode.
  66759. */
  66760. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66761. /**
  66762. * Sets the mesh position in its local space.
  66763. * @param vector3 the position to set in localspace
  66764. * @returns the TransformNode.
  66765. */
  66766. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66767. /**
  66768. * Returns the mesh position in the local space from the current World matrix values.
  66769. * @returns a new Vector3.
  66770. */
  66771. getPositionExpressedInLocalSpace(): Vector3;
  66772. /**
  66773. * Translates the mesh along the passed Vector3 in its local space.
  66774. * @param vector3 the distance to translate in localspace
  66775. * @returns the TransformNode.
  66776. */
  66777. locallyTranslate(vector3: Vector3): TransformNode;
  66778. private static _lookAtVectorCache;
  66779. /**
  66780. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66781. * @param targetPoint the position (must be in same space as current mesh) to look at
  66782. * @param yawCor optional yaw (y-axis) correction in radians
  66783. * @param pitchCor optional pitch (x-axis) correction in radians
  66784. * @param rollCor optional roll (z-axis) correction in radians
  66785. * @param space the choosen space of the target
  66786. * @returns the TransformNode.
  66787. */
  66788. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66789. /**
  66790. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66791. * This Vector3 is expressed in the World space.
  66792. * @param localAxis axis to rotate
  66793. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66794. */
  66795. getDirection(localAxis: Vector3): Vector3;
  66796. /**
  66797. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66798. * localAxis is expressed in the mesh local space.
  66799. * result is computed in the Wordl space from the mesh World matrix.
  66800. * @param localAxis axis to rotate
  66801. * @param result the resulting transformnode
  66802. * @returns this TransformNode.
  66803. */
  66804. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66805. /**
  66806. * Sets this transform node rotation to the given local axis.
  66807. * @param localAxis the axis in local space
  66808. * @param yawCor optional yaw (y-axis) correction in radians
  66809. * @param pitchCor optional pitch (x-axis) correction in radians
  66810. * @param rollCor optional roll (z-axis) correction in radians
  66811. * @returns this TransformNode
  66812. */
  66813. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66814. /**
  66815. * Sets a new pivot point to the current node
  66816. * @param point defines the new pivot point to use
  66817. * @param space defines if the point is in world or local space (local by default)
  66818. * @returns the current TransformNode
  66819. */
  66820. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66821. /**
  66822. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66823. * @returns the pivot point
  66824. */
  66825. getPivotPoint(): Vector3;
  66826. /**
  66827. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66828. * @param result the vector3 to store the result
  66829. * @returns this TransformNode.
  66830. */
  66831. getPivotPointToRef(result: Vector3): TransformNode;
  66832. /**
  66833. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66834. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66835. */
  66836. getAbsolutePivotPoint(): Vector3;
  66837. /**
  66838. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66839. * @param result vector3 to store the result
  66840. * @returns this TransformNode.
  66841. */
  66842. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66843. /**
  66844. * Defines the passed node as the parent of the current node.
  66845. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66846. * @see https://doc.babylonjs.com/how_to/parenting
  66847. * @param node the node ot set as the parent
  66848. * @returns this TransformNode.
  66849. */
  66850. setParent(node: Nullable<Node>): TransformNode;
  66851. private _nonUniformScaling;
  66852. /**
  66853. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66854. */
  66855. readonly nonUniformScaling: boolean;
  66856. /** @hidden */
  66857. _updateNonUniformScalingState(value: boolean): boolean;
  66858. /**
  66859. * Attach the current TransformNode to another TransformNode associated with a bone
  66860. * @param bone Bone affecting the TransformNode
  66861. * @param affectedTransformNode TransformNode associated with the bone
  66862. * @returns this object
  66863. */
  66864. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66865. /**
  66866. * Detach the transform node if its associated with a bone
  66867. * @returns this object
  66868. */
  66869. detachFromBone(): TransformNode;
  66870. private static _rotationAxisCache;
  66871. /**
  66872. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66873. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66874. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66875. * The passed axis is also normalized.
  66876. * @param axis the axis to rotate around
  66877. * @param amount the amount to rotate in radians
  66878. * @param space Space to rotate in (Default: local)
  66879. * @returns the TransformNode.
  66880. */
  66881. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66882. /**
  66883. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66885. * The passed axis is also normalized. .
  66886. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66887. * @param point the point to rotate around
  66888. * @param axis the axis to rotate around
  66889. * @param amount the amount to rotate in radians
  66890. * @returns the TransformNode
  66891. */
  66892. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66893. /**
  66894. * Translates the mesh along the axis vector for the passed distance in the given space.
  66895. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66896. * @param axis the axis to translate in
  66897. * @param distance the distance to translate
  66898. * @param space Space to rotate in (Default: local)
  66899. * @returns the TransformNode.
  66900. */
  66901. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66902. /**
  66903. * Adds a rotation step to the mesh current rotation.
  66904. * x, y, z are Euler angles expressed in radians.
  66905. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66906. * This means this rotation is made in the mesh local space only.
  66907. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66908. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66909. * ```javascript
  66910. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66911. * ```
  66912. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66913. * 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.
  66914. * @param x Rotation to add
  66915. * @param y Rotation to add
  66916. * @param z Rotation to add
  66917. * @returns the TransformNode.
  66918. */
  66919. addRotation(x: number, y: number, z: number): TransformNode;
  66920. /**
  66921. * Computes the world matrix of the node
  66922. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66923. * @returns the world matrix
  66924. */
  66925. computeWorldMatrix(force?: boolean): Matrix;
  66926. protected _afterComputeWorldMatrix(): void;
  66927. /**
  66928. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66929. * @param func callback function to add
  66930. *
  66931. * @returns the TransformNode.
  66932. */
  66933. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66934. /**
  66935. * Removes a registered callback function.
  66936. * @param func callback function to remove
  66937. * @returns the TransformNode.
  66938. */
  66939. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66940. /**
  66941. * Gets the position of the current mesh in camera space
  66942. * @param camera defines the camera to use
  66943. * @returns a position
  66944. */
  66945. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66946. /**
  66947. * Returns the distance from the mesh to the active camera
  66948. * @param camera defines the camera to use
  66949. * @returns the distance
  66950. */
  66951. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66952. /**
  66953. * Clone the current transform node
  66954. * @param name Name of the new clone
  66955. * @param newParent New parent for the clone
  66956. * @param doNotCloneChildren Do not clone children hierarchy
  66957. * @returns the new transform node
  66958. */
  66959. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66960. /**
  66961. * Serializes the objects information.
  66962. * @param currentSerializationObject defines the object to serialize in
  66963. * @returns the serialized object
  66964. */
  66965. serialize(currentSerializationObject?: any): any;
  66966. /**
  66967. * Returns a new TransformNode object parsed from the source provided.
  66968. * @param parsedTransformNode is the source.
  66969. * @param scene the scne the object belongs to
  66970. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66971. * @returns a new TransformNode object parsed from the source provided.
  66972. */
  66973. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66974. /**
  66975. * Get all child-transformNodes of this node
  66976. * @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
  66977. * @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
  66978. * @returns an array of TransformNode
  66979. */
  66980. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66981. /**
  66982. * Releases resources associated with this transform node.
  66983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66985. */
  66986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66987. }
  66988. }
  66989. declare module BABYLON {
  66990. /**
  66991. * Class used to override all child animations of a given target
  66992. */
  66993. export class AnimationPropertiesOverride {
  66994. /**
  66995. * Gets or sets a value indicating if animation blending must be used
  66996. */
  66997. enableBlending: boolean;
  66998. /**
  66999. * Gets or sets the blending speed to use when enableBlending is true
  67000. */
  67001. blendingSpeed: number;
  67002. /**
  67003. * Gets or sets the default loop mode to use
  67004. */
  67005. loopMode: number;
  67006. }
  67007. }
  67008. declare module BABYLON {
  67009. /**
  67010. * Class used to store bone information
  67011. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67012. */
  67013. export class Bone extends Node {
  67014. /**
  67015. * defines the bone name
  67016. */
  67017. name: string;
  67018. private static _tmpVecs;
  67019. private static _tmpQuat;
  67020. private static _tmpMats;
  67021. /**
  67022. * Gets the list of child bones
  67023. */
  67024. children: Bone[];
  67025. /** Gets the animations associated with this bone */
  67026. animations: Animation[];
  67027. /**
  67028. * Gets or sets bone length
  67029. */
  67030. length: number;
  67031. /**
  67032. * @hidden Internal only
  67033. * Set this value to map this bone to a different index in the transform matrices
  67034. * Set this value to -1 to exclude the bone from the transform matrices
  67035. */
  67036. _index: Nullable<number>;
  67037. private _skeleton;
  67038. private _localMatrix;
  67039. private _restPose;
  67040. private _baseMatrix;
  67041. private _absoluteTransform;
  67042. private _invertedAbsoluteTransform;
  67043. private _parent;
  67044. private _scalingDeterminant;
  67045. private _worldTransform;
  67046. private _localScaling;
  67047. private _localRotation;
  67048. private _localPosition;
  67049. private _needToDecompose;
  67050. private _needToCompose;
  67051. /** @hidden */
  67052. _linkedTransformNode: Nullable<TransformNode>;
  67053. /** @hidden */
  67054. /** @hidden */
  67055. _matrix: Matrix;
  67056. /**
  67057. * Create a new bone
  67058. * @param name defines the bone name
  67059. * @param skeleton defines the parent skeleton
  67060. * @param parentBone defines the parent (can be null if the bone is the root)
  67061. * @param localMatrix defines the local matrix
  67062. * @param restPose defines the rest pose matrix
  67063. * @param baseMatrix defines the base matrix
  67064. * @param index defines index of the bone in the hiearchy
  67065. */
  67066. constructor(
  67067. /**
  67068. * defines the bone name
  67069. */
  67070. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67071. /**
  67072. * Gets the current object class name.
  67073. * @return the class name
  67074. */
  67075. getClassName(): string;
  67076. /**
  67077. * Gets the parent skeleton
  67078. * @returns a skeleton
  67079. */
  67080. getSkeleton(): Skeleton;
  67081. /**
  67082. * Gets parent bone
  67083. * @returns a bone or null if the bone is the root of the bone hierarchy
  67084. */
  67085. getParent(): Nullable<Bone>;
  67086. /**
  67087. * Returns an array containing the root bones
  67088. * @returns an array containing the root bones
  67089. */
  67090. getChildren(): Array<Bone>;
  67091. /**
  67092. * Sets the parent bone
  67093. * @param parent defines the parent (can be null if the bone is the root)
  67094. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67095. */
  67096. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67097. /**
  67098. * Gets the local matrix
  67099. * @returns a matrix
  67100. */
  67101. getLocalMatrix(): Matrix;
  67102. /**
  67103. * Gets the base matrix (initial matrix which remains unchanged)
  67104. * @returns a matrix
  67105. */
  67106. getBaseMatrix(): Matrix;
  67107. /**
  67108. * Gets the rest pose matrix
  67109. * @returns a matrix
  67110. */
  67111. getRestPose(): Matrix;
  67112. /**
  67113. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67114. */
  67115. getWorldMatrix(): Matrix;
  67116. /**
  67117. * Sets the local matrix to rest pose matrix
  67118. */
  67119. returnToRest(): void;
  67120. /**
  67121. * Gets the inverse of the absolute transform matrix.
  67122. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67123. * @returns a matrix
  67124. */
  67125. getInvertedAbsoluteTransform(): Matrix;
  67126. /**
  67127. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67128. * @returns a matrix
  67129. */
  67130. getAbsoluteTransform(): Matrix;
  67131. /**
  67132. * Links with the given transform node.
  67133. * The local matrix of this bone is copied from the transform node every frame.
  67134. * @param transformNode defines the transform node to link to
  67135. */
  67136. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67137. /** Gets or sets current position (in local space) */
  67138. position: Vector3;
  67139. /** Gets or sets current rotation (in local space) */
  67140. rotation: Vector3;
  67141. /** Gets or sets current rotation quaternion (in local space) */
  67142. rotationQuaternion: Quaternion;
  67143. /** Gets or sets current scaling (in local space) */
  67144. scaling: Vector3;
  67145. /**
  67146. * Gets the animation properties override
  67147. */
  67148. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67149. private _decompose;
  67150. private _compose;
  67151. /**
  67152. * Update the base and local matrices
  67153. * @param matrix defines the new base or local matrix
  67154. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67155. * @param updateLocalMatrix defines if the local matrix should be updated
  67156. */
  67157. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67158. /** @hidden */
  67159. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67160. /**
  67161. * Flag the bone as dirty (Forcing it to update everything)
  67162. */
  67163. markAsDirty(): void;
  67164. private _markAsDirtyAndCompose;
  67165. private _markAsDirtyAndDecompose;
  67166. /**
  67167. * Translate the bone in local or world space
  67168. * @param vec The amount to translate the bone
  67169. * @param space The space that the translation is in
  67170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67171. */
  67172. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67173. /**
  67174. * Set the postion of the bone in local or world space
  67175. * @param position The position to set the bone
  67176. * @param space The space that the position is in
  67177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67178. */
  67179. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67180. /**
  67181. * Set the absolute position of the bone (world space)
  67182. * @param position The position to set the bone
  67183. * @param mesh The mesh that this bone is attached to
  67184. */
  67185. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67186. /**
  67187. * Scale the bone on the x, y and z axes (in local space)
  67188. * @param x The amount to scale the bone on the x axis
  67189. * @param y The amount to scale the bone on the y axis
  67190. * @param z The amount to scale the bone on the z axis
  67191. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67192. */
  67193. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67194. /**
  67195. * Set the bone scaling in local space
  67196. * @param scale defines the scaling vector
  67197. */
  67198. setScale(scale: Vector3): void;
  67199. /**
  67200. * Gets the current scaling in local space
  67201. * @returns the current scaling vector
  67202. */
  67203. getScale(): Vector3;
  67204. /**
  67205. * Gets the current scaling in local space and stores it in a target vector
  67206. * @param result defines the target vector
  67207. */
  67208. getScaleToRef(result: Vector3): void;
  67209. /**
  67210. * Set the yaw, pitch, and roll of the bone in local or world space
  67211. * @param yaw The rotation of the bone on the y axis
  67212. * @param pitch The rotation of the bone on the x axis
  67213. * @param roll The rotation of the bone on the z axis
  67214. * @param space The space that the axes of rotation are in
  67215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67216. */
  67217. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67218. /**
  67219. * Add a rotation to the bone on an axis in local or world space
  67220. * @param axis The axis to rotate the bone on
  67221. * @param amount The amount to rotate the bone
  67222. * @param space The space that the axis is in
  67223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67224. */
  67225. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67226. /**
  67227. * Set the rotation of the bone to a particular axis angle in local or world space
  67228. * @param axis The axis to rotate the bone on
  67229. * @param angle The angle that the bone should be rotated to
  67230. * @param space The space that the axis is in
  67231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67232. */
  67233. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67234. /**
  67235. * Set the euler rotation of the bone in local of world space
  67236. * @param rotation The euler rotation that the bone should be set to
  67237. * @param space The space that the rotation is in
  67238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67239. */
  67240. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67241. /**
  67242. * Set the quaternion rotation of the bone in local of world space
  67243. * @param quat The quaternion rotation that the bone should be set to
  67244. * @param space The space that the rotation is in
  67245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67246. */
  67247. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67248. /**
  67249. * Set the rotation matrix of the bone in local of world space
  67250. * @param rotMat The rotation matrix that the bone should be set to
  67251. * @param space The space that the rotation is in
  67252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67253. */
  67254. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67255. private _rotateWithMatrix;
  67256. private _getNegativeRotationToRef;
  67257. /**
  67258. * Get the position of the bone in local or world space
  67259. * @param space The space that the returned position is in
  67260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67261. * @returns The position of the bone
  67262. */
  67263. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67264. /**
  67265. * Copy the position of the bone to a vector3 in local or world space
  67266. * @param space The space that the returned position is in
  67267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67268. * @param result The vector3 to copy the position to
  67269. */
  67270. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67271. /**
  67272. * Get the absolute position of the bone (world space)
  67273. * @param mesh The mesh that this bone is attached to
  67274. * @returns The absolute position of the bone
  67275. */
  67276. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67277. /**
  67278. * Copy the absolute position of the bone (world space) to the result param
  67279. * @param mesh The mesh that this bone is attached to
  67280. * @param result The vector3 to copy the absolute position to
  67281. */
  67282. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67283. /**
  67284. * Compute the absolute transforms of this bone and its children
  67285. */
  67286. computeAbsoluteTransforms(): void;
  67287. /**
  67288. * Get the world direction from an axis that is in the local space of the bone
  67289. * @param localAxis The local direction that is used to compute the world direction
  67290. * @param mesh The mesh that this bone is attached to
  67291. * @returns The world direction
  67292. */
  67293. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67294. /**
  67295. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67296. * @param localAxis The local direction that is used to compute the world direction
  67297. * @param mesh The mesh that this bone is attached to
  67298. * @param result The vector3 that the world direction will be copied to
  67299. */
  67300. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67301. /**
  67302. * Get the euler rotation of the bone in local or world space
  67303. * @param space The space that the rotation should be in
  67304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67305. * @returns The euler rotation
  67306. */
  67307. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67308. /**
  67309. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67310. * @param space The space that the rotation should be in
  67311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67312. * @param result The vector3 that the rotation should be copied to
  67313. */
  67314. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67315. /**
  67316. * Get the quaternion rotation of the bone in either local or world space
  67317. * @param space The space that the rotation should be in
  67318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67319. * @returns The quaternion rotation
  67320. */
  67321. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67322. /**
  67323. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67324. * @param space The space that the rotation should be in
  67325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67326. * @param result The quaternion that the rotation should be copied to
  67327. */
  67328. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67329. /**
  67330. * Get the rotation matrix of the bone in local or world space
  67331. * @param space The space that the rotation should be in
  67332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67333. * @returns The rotation matrix
  67334. */
  67335. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67336. /**
  67337. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67338. * @param space The space that the rotation should be in
  67339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67340. * @param result The quaternion that the rotation should be copied to
  67341. */
  67342. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67343. /**
  67344. * Get the world position of a point that is in the local space of the bone
  67345. * @param position The local position
  67346. * @param mesh The mesh that this bone is attached to
  67347. * @returns The world position
  67348. */
  67349. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67350. /**
  67351. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67352. * @param position The local position
  67353. * @param mesh The mesh that this bone is attached to
  67354. * @param result The vector3 that the world position should be copied to
  67355. */
  67356. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67357. /**
  67358. * Get the local position of a point that is in world space
  67359. * @param position The world position
  67360. * @param mesh The mesh that this bone is attached to
  67361. * @returns The local position
  67362. */
  67363. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67364. /**
  67365. * Get the local position of a point that is in world space and copy it to the result param
  67366. * @param position The world position
  67367. * @param mesh The mesh that this bone is attached to
  67368. * @param result The vector3 that the local position should be copied to
  67369. */
  67370. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67371. }
  67372. }
  67373. declare module BABYLON {
  67374. /**
  67375. * Enum that determines the text-wrapping mode to use.
  67376. */
  67377. export enum InspectableType {
  67378. /**
  67379. * Checkbox for booleans
  67380. */
  67381. Checkbox = 0,
  67382. /**
  67383. * Sliders for numbers
  67384. */
  67385. Slider = 1,
  67386. /**
  67387. * Vector3
  67388. */
  67389. Vector3 = 2,
  67390. /**
  67391. * Quaternions
  67392. */
  67393. Quaternion = 3,
  67394. /**
  67395. * Color3
  67396. */
  67397. Color3 = 4
  67398. }
  67399. /**
  67400. * Interface used to define custom inspectable properties.
  67401. * This interface is used by the inspector to display custom property grids
  67402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67403. */
  67404. export interface IInspectable {
  67405. /**
  67406. * Gets the label to display
  67407. */
  67408. label: string;
  67409. /**
  67410. * Gets the name of the property to edit
  67411. */
  67412. propertyName: string;
  67413. /**
  67414. * Gets the type of the editor to use
  67415. */
  67416. type: InspectableType;
  67417. /**
  67418. * Gets the minimum value of the property when using in "slider" mode
  67419. */
  67420. min?: number;
  67421. /**
  67422. * Gets the maximum value of the property when using in "slider" mode
  67423. */
  67424. max?: number;
  67425. /**
  67426. * Gets the setp to use when using in "slider" mode
  67427. */
  67428. step?: number;
  67429. }
  67430. }
  67431. declare module BABYLON {
  67432. /**
  67433. * Class for creating a cube texture
  67434. */
  67435. export class CubeTexture extends BaseTexture {
  67436. private _delayedOnLoad;
  67437. /**
  67438. * The url of the texture
  67439. */
  67440. url: string;
  67441. /**
  67442. * Gets or sets the center of the bounding box associated with the cube texture.
  67443. * It must define where the camera used to render the texture was set
  67444. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67445. */
  67446. boundingBoxPosition: Vector3;
  67447. private _boundingBoxSize;
  67448. /**
  67449. * Gets or sets the size of the bounding box associated with the cube texture
  67450. * When defined, the cubemap will switch to local mode
  67451. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67452. * @example https://www.babylonjs-playground.com/#RNASML
  67453. */
  67454. /**
  67455. * Returns the bounding box size
  67456. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67457. */
  67458. boundingBoxSize: Vector3;
  67459. protected _rotationY: number;
  67460. /**
  67461. * Sets texture matrix rotation angle around Y axis in radians.
  67462. */
  67463. /**
  67464. * Gets texture matrix rotation angle around Y axis radians.
  67465. */
  67466. rotationY: number;
  67467. /**
  67468. * Are mip maps generated for this texture or not.
  67469. */
  67470. readonly noMipmap: boolean;
  67471. private _noMipmap;
  67472. private _files;
  67473. private _extensions;
  67474. private _textureMatrix;
  67475. private _format;
  67476. private _createPolynomials;
  67477. /** @hidden */
  67478. _prefiltered: boolean;
  67479. /**
  67480. * Creates a cube texture from an array of image urls
  67481. * @param files defines an array of image urls
  67482. * @param scene defines the hosting scene
  67483. * @param noMipmap specifies if mip maps are not used
  67484. * @returns a cube texture
  67485. */
  67486. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67487. /**
  67488. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67489. * @param url defines the url of the prefiltered texture
  67490. * @param scene defines the scene the texture is attached to
  67491. * @param forcedExtension defines the extension of the file if different from the url
  67492. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67493. * @return the prefiltered texture
  67494. */
  67495. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67496. /**
  67497. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67498. * as prefiltered data.
  67499. * @param rootUrl defines the url of the texture or the root name of the six images
  67500. * @param scene defines the scene the texture is attached to
  67501. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67502. * @param noMipmap defines if mipmaps should be created or not
  67503. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67504. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67505. * @param onError defines a callback triggered in case of error during load
  67506. * @param format defines the internal format to use for the texture once loaded
  67507. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67508. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67509. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67510. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67511. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67512. * @return the cube texture
  67513. */
  67514. 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);
  67515. /**
  67516. * Get the current class name of the texture useful for serialization or dynamic coding.
  67517. * @returns "CubeTexture"
  67518. */
  67519. getClassName(): string;
  67520. /**
  67521. * Update the url (and optional buffer) of this texture if url was null during construction.
  67522. * @param url the url of the texture
  67523. * @param forcedExtension defines the extension to use
  67524. * @param onLoad callback called when the texture is loaded (defaults to null)
  67525. */
  67526. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67527. /**
  67528. * Delays loading of the cube texture
  67529. * @param forcedExtension defines the extension to use
  67530. */
  67531. delayLoad(forcedExtension?: string): void;
  67532. /**
  67533. * Returns the reflection texture matrix
  67534. * @returns the reflection texture matrix
  67535. */
  67536. getReflectionTextureMatrix(): Matrix;
  67537. /**
  67538. * Sets the reflection texture matrix
  67539. * @param value Reflection texture matrix
  67540. */
  67541. setReflectionTextureMatrix(value: Matrix): void;
  67542. /**
  67543. * Parses text to create a cube texture
  67544. * @param parsedTexture define the serialized text to read from
  67545. * @param scene defines the hosting scene
  67546. * @param rootUrl defines the root url of the cube texture
  67547. * @returns a cube texture
  67548. */
  67549. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67550. /**
  67551. * Makes a clone, or deep copy, of the cube texture
  67552. * @returns a new cube texture
  67553. */
  67554. clone(): CubeTexture;
  67555. }
  67556. }
  67557. declare module BABYLON {
  67558. /** @hidden */
  67559. export var postprocessVertexShader: {
  67560. name: string;
  67561. shader: string;
  67562. };
  67563. }
  67564. declare module BABYLON {
  67565. /**
  67566. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67567. * This is the base of the follow, arc rotate cameras and Free camera
  67568. * @see http://doc.babylonjs.com/features/cameras
  67569. */
  67570. export class TargetCamera extends Camera {
  67571. private static _RigCamTransformMatrix;
  67572. private static _TargetTransformMatrix;
  67573. private static _TargetFocalPoint;
  67574. /**
  67575. * Define the current direction the camera is moving to
  67576. */
  67577. cameraDirection: Vector3;
  67578. /**
  67579. * Define the current rotation the camera is rotating to
  67580. */
  67581. cameraRotation: Vector2;
  67582. /**
  67583. * When set, the up vector of the camera will be updated by the rotation of the camera
  67584. */
  67585. updateUpVectorFromRotation: boolean;
  67586. private _tmpQuaternion;
  67587. /**
  67588. * Define the current rotation of the camera
  67589. */
  67590. rotation: Vector3;
  67591. /**
  67592. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67593. */
  67594. rotationQuaternion: Quaternion;
  67595. /**
  67596. * Define the current speed of the camera
  67597. */
  67598. speed: number;
  67599. /**
  67600. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67601. * around all axis.
  67602. */
  67603. noRotationConstraint: boolean;
  67604. /**
  67605. * Define the current target of the camera as an object or a position.
  67606. */
  67607. lockedTarget: any;
  67608. /** @hidden */
  67609. _currentTarget: Vector3;
  67610. /** @hidden */
  67611. _initialFocalDistance: number;
  67612. /** @hidden */
  67613. _viewMatrix: Matrix;
  67614. /** @hidden */
  67615. _camMatrix: Matrix;
  67616. /** @hidden */
  67617. _cameraTransformMatrix: Matrix;
  67618. /** @hidden */
  67619. _cameraRotationMatrix: Matrix;
  67620. /** @hidden */
  67621. _referencePoint: Vector3;
  67622. /** @hidden */
  67623. _transformedReferencePoint: Vector3;
  67624. protected _globalCurrentTarget: Vector3;
  67625. protected _globalCurrentUpVector: Vector3;
  67626. /** @hidden */
  67627. _reset: () => void;
  67628. private _defaultUp;
  67629. /**
  67630. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67631. * This is the base of the follow, arc rotate cameras and Free camera
  67632. * @see http://doc.babylonjs.com/features/cameras
  67633. * @param name Defines the name of the camera in the scene
  67634. * @param position Defines the start position of the camera in the scene
  67635. * @param scene Defines the scene the camera belongs to
  67636. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67637. */
  67638. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67639. /**
  67640. * Gets the position in front of the camera at a given distance.
  67641. * @param distance The distance from the camera we want the position to be
  67642. * @returns the position
  67643. */
  67644. getFrontPosition(distance: number): Vector3;
  67645. /** @hidden */
  67646. _getLockedTargetPosition(): Nullable<Vector3>;
  67647. private _storedPosition;
  67648. private _storedRotation;
  67649. private _storedRotationQuaternion;
  67650. /**
  67651. * Store current camera state of the camera (fov, position, rotation, etc..)
  67652. * @returns the camera
  67653. */
  67654. storeState(): Camera;
  67655. /**
  67656. * Restored camera state. You must call storeState() first
  67657. * @returns whether it was successful or not
  67658. * @hidden
  67659. */
  67660. _restoreStateValues(): boolean;
  67661. /** @hidden */
  67662. _initCache(): void;
  67663. /** @hidden */
  67664. _updateCache(ignoreParentClass?: boolean): void;
  67665. /** @hidden */
  67666. _isSynchronizedViewMatrix(): boolean;
  67667. /** @hidden */
  67668. _computeLocalCameraSpeed(): number;
  67669. /**
  67670. * Defines the target the camera should look at.
  67671. * This will automatically adapt alpha beta and radius to fit within the new target.
  67672. * @param target Defines the new target as a Vector or a mesh
  67673. */
  67674. setTarget(target: Vector3): void;
  67675. /**
  67676. * Return the current target position of the camera. This value is expressed in local space.
  67677. * @returns the target position
  67678. */
  67679. getTarget(): Vector3;
  67680. /** @hidden */
  67681. _decideIfNeedsToMove(): boolean;
  67682. /** @hidden */
  67683. _updatePosition(): void;
  67684. /** @hidden */
  67685. _checkInputs(): void;
  67686. protected _updateCameraRotationMatrix(): void;
  67687. /**
  67688. * 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)
  67689. * @returns the current camera
  67690. */
  67691. private _rotateUpVectorWithCameraRotationMatrix;
  67692. private _cachedRotationZ;
  67693. private _cachedQuaternionRotationZ;
  67694. /** @hidden */
  67695. _getViewMatrix(): Matrix;
  67696. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67697. /**
  67698. * @hidden
  67699. */
  67700. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67701. /**
  67702. * @hidden
  67703. */
  67704. _updateRigCameras(): void;
  67705. private _getRigCamPositionAndTarget;
  67706. /**
  67707. * Gets the current object class name.
  67708. * @return the class name
  67709. */
  67710. getClassName(): string;
  67711. }
  67712. }
  67713. declare module BABYLON {
  67714. /**
  67715. * @ignore
  67716. * This is a list of all the different input types that are available in the application.
  67717. * Fo instance: ArcRotateCameraGamepadInput...
  67718. */
  67719. export var CameraInputTypes: {};
  67720. /**
  67721. * This is the contract to implement in order to create a new input class.
  67722. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67723. */
  67724. export interface ICameraInput<TCamera extends Camera> {
  67725. /**
  67726. * Defines the camera the input is attached to.
  67727. */
  67728. camera: Nullable<TCamera>;
  67729. /**
  67730. * Gets the class name of the current intput.
  67731. * @returns the class name
  67732. */
  67733. getClassName(): string;
  67734. /**
  67735. * Get the friendly name associated with the input class.
  67736. * @returns the input friendly name
  67737. */
  67738. getSimpleName(): string;
  67739. /**
  67740. * Attach the input controls to a specific dom element to get the input from.
  67741. * @param element Defines the element the controls should be listened from
  67742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67743. */
  67744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67745. /**
  67746. * Detach the current controls from the specified dom element.
  67747. * @param element Defines the element to stop listening the inputs from
  67748. */
  67749. detachControl(element: Nullable<HTMLElement>): void;
  67750. /**
  67751. * Update the current camera state depending on the inputs that have been used this frame.
  67752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67753. */
  67754. checkInputs?: () => void;
  67755. }
  67756. /**
  67757. * Represents a map of input types to input instance or input index to input instance.
  67758. */
  67759. export interface CameraInputsMap<TCamera extends Camera> {
  67760. /**
  67761. * Accessor to the input by input type.
  67762. */
  67763. [name: string]: ICameraInput<TCamera>;
  67764. /**
  67765. * Accessor to the input by input index.
  67766. */
  67767. [idx: number]: ICameraInput<TCamera>;
  67768. }
  67769. /**
  67770. * This represents the input manager used within a camera.
  67771. * It helps dealing with all the different kind of input attached to a camera.
  67772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67773. */
  67774. export class CameraInputsManager<TCamera extends Camera> {
  67775. /**
  67776. * Defines the list of inputs attahed to the camera.
  67777. */
  67778. attached: CameraInputsMap<TCamera>;
  67779. /**
  67780. * Defines the dom element the camera is collecting inputs from.
  67781. * This is null if the controls have not been attached.
  67782. */
  67783. attachedElement: Nullable<HTMLElement>;
  67784. /**
  67785. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67786. */
  67787. noPreventDefault: boolean;
  67788. /**
  67789. * Defined the camera the input manager belongs to.
  67790. */
  67791. camera: TCamera;
  67792. /**
  67793. * Update the current camera state depending on the inputs that have been used this frame.
  67794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67795. */
  67796. checkInputs: () => void;
  67797. /**
  67798. * Instantiate a new Camera Input Manager.
  67799. * @param camera Defines the camera the input manager blongs to
  67800. */
  67801. constructor(camera: TCamera);
  67802. /**
  67803. * Add an input method to a camera
  67804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67805. * @param input camera input method
  67806. */
  67807. add(input: ICameraInput<TCamera>): void;
  67808. /**
  67809. * Remove a specific input method from a camera
  67810. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67811. * @param inputToRemove camera input method
  67812. */
  67813. remove(inputToRemove: ICameraInput<TCamera>): void;
  67814. /**
  67815. * Remove a specific input type from a camera
  67816. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67817. * @param inputType the type of the input to remove
  67818. */
  67819. removeByType(inputType: string): void;
  67820. private _addCheckInputs;
  67821. /**
  67822. * Attach the input controls to the currently attached dom element to listen the events from.
  67823. * @param input Defines the input to attach
  67824. */
  67825. attachInput(input: ICameraInput<TCamera>): void;
  67826. /**
  67827. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67828. * @param element Defines the dom element to collect the events from
  67829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67830. */
  67831. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67832. /**
  67833. * Detach the current manager inputs controls from a specific dom element.
  67834. * @param element Defines the dom element to collect the events from
  67835. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67836. */
  67837. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67838. /**
  67839. * Rebuild the dynamic inputCheck function from the current list of
  67840. * defined inputs in the manager.
  67841. */
  67842. rebuildInputCheck(): void;
  67843. /**
  67844. * Remove all attached input methods from a camera
  67845. */
  67846. clear(): void;
  67847. /**
  67848. * Serialize the current input manager attached to a camera.
  67849. * This ensures than once parsed,
  67850. * the input associated to the camera will be identical to the current ones
  67851. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67852. */
  67853. serialize(serializedCamera: any): void;
  67854. /**
  67855. * Parses an input manager serialized JSON to restore the previous list of inputs
  67856. * and states associated to a camera.
  67857. * @param parsedCamera Defines the JSON to parse
  67858. */
  67859. parse(parsedCamera: any): void;
  67860. }
  67861. }
  67862. declare module BABYLON {
  67863. /**
  67864. * Gather the list of keyboard event types as constants.
  67865. */
  67866. export class KeyboardEventTypes {
  67867. /**
  67868. * The keydown event is fired when a key becomes active (pressed).
  67869. */
  67870. static readonly KEYDOWN: number;
  67871. /**
  67872. * The keyup event is fired when a key has been released.
  67873. */
  67874. static readonly KEYUP: number;
  67875. }
  67876. /**
  67877. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67878. */
  67879. export class KeyboardInfo {
  67880. /**
  67881. * Defines the type of event (KeyboardEventTypes)
  67882. */
  67883. type: number;
  67884. /**
  67885. * Defines the related dom event
  67886. */
  67887. event: KeyboardEvent;
  67888. /**
  67889. * Instantiates a new keyboard info.
  67890. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67891. * @param type Defines the type of event (KeyboardEventTypes)
  67892. * @param event Defines the related dom event
  67893. */
  67894. constructor(
  67895. /**
  67896. * Defines the type of event (KeyboardEventTypes)
  67897. */
  67898. type: number,
  67899. /**
  67900. * Defines the related dom event
  67901. */
  67902. event: KeyboardEvent);
  67903. }
  67904. /**
  67905. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67906. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67907. */
  67908. export class KeyboardInfoPre extends KeyboardInfo {
  67909. /**
  67910. * Defines the type of event (KeyboardEventTypes)
  67911. */
  67912. type: number;
  67913. /**
  67914. * Defines the related dom event
  67915. */
  67916. event: KeyboardEvent;
  67917. /**
  67918. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67919. */
  67920. skipOnPointerObservable: boolean;
  67921. /**
  67922. * Instantiates a new keyboard pre info.
  67923. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67924. * @param type Defines the type of event (KeyboardEventTypes)
  67925. * @param event Defines the related dom event
  67926. */
  67927. constructor(
  67928. /**
  67929. * Defines the type of event (KeyboardEventTypes)
  67930. */
  67931. type: number,
  67932. /**
  67933. * Defines the related dom event
  67934. */
  67935. event: KeyboardEvent);
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /**
  67940. * Manage the keyboard inputs to control the movement of a free camera.
  67941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67942. */
  67943. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67944. /**
  67945. * Defines the camera the input is attached to.
  67946. */
  67947. camera: FreeCamera;
  67948. /**
  67949. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67950. */
  67951. keysUp: number[];
  67952. /**
  67953. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67954. */
  67955. keysDown: number[];
  67956. /**
  67957. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67958. */
  67959. keysLeft: number[];
  67960. /**
  67961. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67962. */
  67963. keysRight: number[];
  67964. private _keys;
  67965. private _onCanvasBlurObserver;
  67966. private _onKeyboardObserver;
  67967. private _engine;
  67968. private _scene;
  67969. /**
  67970. * Attach the input controls to a specific dom element to get the input from.
  67971. * @param element Defines the element the controls should be listened from
  67972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67973. */
  67974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67975. /**
  67976. * Detach the current controls from the specified dom element.
  67977. * @param element Defines the element to stop listening the inputs from
  67978. */
  67979. detachControl(element: Nullable<HTMLElement>): void;
  67980. /**
  67981. * Update the current camera state depending on the inputs that have been used this frame.
  67982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67983. */
  67984. checkInputs(): void;
  67985. /**
  67986. * Gets the class name of the current intput.
  67987. * @returns the class name
  67988. */
  67989. getClassName(): string;
  67990. /** @hidden */
  67991. _onLostFocus(): void;
  67992. /**
  67993. * Get the friendly name associated with the input class.
  67994. * @returns the input friendly name
  67995. */
  67996. getSimpleName(): string;
  67997. }
  67998. }
  67999. declare module BABYLON {
  68000. /**
  68001. * Interface describing all the common properties and methods a shadow light needs to implement.
  68002. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68003. * as well as binding the different shadow properties to the effects.
  68004. */
  68005. export interface IShadowLight extends Light {
  68006. /**
  68007. * The light id in the scene (used in scene.findLighById for instance)
  68008. */
  68009. id: string;
  68010. /**
  68011. * The position the shdow will be casted from.
  68012. */
  68013. position: Vector3;
  68014. /**
  68015. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68016. */
  68017. direction: Vector3;
  68018. /**
  68019. * The transformed position. Position of the light in world space taking parenting in account.
  68020. */
  68021. transformedPosition: Vector3;
  68022. /**
  68023. * The transformed direction. Direction of the light in world space taking parenting in account.
  68024. */
  68025. transformedDirection: Vector3;
  68026. /**
  68027. * The friendly name of the light in the scene.
  68028. */
  68029. name: string;
  68030. /**
  68031. * Defines the shadow projection clipping minimum z value.
  68032. */
  68033. shadowMinZ: number;
  68034. /**
  68035. * Defines the shadow projection clipping maximum z value.
  68036. */
  68037. shadowMaxZ: number;
  68038. /**
  68039. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68040. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68041. */
  68042. computeTransformedInformation(): boolean;
  68043. /**
  68044. * Gets the scene the light belongs to.
  68045. * @returns The scene
  68046. */
  68047. getScene(): Scene;
  68048. /**
  68049. * Callback defining a custom Projection Matrix Builder.
  68050. * This can be used to override the default projection matrix computation.
  68051. */
  68052. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68053. /**
  68054. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68055. * @param matrix The materix to updated with the projection information
  68056. * @param viewMatrix The transform matrix of the light
  68057. * @param renderList The list of mesh to render in the map
  68058. * @returns The current light
  68059. */
  68060. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68061. /**
  68062. * Gets the current depth scale used in ESM.
  68063. * @returns The scale
  68064. */
  68065. getDepthScale(): number;
  68066. /**
  68067. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68068. * @returns true if a cube texture needs to be use
  68069. */
  68070. needCube(): boolean;
  68071. /**
  68072. * Detects if the projection matrix requires to be recomputed this frame.
  68073. * @returns true if it requires to be recomputed otherwise, false.
  68074. */
  68075. needProjectionMatrixCompute(): boolean;
  68076. /**
  68077. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68078. */
  68079. forceProjectionMatrixCompute(): void;
  68080. /**
  68081. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68082. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68083. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68084. */
  68085. getShadowDirection(faceIndex?: number): Vector3;
  68086. /**
  68087. * Gets the minZ used for shadow according to both the scene and the light.
  68088. * @param activeCamera The camera we are returning the min for
  68089. * @returns the depth min z
  68090. */
  68091. getDepthMinZ(activeCamera: Camera): number;
  68092. /**
  68093. * Gets the maxZ used for shadow according to both the scene and the light.
  68094. * @param activeCamera The camera we are returning the max for
  68095. * @returns the depth max z
  68096. */
  68097. getDepthMaxZ(activeCamera: Camera): number;
  68098. }
  68099. /**
  68100. * Base implementation IShadowLight
  68101. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68102. */
  68103. export abstract class ShadowLight extends Light implements IShadowLight {
  68104. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68105. protected _position: Vector3;
  68106. protected _setPosition(value: Vector3): void;
  68107. /**
  68108. * Sets the position the shadow will be casted from. Also use as the light position for both
  68109. * point and spot lights.
  68110. */
  68111. /**
  68112. * Sets the position the shadow will be casted from. Also use as the light position for both
  68113. * point and spot lights.
  68114. */
  68115. position: Vector3;
  68116. protected _direction: Vector3;
  68117. protected _setDirection(value: Vector3): void;
  68118. /**
  68119. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68120. * Also use as the light direction on spot and directional lights.
  68121. */
  68122. /**
  68123. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68124. * Also use as the light direction on spot and directional lights.
  68125. */
  68126. direction: Vector3;
  68127. private _shadowMinZ;
  68128. /**
  68129. * Gets the shadow projection clipping minimum z value.
  68130. */
  68131. /**
  68132. * Sets the shadow projection clipping minimum z value.
  68133. */
  68134. shadowMinZ: number;
  68135. private _shadowMaxZ;
  68136. /**
  68137. * Sets the shadow projection clipping maximum z value.
  68138. */
  68139. /**
  68140. * Gets the shadow projection clipping maximum z value.
  68141. */
  68142. shadowMaxZ: number;
  68143. /**
  68144. * Callback defining a custom Projection Matrix Builder.
  68145. * This can be used to override the default projection matrix computation.
  68146. */
  68147. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68148. /**
  68149. * The transformed position. Position of the light in world space taking parenting in account.
  68150. */
  68151. transformedPosition: Vector3;
  68152. /**
  68153. * The transformed direction. Direction of the light in world space taking parenting in account.
  68154. */
  68155. transformedDirection: Vector3;
  68156. private _needProjectionMatrixCompute;
  68157. /**
  68158. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68159. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68160. */
  68161. computeTransformedInformation(): boolean;
  68162. /**
  68163. * Return the depth scale used for the shadow map.
  68164. * @returns the depth scale.
  68165. */
  68166. getDepthScale(): number;
  68167. /**
  68168. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68169. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68170. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68171. */
  68172. getShadowDirection(faceIndex?: number): Vector3;
  68173. /**
  68174. * Returns the ShadowLight absolute position in the World.
  68175. * @returns the position vector in world space
  68176. */
  68177. getAbsolutePosition(): Vector3;
  68178. /**
  68179. * Sets the ShadowLight direction toward the passed target.
  68180. * @param target The point to target in local space
  68181. * @returns the updated ShadowLight direction
  68182. */
  68183. setDirectionToTarget(target: Vector3): Vector3;
  68184. /**
  68185. * Returns the light rotation in euler definition.
  68186. * @returns the x y z rotation in local space.
  68187. */
  68188. getRotation(): Vector3;
  68189. /**
  68190. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68191. * @returns true if a cube texture needs to be use
  68192. */
  68193. needCube(): boolean;
  68194. /**
  68195. * Detects if the projection matrix requires to be recomputed this frame.
  68196. * @returns true if it requires to be recomputed otherwise, false.
  68197. */
  68198. needProjectionMatrixCompute(): boolean;
  68199. /**
  68200. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68201. */
  68202. forceProjectionMatrixCompute(): void;
  68203. /** @hidden */
  68204. _initCache(): void;
  68205. /** @hidden */
  68206. _isSynchronized(): boolean;
  68207. /**
  68208. * Computes the world matrix of the node
  68209. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68210. * @returns the world matrix
  68211. */
  68212. computeWorldMatrix(force?: boolean): Matrix;
  68213. /**
  68214. * Gets the minZ used for shadow according to both the scene and the light.
  68215. * @param activeCamera The camera we are returning the min for
  68216. * @returns the depth min z
  68217. */
  68218. getDepthMinZ(activeCamera: Camera): number;
  68219. /**
  68220. * Gets the maxZ used for shadow according to both the scene and the light.
  68221. * @param activeCamera The camera we are returning the max for
  68222. * @returns the depth max z
  68223. */
  68224. getDepthMaxZ(activeCamera: Camera): number;
  68225. /**
  68226. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68227. * @param matrix The materix to updated with the projection information
  68228. * @param viewMatrix The transform matrix of the light
  68229. * @param renderList The list of mesh to render in the map
  68230. * @returns The current light
  68231. */
  68232. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68233. }
  68234. }
  68235. declare module BABYLON {
  68236. /**
  68237. * "Static Class" containing the most commonly used helper while dealing with material for
  68238. * rendering purpose.
  68239. *
  68240. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68241. *
  68242. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68243. */
  68244. export class MaterialHelper {
  68245. /**
  68246. * Bind the current view position to an effect.
  68247. * @param effect The effect to be bound
  68248. * @param scene The scene the eyes position is used from
  68249. */
  68250. static BindEyePosition(effect: Effect, scene: Scene): void;
  68251. /**
  68252. * Helps preparing the defines values about the UVs in used in the effect.
  68253. * UVs are shared as much as we can accross channels in the shaders.
  68254. * @param texture The texture we are preparing the UVs for
  68255. * @param defines The defines to update
  68256. * @param key The channel key "diffuse", "specular"... used in the shader
  68257. */
  68258. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68259. /**
  68260. * Binds a texture matrix value to its corrsponding uniform
  68261. * @param texture The texture to bind the matrix for
  68262. * @param uniformBuffer The uniform buffer receivin the data
  68263. * @param key The channel key "diffuse", "specular"... used in the shader
  68264. */
  68265. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68266. /**
  68267. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68268. * @param mesh defines the current mesh
  68269. * @param scene defines the current scene
  68270. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68271. * @param pointsCloud defines if point cloud rendering has to be turned on
  68272. * @param fogEnabled defines if fog has to be turned on
  68273. * @param alphaTest defines if alpha testing has to be turned on
  68274. * @param defines defines the current list of defines
  68275. */
  68276. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68277. /**
  68278. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68279. * @param scene defines the current scene
  68280. * @param engine defines the current engine
  68281. * @param defines specifies the list of active defines
  68282. * @param useInstances defines if instances have to be turned on
  68283. * @param useClipPlane defines if clip plane have to be turned on
  68284. */
  68285. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68286. /**
  68287. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68288. * @param mesh The mesh containing the geometry data we will draw
  68289. * @param defines The defines to update
  68290. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68291. * @param useBones Precise whether bones should be used or not (override mesh info)
  68292. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68293. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68294. * @returns false if defines are considered not dirty and have not been checked
  68295. */
  68296. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68297. /**
  68298. * Prepares the defines related to multiview
  68299. * @param scene The scene we are intending to draw
  68300. * @param defines The defines to update
  68301. */
  68302. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68303. /**
  68304. * Prepares the defines related to the light information passed in parameter
  68305. * @param scene The scene we are intending to draw
  68306. * @param mesh The mesh the effect is compiling for
  68307. * @param defines The defines to update
  68308. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68309. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68310. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68311. * @returns true if normals will be required for the rest of the effect
  68312. */
  68313. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68314. /**
  68315. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68316. * that won t be acctive due to defines being turned off.
  68317. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68318. * @param samplersList The samplers list
  68319. * @param defines The defines helping in the list generation
  68320. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68321. */
  68322. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68323. /**
  68324. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68325. * @param defines The defines to update while falling back
  68326. * @param fallbacks The authorized effect fallbacks
  68327. * @param maxSimultaneousLights The maximum number of lights allowed
  68328. * @param rank the current rank of the Effect
  68329. * @returns The newly affected rank
  68330. */
  68331. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68332. /**
  68333. * Prepares the list of attributes required for morph targets according to the effect defines.
  68334. * @param attribs The current list of supported attribs
  68335. * @param mesh The mesh to prepare the morph targets attributes for
  68336. * @param defines The current Defines of the effect
  68337. */
  68338. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68339. /**
  68340. * Prepares the list of attributes required for bones according to the effect defines.
  68341. * @param attribs The current list of supported attribs
  68342. * @param mesh The mesh to prepare the bones attributes for
  68343. * @param defines The current Defines of the effect
  68344. * @param fallbacks The current efffect fallback strategy
  68345. */
  68346. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68347. /**
  68348. * Prepares the list of attributes required for instances according to the effect defines.
  68349. * @param attribs The current list of supported attribs
  68350. * @param defines The current Defines of the effect
  68351. */
  68352. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68353. /**
  68354. * Binds the light shadow information to the effect for the given mesh.
  68355. * @param light The light containing the generator
  68356. * @param scene The scene the lights belongs to
  68357. * @param mesh The mesh we are binding the information to render
  68358. * @param lightIndex The light index in the effect used to render the mesh
  68359. * @param effect The effect we are binding the data to
  68360. */
  68361. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68362. /**
  68363. * Binds the light information to the effect.
  68364. * @param light The light containing the generator
  68365. * @param effect The effect we are binding the data to
  68366. * @param lightIndex The light index in the effect used to render
  68367. */
  68368. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68369. /**
  68370. * Binds the lights information from the scene to the effect for the given mesh.
  68371. * @param scene The scene the lights belongs to
  68372. * @param mesh The mesh we are binding the information to render
  68373. * @param effect The effect we are binding the data to
  68374. * @param defines The generated defines for the effect
  68375. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68376. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68377. */
  68378. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68379. private static _tempFogColor;
  68380. /**
  68381. * Binds the fog information from the scene to the effect for the given mesh.
  68382. * @param scene The scene the lights belongs to
  68383. * @param mesh The mesh we are binding the information to render
  68384. * @param effect The effect we are binding the data to
  68385. * @param linearSpace Defines if the fog effect is applied in linear space
  68386. */
  68387. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68388. /**
  68389. * Binds the bones information from the mesh to the effect.
  68390. * @param mesh The mesh we are binding the information to render
  68391. * @param effect The effect we are binding the data to
  68392. */
  68393. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68394. /**
  68395. * Binds the morph targets information from the mesh to the effect.
  68396. * @param abstractMesh The mesh we are binding the information to render
  68397. * @param effect The effect we are binding the data to
  68398. */
  68399. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68400. /**
  68401. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68402. * @param defines The generated defines used in the effect
  68403. * @param effect The effect we are binding the data to
  68404. * @param scene The scene we are willing to render with logarithmic scale for
  68405. */
  68406. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68407. /**
  68408. * Binds the clip plane information from the scene to the effect.
  68409. * @param scene The scene the clip plane information are extracted from
  68410. * @param effect The effect we are binding the data to
  68411. */
  68412. static BindClipPlane(effect: Effect, scene: Scene): void;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /** @hidden */
  68417. export var kernelBlurVaryingDeclaration: {
  68418. name: string;
  68419. shader: string;
  68420. };
  68421. }
  68422. declare module BABYLON {
  68423. /** @hidden */
  68424. export var kernelBlurFragment: {
  68425. name: string;
  68426. shader: string;
  68427. };
  68428. }
  68429. declare module BABYLON {
  68430. /** @hidden */
  68431. export var kernelBlurFragment2: {
  68432. name: string;
  68433. shader: string;
  68434. };
  68435. }
  68436. declare module BABYLON {
  68437. /** @hidden */
  68438. export var kernelBlurPixelShader: {
  68439. name: string;
  68440. shader: string;
  68441. };
  68442. }
  68443. declare module BABYLON {
  68444. /** @hidden */
  68445. export var kernelBlurVertex: {
  68446. name: string;
  68447. shader: string;
  68448. };
  68449. }
  68450. declare module BABYLON {
  68451. /** @hidden */
  68452. export var kernelBlurVertexShader: {
  68453. name: string;
  68454. shader: string;
  68455. };
  68456. }
  68457. declare module BABYLON {
  68458. /**
  68459. * The Blur Post Process which blurs an image based on a kernel and direction.
  68460. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68461. */
  68462. export class BlurPostProcess extends PostProcess {
  68463. /** The direction in which to blur the image. */
  68464. direction: Vector2;
  68465. private blockCompilation;
  68466. protected _kernel: number;
  68467. protected _idealKernel: number;
  68468. protected _packedFloat: boolean;
  68469. private _staticDefines;
  68470. /**
  68471. * Sets the length in pixels of the blur sample region
  68472. */
  68473. /**
  68474. * Gets the length in pixels of the blur sample region
  68475. */
  68476. kernel: number;
  68477. /**
  68478. * Sets wether or not the blur needs to unpack/repack floats
  68479. */
  68480. /**
  68481. * Gets wether or not the blur is unpacking/repacking floats
  68482. */
  68483. packedFloat: boolean;
  68484. /**
  68485. * Creates a new instance BlurPostProcess
  68486. * @param name The name of the effect.
  68487. * @param direction The direction in which to blur the image.
  68488. * @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.
  68489. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68490. * @param camera The camera to apply the render pass to.
  68491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68492. * @param engine The engine which the post process will be applied. (default: current engine)
  68493. * @param reusable If the post process can be reused on the same frame. (default: false)
  68494. * @param textureType Type of textures used when performing the post process. (default: 0)
  68495. * @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)
  68496. */
  68497. constructor(name: string,
  68498. /** The direction in which to blur the image. */
  68499. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68500. /**
  68501. * Updates the effect with the current post process compile time values and recompiles the shader.
  68502. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68503. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68504. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68505. * @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
  68506. * @param onCompiled Called when the shader has been compiled.
  68507. * @param onError Called if there is an error when compiling a shader.
  68508. */
  68509. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68510. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68511. /**
  68512. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68513. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68514. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68515. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68516. * The gaps between physical kernels are compensated for in the weighting of the samples
  68517. * @param idealKernel Ideal blur kernel.
  68518. * @return Nearest best kernel.
  68519. */
  68520. protected _nearestBestKernel(idealKernel: number): number;
  68521. /**
  68522. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68523. * @param x The point on the Gaussian distribution to sample.
  68524. * @return the value of the Gaussian function at x.
  68525. */
  68526. protected _gaussianWeight(x: number): number;
  68527. /**
  68528. * Generates a string that can be used as a floating point number in GLSL.
  68529. * @param x Value to print.
  68530. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68531. * @return GLSL float string.
  68532. */
  68533. protected _glslFloat(x: number, decimalFigures?: number): string;
  68534. }
  68535. }
  68536. declare module BABYLON {
  68537. /** @hidden */
  68538. export var shadowMapPixelShader: {
  68539. name: string;
  68540. shader: string;
  68541. };
  68542. }
  68543. declare module BABYLON {
  68544. /** @hidden */
  68545. export var bonesDeclaration: {
  68546. name: string;
  68547. shader: string;
  68548. };
  68549. }
  68550. declare module BABYLON {
  68551. /** @hidden */
  68552. export var morphTargetsVertexGlobalDeclaration: {
  68553. name: string;
  68554. shader: string;
  68555. };
  68556. }
  68557. declare module BABYLON {
  68558. /** @hidden */
  68559. export var morphTargetsVertexDeclaration: {
  68560. name: string;
  68561. shader: string;
  68562. };
  68563. }
  68564. declare module BABYLON {
  68565. /** @hidden */
  68566. export var instancesDeclaration: {
  68567. name: string;
  68568. shader: string;
  68569. };
  68570. }
  68571. declare module BABYLON {
  68572. /** @hidden */
  68573. export var helperFunctions: {
  68574. name: string;
  68575. shader: string;
  68576. };
  68577. }
  68578. declare module BABYLON {
  68579. /** @hidden */
  68580. export var morphTargetsVertex: {
  68581. name: string;
  68582. shader: string;
  68583. };
  68584. }
  68585. declare module BABYLON {
  68586. /** @hidden */
  68587. export var instancesVertex: {
  68588. name: string;
  68589. shader: string;
  68590. };
  68591. }
  68592. declare module BABYLON {
  68593. /** @hidden */
  68594. export var bonesVertex: {
  68595. name: string;
  68596. shader: string;
  68597. };
  68598. }
  68599. declare module BABYLON {
  68600. /** @hidden */
  68601. export var shadowMapVertexShader: {
  68602. name: string;
  68603. shader: string;
  68604. };
  68605. }
  68606. declare module BABYLON {
  68607. /** @hidden */
  68608. export var depthBoxBlurPixelShader: {
  68609. name: string;
  68610. shader: string;
  68611. };
  68612. }
  68613. declare module BABYLON {
  68614. /**
  68615. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68616. */
  68617. export interface ICustomShaderOptions {
  68618. /**
  68619. * Gets or sets the custom shader name to use
  68620. */
  68621. shaderName: string;
  68622. /**
  68623. * The list of attribute names used in the shader
  68624. */
  68625. attributes?: string[];
  68626. /**
  68627. * The list of unifrom names used in the shader
  68628. */
  68629. uniforms?: string[];
  68630. /**
  68631. * The list of sampler names used in the shader
  68632. */
  68633. samplers?: string[];
  68634. /**
  68635. * The list of defines used in the shader
  68636. */
  68637. defines?: string[];
  68638. }
  68639. /**
  68640. * Interface to implement to create a shadow generator compatible with BJS.
  68641. */
  68642. export interface IShadowGenerator {
  68643. /**
  68644. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68645. * @returns The render target texture if present otherwise, null
  68646. */
  68647. getShadowMap(): Nullable<RenderTargetTexture>;
  68648. /**
  68649. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68650. * @returns The render target texture if the shadow map is present otherwise, null
  68651. */
  68652. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68653. /**
  68654. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68655. * @param subMesh The submesh we want to render in the shadow map
  68656. * @param useInstances Defines wether will draw in the map using instances
  68657. * @returns true if ready otherwise, false
  68658. */
  68659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68660. /**
  68661. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68662. * @param defines Defines of the material we want to update
  68663. * @param lightIndex Index of the light in the enabled light list of the material
  68664. */
  68665. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68666. /**
  68667. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68668. * defined in the generator but impacting the effect).
  68669. * It implies the unifroms available on the materials are the standard BJS ones.
  68670. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68671. * @param effect The effect we are binfing the information for
  68672. */
  68673. bindShadowLight(lightIndex: string, effect: Effect): void;
  68674. /**
  68675. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68676. * (eq to shadow prjection matrix * light transform matrix)
  68677. * @returns The transform matrix used to create the shadow map
  68678. */
  68679. getTransformMatrix(): Matrix;
  68680. /**
  68681. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68682. * Cube and 2D textures for instance.
  68683. */
  68684. recreateShadowMap(): void;
  68685. /**
  68686. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68687. * @param onCompiled Callback triggered at the and of the effects compilation
  68688. * @param options Sets of optional options forcing the compilation with different modes
  68689. */
  68690. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68691. useInstances: boolean;
  68692. }>): void;
  68693. /**
  68694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68695. * @param options Sets of optional options forcing the compilation with different modes
  68696. * @returns A promise that resolves when the compilation completes
  68697. */
  68698. forceCompilationAsync(options?: Partial<{
  68699. useInstances: boolean;
  68700. }>): Promise<void>;
  68701. /**
  68702. * Serializes the shadow generator setup to a json object.
  68703. * @returns The serialized JSON object
  68704. */
  68705. serialize(): any;
  68706. /**
  68707. * Disposes the Shadow map and related Textures and effects.
  68708. */
  68709. dispose(): void;
  68710. }
  68711. /**
  68712. * Default implementation IShadowGenerator.
  68713. * This is the main object responsible of generating shadows in the framework.
  68714. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68715. */
  68716. export class ShadowGenerator implements IShadowGenerator {
  68717. /**
  68718. * Shadow generator mode None: no filtering applied.
  68719. */
  68720. static readonly FILTER_NONE: number;
  68721. /**
  68722. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68724. */
  68725. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68726. /**
  68727. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68728. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68729. */
  68730. static readonly FILTER_POISSONSAMPLING: number;
  68731. /**
  68732. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68733. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68734. */
  68735. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68736. /**
  68737. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68738. * edge artifacts on steep falloff.
  68739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68740. */
  68741. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68742. /**
  68743. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68744. * edge artifacts on steep falloff.
  68745. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68746. */
  68747. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68748. /**
  68749. * Shadow generator mode PCF: Percentage Closer Filtering
  68750. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68751. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68752. */
  68753. static readonly FILTER_PCF: number;
  68754. /**
  68755. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68756. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68757. * Contact Hardening
  68758. */
  68759. static readonly FILTER_PCSS: number;
  68760. /**
  68761. * Reserved for PCF and PCSS
  68762. * Highest Quality.
  68763. *
  68764. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68765. *
  68766. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68767. */
  68768. static readonly QUALITY_HIGH: number;
  68769. /**
  68770. * Reserved for PCF and PCSS
  68771. * Good tradeoff for quality/perf cross devices
  68772. *
  68773. * Execute PCF on a 3*3 kernel.
  68774. *
  68775. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68776. */
  68777. static readonly QUALITY_MEDIUM: number;
  68778. /**
  68779. * Reserved for PCF and PCSS
  68780. * The lowest quality but the fastest.
  68781. *
  68782. * Execute PCF on a 1*1 kernel.
  68783. *
  68784. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68785. */
  68786. static readonly QUALITY_LOW: number;
  68787. /** Gets or sets the custom shader name to use */
  68788. customShaderOptions: ICustomShaderOptions;
  68789. /**
  68790. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68791. */
  68792. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68793. /**
  68794. * Observable triggered before a mesh is rendered in the shadow map.
  68795. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68796. */
  68797. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68798. private _bias;
  68799. /**
  68800. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68801. */
  68802. /**
  68803. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68804. */
  68805. bias: number;
  68806. private _normalBias;
  68807. /**
  68808. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68809. */
  68810. /**
  68811. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68812. */
  68813. normalBias: number;
  68814. private _blurBoxOffset;
  68815. /**
  68816. * Gets the blur box offset: offset applied during the blur pass.
  68817. * Only useful if useKernelBlur = false
  68818. */
  68819. /**
  68820. * Sets the blur box offset: offset applied during the blur pass.
  68821. * Only useful if useKernelBlur = false
  68822. */
  68823. blurBoxOffset: number;
  68824. private _blurScale;
  68825. /**
  68826. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68827. * 2 means half of the size.
  68828. */
  68829. /**
  68830. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68831. * 2 means half of the size.
  68832. */
  68833. blurScale: number;
  68834. private _blurKernel;
  68835. /**
  68836. * Gets the blur kernel: kernel size of the blur pass.
  68837. * Only useful if useKernelBlur = true
  68838. */
  68839. /**
  68840. * Sets the blur kernel: kernel size of the blur pass.
  68841. * Only useful if useKernelBlur = true
  68842. */
  68843. blurKernel: number;
  68844. private _useKernelBlur;
  68845. /**
  68846. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68847. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68848. */
  68849. /**
  68850. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68851. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68852. */
  68853. useKernelBlur: boolean;
  68854. private _depthScale;
  68855. /**
  68856. * Gets the depth scale used in ESM mode.
  68857. */
  68858. /**
  68859. * Sets the depth scale used in ESM mode.
  68860. * This can override the scale stored on the light.
  68861. */
  68862. depthScale: number;
  68863. private _filter;
  68864. /**
  68865. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68866. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68867. */
  68868. /**
  68869. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68870. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68871. */
  68872. filter: number;
  68873. /**
  68874. * Gets if the current filter is set to Poisson Sampling.
  68875. */
  68876. /**
  68877. * Sets the current filter to Poisson Sampling.
  68878. */
  68879. usePoissonSampling: boolean;
  68880. /**
  68881. * Gets if the current filter is set to ESM.
  68882. */
  68883. /**
  68884. * Sets the current filter is to ESM.
  68885. */
  68886. useExponentialShadowMap: boolean;
  68887. /**
  68888. * Gets if the current filter is set to filtered ESM.
  68889. */
  68890. /**
  68891. * Gets if the current filter is set to filtered ESM.
  68892. */
  68893. useBlurExponentialShadowMap: boolean;
  68894. /**
  68895. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68896. * exponential to prevent steep falloff artifacts).
  68897. */
  68898. /**
  68899. * Sets the current filter to "close ESM" (using the inverse of the
  68900. * exponential to prevent steep falloff artifacts).
  68901. */
  68902. useCloseExponentialShadowMap: boolean;
  68903. /**
  68904. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68905. * exponential to prevent steep falloff artifacts).
  68906. */
  68907. /**
  68908. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68909. * exponential to prevent steep falloff artifacts).
  68910. */
  68911. useBlurCloseExponentialShadowMap: boolean;
  68912. /**
  68913. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68914. */
  68915. /**
  68916. * Sets the current filter to "PCF" (percentage closer filtering).
  68917. */
  68918. usePercentageCloserFiltering: boolean;
  68919. private _filteringQuality;
  68920. /**
  68921. * Gets the PCF or PCSS Quality.
  68922. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68923. */
  68924. /**
  68925. * Sets the PCF or PCSS Quality.
  68926. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68927. */
  68928. filteringQuality: number;
  68929. /**
  68930. * Gets if the current filter is set to "PCSS" (contact hardening).
  68931. */
  68932. /**
  68933. * Sets the current filter to "PCSS" (contact hardening).
  68934. */
  68935. useContactHardeningShadow: boolean;
  68936. private _contactHardeningLightSizeUVRatio;
  68937. /**
  68938. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68939. * Using a ratio helps keeping shape stability independently of the map size.
  68940. *
  68941. * It does not account for the light projection as it was having too much
  68942. * instability during the light setup or during light position changes.
  68943. *
  68944. * Only valid if useContactHardeningShadow is true.
  68945. */
  68946. /**
  68947. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68948. * Using a ratio helps keeping shape stability independently of the map size.
  68949. *
  68950. * It does not account for the light projection as it was having too much
  68951. * instability during the light setup or during light position changes.
  68952. *
  68953. * Only valid if useContactHardeningShadow is true.
  68954. */
  68955. contactHardeningLightSizeUVRatio: number;
  68956. private _darkness;
  68957. /**
  68958. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68959. * 0 means strongest and 1 would means no shadow.
  68960. * @returns the darkness.
  68961. */
  68962. getDarkness(): number;
  68963. /**
  68964. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68965. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68966. * @returns the shadow generator allowing fluent coding.
  68967. */
  68968. setDarkness(darkness: number): ShadowGenerator;
  68969. private _transparencyShadow;
  68970. /**
  68971. * Sets the ability to have transparent shadow (boolean).
  68972. * @param transparent True if transparent else False
  68973. * @returns the shadow generator allowing fluent coding
  68974. */
  68975. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68976. private _shadowMap;
  68977. private _shadowMap2;
  68978. /**
  68979. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68980. * @returns The render target texture if present otherwise, null
  68981. */
  68982. getShadowMap(): Nullable<RenderTargetTexture>;
  68983. /**
  68984. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68985. * @returns The render target texture if the shadow map is present otherwise, null
  68986. */
  68987. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68988. /**
  68989. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68990. * @param mesh Mesh to add
  68991. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68992. * @returns the Shadow Generator itself
  68993. */
  68994. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68995. /**
  68996. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68997. * @param mesh Mesh to remove
  68998. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68999. * @returns the Shadow Generator itself
  69000. */
  69001. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69002. /**
  69003. * Controls the extent to which the shadows fade out at the edge of the frustum
  69004. * Used only by directionals and spots
  69005. */
  69006. frustumEdgeFalloff: number;
  69007. private _light;
  69008. /**
  69009. * Returns the associated light object.
  69010. * @returns the light generating the shadow
  69011. */
  69012. getLight(): IShadowLight;
  69013. /**
  69014. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69015. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69016. * It might on the other hand introduce peter panning.
  69017. */
  69018. forceBackFacesOnly: boolean;
  69019. private _scene;
  69020. private _lightDirection;
  69021. private _effect;
  69022. private _viewMatrix;
  69023. private _projectionMatrix;
  69024. private _transformMatrix;
  69025. private _cachedPosition;
  69026. private _cachedDirection;
  69027. private _cachedDefines;
  69028. private _currentRenderID;
  69029. private _boxBlurPostprocess;
  69030. private _kernelBlurXPostprocess;
  69031. private _kernelBlurYPostprocess;
  69032. private _blurPostProcesses;
  69033. private _mapSize;
  69034. private _currentFaceIndex;
  69035. private _currentFaceIndexCache;
  69036. private _textureType;
  69037. private _defaultTextureMatrix;
  69038. /** @hidden */
  69039. static _SceneComponentInitialization: (scene: Scene) => void;
  69040. /**
  69041. * Creates a ShadowGenerator object.
  69042. * A ShadowGenerator is the required tool to use the shadows.
  69043. * Each light casting shadows needs to use its own ShadowGenerator.
  69044. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69045. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69046. * @param light The light object generating the shadows.
  69047. * @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.
  69048. */
  69049. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69050. private _initializeGenerator;
  69051. private _initializeShadowMap;
  69052. private _initializeBlurRTTAndPostProcesses;
  69053. private _renderForShadowMap;
  69054. private _renderSubMeshForShadowMap;
  69055. private _applyFilterValues;
  69056. /**
  69057. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69058. * @param onCompiled Callback triggered at the and of the effects compilation
  69059. * @param options Sets of optional options forcing the compilation with different modes
  69060. */
  69061. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69062. useInstances: boolean;
  69063. }>): void;
  69064. /**
  69065. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69066. * @param options Sets of optional options forcing the compilation with different modes
  69067. * @returns A promise that resolves when the compilation completes
  69068. */
  69069. forceCompilationAsync(options?: Partial<{
  69070. useInstances: boolean;
  69071. }>): Promise<void>;
  69072. /**
  69073. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69074. * @param subMesh The submesh we want to render in the shadow map
  69075. * @param useInstances Defines wether will draw in the map using instances
  69076. * @returns true if ready otherwise, false
  69077. */
  69078. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69079. /**
  69080. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69081. * @param defines Defines of the material we want to update
  69082. * @param lightIndex Index of the light in the enabled light list of the material
  69083. */
  69084. prepareDefines(defines: any, lightIndex: number): void;
  69085. /**
  69086. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69087. * defined in the generator but impacting the effect).
  69088. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69089. * @param effect The effect we are binfing the information for
  69090. */
  69091. bindShadowLight(lightIndex: string, effect: Effect): void;
  69092. /**
  69093. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69094. * (eq to shadow prjection matrix * light transform matrix)
  69095. * @returns The transform matrix used to create the shadow map
  69096. */
  69097. getTransformMatrix(): Matrix;
  69098. /**
  69099. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69100. * Cube and 2D textures for instance.
  69101. */
  69102. recreateShadowMap(): void;
  69103. private _disposeBlurPostProcesses;
  69104. private _disposeRTTandPostProcesses;
  69105. /**
  69106. * Disposes the ShadowGenerator.
  69107. * Returns nothing.
  69108. */
  69109. dispose(): void;
  69110. /**
  69111. * Serializes the shadow generator setup to a json object.
  69112. * @returns The serialized JSON object
  69113. */
  69114. serialize(): any;
  69115. /**
  69116. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69117. * @param parsedShadowGenerator The JSON object to parse
  69118. * @param scene The scene to create the shadow map for
  69119. * @returns The parsed shadow generator
  69120. */
  69121. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69122. }
  69123. }
  69124. declare module BABYLON {
  69125. /**
  69126. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69127. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69128. * 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.
  69129. */
  69130. export abstract class Light extends Node {
  69131. /**
  69132. * Falloff Default: light is falling off following the material specification:
  69133. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69134. */
  69135. static readonly FALLOFF_DEFAULT: number;
  69136. /**
  69137. * Falloff Physical: light is falling off following the inverse squared distance law.
  69138. */
  69139. static readonly FALLOFF_PHYSICAL: number;
  69140. /**
  69141. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69142. * to enhance interoperability with other engines.
  69143. */
  69144. static readonly FALLOFF_GLTF: number;
  69145. /**
  69146. * Falloff Standard: light is falling off like in the standard material
  69147. * to enhance interoperability with other materials.
  69148. */
  69149. static readonly FALLOFF_STANDARD: number;
  69150. /**
  69151. * If every light affecting the material is in this lightmapMode,
  69152. * material.lightmapTexture adds or multiplies
  69153. * (depends on material.useLightmapAsShadowmap)
  69154. * after every other light calculations.
  69155. */
  69156. static readonly LIGHTMAP_DEFAULT: number;
  69157. /**
  69158. * material.lightmapTexture as only diffuse lighting from this light
  69159. * adds only specular lighting from this light
  69160. * adds dynamic shadows
  69161. */
  69162. static readonly LIGHTMAP_SPECULAR: number;
  69163. /**
  69164. * material.lightmapTexture as only lighting
  69165. * no light calculation from this light
  69166. * only adds dynamic shadows from this light
  69167. */
  69168. static readonly LIGHTMAP_SHADOWSONLY: number;
  69169. /**
  69170. * Each light type uses the default quantity according to its type:
  69171. * point/spot lights use luminous intensity
  69172. * directional lights use illuminance
  69173. */
  69174. static readonly INTENSITYMODE_AUTOMATIC: number;
  69175. /**
  69176. * lumen (lm)
  69177. */
  69178. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69179. /**
  69180. * candela (lm/sr)
  69181. */
  69182. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69183. /**
  69184. * lux (lm/m^2)
  69185. */
  69186. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69187. /**
  69188. * nit (cd/m^2)
  69189. */
  69190. static readonly INTENSITYMODE_LUMINANCE: number;
  69191. /**
  69192. * Light type const id of the point light.
  69193. */
  69194. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69195. /**
  69196. * Light type const id of the directional light.
  69197. */
  69198. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69199. /**
  69200. * Light type const id of the spot light.
  69201. */
  69202. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69203. /**
  69204. * Light type const id of the hemispheric light.
  69205. */
  69206. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69207. /**
  69208. * Diffuse gives the basic color to an object.
  69209. */
  69210. diffuse: Color3;
  69211. /**
  69212. * Specular produces a highlight color on an object.
  69213. * Note: This is note affecting PBR materials.
  69214. */
  69215. specular: Color3;
  69216. /**
  69217. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69218. * falling off base on range or angle.
  69219. * This can be set to any values in Light.FALLOFF_x.
  69220. *
  69221. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69222. * other types of materials.
  69223. */
  69224. falloffType: number;
  69225. /**
  69226. * Strength of the light.
  69227. * Note: By default it is define in the framework own unit.
  69228. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69229. */
  69230. intensity: number;
  69231. private _range;
  69232. protected _inverseSquaredRange: number;
  69233. /**
  69234. * Defines how far from the source the light is impacting in scene units.
  69235. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69236. */
  69237. /**
  69238. * Defines how far from the source the light is impacting in scene units.
  69239. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69240. */
  69241. range: number;
  69242. /**
  69243. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69244. * of light.
  69245. */
  69246. private _photometricScale;
  69247. private _intensityMode;
  69248. /**
  69249. * Gets the photometric scale used to interpret the intensity.
  69250. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69251. */
  69252. /**
  69253. * Sets the photometric scale used to interpret the intensity.
  69254. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69255. */
  69256. intensityMode: number;
  69257. private _radius;
  69258. /**
  69259. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69260. */
  69261. /**
  69262. * sets the light radius used by PBR Materials to simulate soft area lights.
  69263. */
  69264. radius: number;
  69265. private _renderPriority;
  69266. /**
  69267. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69268. * exceeding the number allowed of the materials.
  69269. */
  69270. renderPriority: number;
  69271. private _shadowEnabled;
  69272. /**
  69273. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69274. * the current shadow generator.
  69275. */
  69276. /**
  69277. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69278. * the current shadow generator.
  69279. */
  69280. shadowEnabled: boolean;
  69281. private _includedOnlyMeshes;
  69282. /**
  69283. * Gets the only meshes impacted by this light.
  69284. */
  69285. /**
  69286. * Sets the only meshes impacted by this light.
  69287. */
  69288. includedOnlyMeshes: AbstractMesh[];
  69289. private _excludedMeshes;
  69290. /**
  69291. * Gets the meshes not impacted by this light.
  69292. */
  69293. /**
  69294. * Sets the meshes not impacted by this light.
  69295. */
  69296. excludedMeshes: AbstractMesh[];
  69297. private _excludeWithLayerMask;
  69298. /**
  69299. * Gets the layer id use to find what meshes are not impacted by the light.
  69300. * Inactive if 0
  69301. */
  69302. /**
  69303. * Sets the layer id use to find what meshes are not impacted by the light.
  69304. * Inactive if 0
  69305. */
  69306. excludeWithLayerMask: number;
  69307. private _includeOnlyWithLayerMask;
  69308. /**
  69309. * Gets the layer id use to find what meshes are impacted by the light.
  69310. * Inactive if 0
  69311. */
  69312. /**
  69313. * Sets the layer id use to find what meshes are impacted by the light.
  69314. * Inactive if 0
  69315. */
  69316. includeOnlyWithLayerMask: number;
  69317. private _lightmapMode;
  69318. /**
  69319. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69320. */
  69321. /**
  69322. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69323. */
  69324. lightmapMode: number;
  69325. /**
  69326. * Shadow generator associted to the light.
  69327. * @hidden Internal use only.
  69328. */
  69329. _shadowGenerator: Nullable<IShadowGenerator>;
  69330. /**
  69331. * @hidden Internal use only.
  69332. */
  69333. _excludedMeshesIds: string[];
  69334. /**
  69335. * @hidden Internal use only.
  69336. */
  69337. _includedOnlyMeshesIds: string[];
  69338. /**
  69339. * The current light unifom buffer.
  69340. * @hidden Internal use only.
  69341. */
  69342. _uniformBuffer: UniformBuffer;
  69343. /**
  69344. * Creates a Light object in the scene.
  69345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69346. * @param name The firendly name of the light
  69347. * @param scene The scene the light belongs too
  69348. */
  69349. constructor(name: string, scene: Scene);
  69350. protected abstract _buildUniformLayout(): void;
  69351. /**
  69352. * Sets the passed Effect "effect" with the Light information.
  69353. * @param effect The effect to update
  69354. * @param lightIndex The index of the light in the effect to update
  69355. * @returns The light
  69356. */
  69357. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69358. /**
  69359. * Returns the string "Light".
  69360. * @returns the class name
  69361. */
  69362. getClassName(): string;
  69363. /** @hidden */
  69364. readonly _isLight: boolean;
  69365. /**
  69366. * Converts the light information to a readable string for debug purpose.
  69367. * @param fullDetails Supports for multiple levels of logging within scene loading
  69368. * @returns the human readable light info
  69369. */
  69370. toString(fullDetails?: boolean): string;
  69371. /** @hidden */
  69372. protected _syncParentEnabledState(): void;
  69373. /**
  69374. * Set the enabled state of this node.
  69375. * @param value - the new enabled state
  69376. */
  69377. setEnabled(value: boolean): void;
  69378. /**
  69379. * Returns the Light associated shadow generator if any.
  69380. * @return the associated shadow generator.
  69381. */
  69382. getShadowGenerator(): Nullable<IShadowGenerator>;
  69383. /**
  69384. * Returns a Vector3, the absolute light position in the World.
  69385. * @returns the world space position of the light
  69386. */
  69387. getAbsolutePosition(): Vector3;
  69388. /**
  69389. * Specifies if the light will affect the passed mesh.
  69390. * @param mesh The mesh to test against the light
  69391. * @return true the mesh is affected otherwise, false.
  69392. */
  69393. canAffectMesh(mesh: AbstractMesh): boolean;
  69394. /**
  69395. * Sort function to order lights for rendering.
  69396. * @param a First Light object to compare to second.
  69397. * @param b Second Light object to compare first.
  69398. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69399. */
  69400. static CompareLightsPriority(a: Light, b: Light): number;
  69401. /**
  69402. * Releases resources associated with this node.
  69403. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69404. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69405. */
  69406. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69407. /**
  69408. * Returns the light type ID (integer).
  69409. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69410. */
  69411. getTypeID(): number;
  69412. /**
  69413. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69414. * @returns the scaled intensity in intensity mode unit
  69415. */
  69416. getScaledIntensity(): number;
  69417. /**
  69418. * Returns a new Light object, named "name", from the current one.
  69419. * @param name The name of the cloned light
  69420. * @returns the new created light
  69421. */
  69422. clone(name: string): Nullable<Light>;
  69423. /**
  69424. * Serializes the current light into a Serialization object.
  69425. * @returns the serialized object.
  69426. */
  69427. serialize(): any;
  69428. /**
  69429. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69430. * This new light is named "name" and added to the passed scene.
  69431. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69432. * @param name The friendly name of the light
  69433. * @param scene The scene the new light will belong to
  69434. * @returns the constructor function
  69435. */
  69436. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69437. /**
  69438. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69439. * @param parsedLight The JSON representation of the light
  69440. * @param scene The scene to create the parsed light in
  69441. * @returns the created light after parsing
  69442. */
  69443. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69444. private _hookArrayForExcluded;
  69445. private _hookArrayForIncludedOnly;
  69446. private _resyncMeshes;
  69447. /**
  69448. * Forces the meshes to update their light related information in their rendering used effects
  69449. * @hidden Internal Use Only
  69450. */
  69451. _markMeshesAsLightDirty(): void;
  69452. /**
  69453. * Recomputes the cached photometric scale if needed.
  69454. */
  69455. private _computePhotometricScale;
  69456. /**
  69457. * Returns the Photometric Scale according to the light type and intensity mode.
  69458. */
  69459. private _getPhotometricScale;
  69460. /**
  69461. * Reorder the light in the scene according to their defined priority.
  69462. * @hidden Internal Use Only
  69463. */
  69464. _reorderLightsInScene(): void;
  69465. /**
  69466. * Prepares the list of defines specific to the light type.
  69467. * @param defines the list of defines
  69468. * @param lightIndex defines the index of the light for the effect
  69469. */
  69470. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. /**
  69475. * Interface used to define Action
  69476. */
  69477. export interface IAction {
  69478. /**
  69479. * Trigger for the action
  69480. */
  69481. trigger: number;
  69482. /** Options of the trigger */
  69483. triggerOptions: any;
  69484. /**
  69485. * Gets the trigger parameters
  69486. * @returns the trigger parameters
  69487. */
  69488. getTriggerParameter(): any;
  69489. /**
  69490. * Internal only - executes current action event
  69491. * @hidden
  69492. */
  69493. _executeCurrent(evt?: ActionEvent): void;
  69494. /**
  69495. * Serialize placeholder for child classes
  69496. * @param parent of child
  69497. * @returns the serialized object
  69498. */
  69499. serialize(parent: any): any;
  69500. /**
  69501. * Internal only
  69502. * @hidden
  69503. */
  69504. _prepare(): void;
  69505. /**
  69506. * Internal only - manager for action
  69507. * @hidden
  69508. */
  69509. _actionManager: AbstractActionManager;
  69510. }
  69511. /**
  69512. * The action to be carried out following a trigger
  69513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69514. */
  69515. export class Action implements IAction {
  69516. /** the trigger, with or without parameters, for the action */
  69517. triggerOptions: any;
  69518. /**
  69519. * Trigger for the action
  69520. */
  69521. trigger: number;
  69522. /**
  69523. * Internal only - manager for action
  69524. * @hidden
  69525. */
  69526. _actionManager: ActionManager;
  69527. private _nextActiveAction;
  69528. private _child;
  69529. private _condition?;
  69530. private _triggerParameter;
  69531. /**
  69532. * An event triggered prior to action being executed.
  69533. */
  69534. onBeforeExecuteObservable: Observable<Action>;
  69535. /**
  69536. * Creates a new Action
  69537. * @param triggerOptions the trigger, with or without parameters, for the action
  69538. * @param condition an optional determinant of action
  69539. */
  69540. constructor(
  69541. /** the trigger, with or without parameters, for the action */
  69542. triggerOptions: any, condition?: Condition);
  69543. /**
  69544. * Internal only
  69545. * @hidden
  69546. */
  69547. _prepare(): void;
  69548. /**
  69549. * Gets the trigger parameters
  69550. * @returns the trigger parameters
  69551. */
  69552. getTriggerParameter(): any;
  69553. /**
  69554. * Internal only - executes current action event
  69555. * @hidden
  69556. */
  69557. _executeCurrent(evt?: ActionEvent): void;
  69558. /**
  69559. * Execute placeholder for child classes
  69560. * @param evt optional action event
  69561. */
  69562. execute(evt?: ActionEvent): void;
  69563. /**
  69564. * Skips to next active action
  69565. */
  69566. skipToNextActiveAction(): void;
  69567. /**
  69568. * Adds action to chain of actions, may be a DoNothingAction
  69569. * @param action defines the next action to execute
  69570. * @returns The action passed in
  69571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69572. */
  69573. then(action: Action): Action;
  69574. /**
  69575. * Internal only
  69576. * @hidden
  69577. */
  69578. _getProperty(propertyPath: string): string;
  69579. /**
  69580. * Internal only
  69581. * @hidden
  69582. */
  69583. _getEffectiveTarget(target: any, propertyPath: string): any;
  69584. /**
  69585. * Serialize placeholder for child classes
  69586. * @param parent of child
  69587. * @returns the serialized object
  69588. */
  69589. serialize(parent: any): any;
  69590. /**
  69591. * Internal only called by serialize
  69592. * @hidden
  69593. */
  69594. protected _serialize(serializedAction: any, parent?: any): any;
  69595. /**
  69596. * Internal only
  69597. * @hidden
  69598. */
  69599. static _SerializeValueAsString: (value: any) => string;
  69600. /**
  69601. * Internal only
  69602. * @hidden
  69603. */
  69604. static _GetTargetProperty: (target: Scene | Node) => {
  69605. name: string;
  69606. targetType: string;
  69607. value: string;
  69608. };
  69609. }
  69610. }
  69611. declare module BABYLON {
  69612. /**
  69613. * A Condition applied to an Action
  69614. */
  69615. export class Condition {
  69616. /**
  69617. * Internal only - manager for action
  69618. * @hidden
  69619. */
  69620. _actionManager: ActionManager;
  69621. /**
  69622. * Internal only
  69623. * @hidden
  69624. */
  69625. _evaluationId: number;
  69626. /**
  69627. * Internal only
  69628. * @hidden
  69629. */
  69630. _currentResult: boolean;
  69631. /**
  69632. * Creates a new Condition
  69633. * @param actionManager the manager of the action the condition is applied to
  69634. */
  69635. constructor(actionManager: ActionManager);
  69636. /**
  69637. * Check if the current condition is valid
  69638. * @returns a boolean
  69639. */
  69640. isValid(): boolean;
  69641. /**
  69642. * Internal only
  69643. * @hidden
  69644. */
  69645. _getProperty(propertyPath: string): string;
  69646. /**
  69647. * Internal only
  69648. * @hidden
  69649. */
  69650. _getEffectiveTarget(target: any, propertyPath: string): any;
  69651. /**
  69652. * Serialize placeholder for child classes
  69653. * @returns the serialized object
  69654. */
  69655. serialize(): any;
  69656. /**
  69657. * Internal only
  69658. * @hidden
  69659. */
  69660. protected _serialize(serializedCondition: any): any;
  69661. }
  69662. /**
  69663. * Defines specific conditional operators as extensions of Condition
  69664. */
  69665. export class ValueCondition extends Condition {
  69666. /** path to specify the property of the target the conditional operator uses */
  69667. propertyPath: string;
  69668. /** the value compared by the conditional operator against the current value of the property */
  69669. value: any;
  69670. /** the conditional operator, default ValueCondition.IsEqual */
  69671. operator: number;
  69672. /**
  69673. * Internal only
  69674. * @hidden
  69675. */
  69676. private static _IsEqual;
  69677. /**
  69678. * Internal only
  69679. * @hidden
  69680. */
  69681. private static _IsDifferent;
  69682. /**
  69683. * Internal only
  69684. * @hidden
  69685. */
  69686. private static _IsGreater;
  69687. /**
  69688. * Internal only
  69689. * @hidden
  69690. */
  69691. private static _IsLesser;
  69692. /**
  69693. * returns the number for IsEqual
  69694. */
  69695. static readonly IsEqual: number;
  69696. /**
  69697. * Returns the number for IsDifferent
  69698. */
  69699. static readonly IsDifferent: number;
  69700. /**
  69701. * Returns the number for IsGreater
  69702. */
  69703. static readonly IsGreater: number;
  69704. /**
  69705. * Returns the number for IsLesser
  69706. */
  69707. static readonly IsLesser: number;
  69708. /**
  69709. * Internal only The action manager for the condition
  69710. * @hidden
  69711. */
  69712. _actionManager: ActionManager;
  69713. /**
  69714. * Internal only
  69715. * @hidden
  69716. */
  69717. private _target;
  69718. /**
  69719. * Internal only
  69720. * @hidden
  69721. */
  69722. private _effectiveTarget;
  69723. /**
  69724. * Internal only
  69725. * @hidden
  69726. */
  69727. private _property;
  69728. /**
  69729. * Creates a new ValueCondition
  69730. * @param actionManager manager for the action the condition applies to
  69731. * @param target for the action
  69732. * @param propertyPath path to specify the property of the target the conditional operator uses
  69733. * @param value the value compared by the conditional operator against the current value of the property
  69734. * @param operator the conditional operator, default ValueCondition.IsEqual
  69735. */
  69736. constructor(actionManager: ActionManager, target: any,
  69737. /** path to specify the property of the target the conditional operator uses */
  69738. propertyPath: string,
  69739. /** the value compared by the conditional operator against the current value of the property */
  69740. value: any,
  69741. /** the conditional operator, default ValueCondition.IsEqual */
  69742. operator?: number);
  69743. /**
  69744. * Compares the given value with the property value for the specified conditional operator
  69745. * @returns the result of the comparison
  69746. */
  69747. isValid(): boolean;
  69748. /**
  69749. * Serialize the ValueCondition into a JSON compatible object
  69750. * @returns serialization object
  69751. */
  69752. serialize(): any;
  69753. /**
  69754. * Gets the name of the conditional operator for the ValueCondition
  69755. * @param operator the conditional operator
  69756. * @returns the name
  69757. */
  69758. static GetOperatorName(operator: number): string;
  69759. }
  69760. /**
  69761. * Defines a predicate condition as an extension of Condition
  69762. */
  69763. export class PredicateCondition extends Condition {
  69764. /** defines the predicate function used to validate the condition */
  69765. predicate: () => boolean;
  69766. /**
  69767. * Internal only - manager for action
  69768. * @hidden
  69769. */
  69770. _actionManager: ActionManager;
  69771. /**
  69772. * Creates a new PredicateCondition
  69773. * @param actionManager manager for the action the condition applies to
  69774. * @param predicate defines the predicate function used to validate the condition
  69775. */
  69776. constructor(actionManager: ActionManager,
  69777. /** defines the predicate function used to validate the condition */
  69778. predicate: () => boolean);
  69779. /**
  69780. * @returns the validity of the predicate condition
  69781. */
  69782. isValid(): boolean;
  69783. }
  69784. /**
  69785. * Defines a state condition as an extension of Condition
  69786. */
  69787. export class StateCondition extends Condition {
  69788. /** Value to compare with target state */
  69789. value: string;
  69790. /**
  69791. * Internal only - manager for action
  69792. * @hidden
  69793. */
  69794. _actionManager: ActionManager;
  69795. /**
  69796. * Internal only
  69797. * @hidden
  69798. */
  69799. private _target;
  69800. /**
  69801. * Creates a new StateCondition
  69802. * @param actionManager manager for the action the condition applies to
  69803. * @param target of the condition
  69804. * @param value to compare with target state
  69805. */
  69806. constructor(actionManager: ActionManager, target: any,
  69807. /** Value to compare with target state */
  69808. value: string);
  69809. /**
  69810. * Gets a boolean indicating if the current condition is met
  69811. * @returns the validity of the state
  69812. */
  69813. isValid(): boolean;
  69814. /**
  69815. * Serialize the StateCondition into a JSON compatible object
  69816. * @returns serialization object
  69817. */
  69818. serialize(): any;
  69819. }
  69820. }
  69821. declare module BABYLON {
  69822. /**
  69823. * This defines an action responsible to toggle a boolean once triggered.
  69824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69825. */
  69826. export class SwitchBooleanAction extends Action {
  69827. /**
  69828. * The path to the boolean property in the target object
  69829. */
  69830. propertyPath: string;
  69831. private _target;
  69832. private _effectiveTarget;
  69833. private _property;
  69834. /**
  69835. * Instantiate the action
  69836. * @param triggerOptions defines the trigger options
  69837. * @param target defines the object containing the boolean
  69838. * @param propertyPath defines the path to the boolean property in the target object
  69839. * @param condition defines the trigger related conditions
  69840. */
  69841. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69842. /** @hidden */
  69843. _prepare(): void;
  69844. /**
  69845. * Execute the action toggle the boolean value.
  69846. */
  69847. execute(): void;
  69848. /**
  69849. * Serializes the actions and its related information.
  69850. * @param parent defines the object to serialize in
  69851. * @returns the serialized object
  69852. */
  69853. serialize(parent: any): any;
  69854. }
  69855. /**
  69856. * This defines an action responsible to set a the state field of the target
  69857. * to a desired value once triggered.
  69858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69859. */
  69860. export class SetStateAction extends Action {
  69861. /**
  69862. * The value to store in the state field.
  69863. */
  69864. value: string;
  69865. private _target;
  69866. /**
  69867. * Instantiate the action
  69868. * @param triggerOptions defines the trigger options
  69869. * @param target defines the object containing the state property
  69870. * @param value defines the value to store in the state field
  69871. * @param condition defines the trigger related conditions
  69872. */
  69873. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69874. /**
  69875. * Execute the action and store the value on the target state property.
  69876. */
  69877. execute(): void;
  69878. /**
  69879. * Serializes the actions and its related information.
  69880. * @param parent defines the object to serialize in
  69881. * @returns the serialized object
  69882. */
  69883. serialize(parent: any): any;
  69884. }
  69885. /**
  69886. * This defines an action responsible to set a property of the target
  69887. * to a desired value once triggered.
  69888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69889. */
  69890. export class SetValueAction extends Action {
  69891. /**
  69892. * The path of the property to set in the target.
  69893. */
  69894. propertyPath: string;
  69895. /**
  69896. * The value to set in the property
  69897. */
  69898. value: any;
  69899. private _target;
  69900. private _effectiveTarget;
  69901. private _property;
  69902. /**
  69903. * Instantiate the action
  69904. * @param triggerOptions defines the trigger options
  69905. * @param target defines the object containing the property
  69906. * @param propertyPath defines the path of the property to set in the target
  69907. * @param value defines the value to set in the property
  69908. * @param condition defines the trigger related conditions
  69909. */
  69910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69911. /** @hidden */
  69912. _prepare(): void;
  69913. /**
  69914. * Execute the action and set the targetted property to the desired value.
  69915. */
  69916. execute(): void;
  69917. /**
  69918. * Serializes the actions and its related information.
  69919. * @param parent defines the object to serialize in
  69920. * @returns the serialized object
  69921. */
  69922. serialize(parent: any): any;
  69923. }
  69924. /**
  69925. * This defines an action responsible to increment the target value
  69926. * to a desired value once triggered.
  69927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69928. */
  69929. export class IncrementValueAction extends Action {
  69930. /**
  69931. * The path of the property to increment in the target.
  69932. */
  69933. propertyPath: string;
  69934. /**
  69935. * The value we should increment the property by.
  69936. */
  69937. value: any;
  69938. private _target;
  69939. private _effectiveTarget;
  69940. private _property;
  69941. /**
  69942. * Instantiate the action
  69943. * @param triggerOptions defines the trigger options
  69944. * @param target defines the object containing the property
  69945. * @param propertyPath defines the path of the property to increment in the target
  69946. * @param value defines the value value we should increment the property by
  69947. * @param condition defines the trigger related conditions
  69948. */
  69949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69950. /** @hidden */
  69951. _prepare(): void;
  69952. /**
  69953. * Execute the action and increment the target of the value amount.
  69954. */
  69955. execute(): void;
  69956. /**
  69957. * Serializes the actions and its related information.
  69958. * @param parent defines the object to serialize in
  69959. * @returns the serialized object
  69960. */
  69961. serialize(parent: any): any;
  69962. }
  69963. /**
  69964. * This defines an action responsible to start an animation once triggered.
  69965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69966. */
  69967. export class PlayAnimationAction extends Action {
  69968. /**
  69969. * Where the animation should start (animation frame)
  69970. */
  69971. from: number;
  69972. /**
  69973. * Where the animation should stop (animation frame)
  69974. */
  69975. to: number;
  69976. /**
  69977. * Define if the animation should loop or stop after the first play.
  69978. */
  69979. loop?: boolean;
  69980. private _target;
  69981. /**
  69982. * Instantiate the action
  69983. * @param triggerOptions defines the trigger options
  69984. * @param target defines the target animation or animation name
  69985. * @param from defines from where the animation should start (animation frame)
  69986. * @param end defines where the animation should stop (animation frame)
  69987. * @param loop defines if the animation should loop or stop after the first play
  69988. * @param condition defines the trigger related conditions
  69989. */
  69990. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69991. /** @hidden */
  69992. _prepare(): void;
  69993. /**
  69994. * Execute the action and play the animation.
  69995. */
  69996. execute(): void;
  69997. /**
  69998. * Serializes the actions and its related information.
  69999. * @param parent defines the object to serialize in
  70000. * @returns the serialized object
  70001. */
  70002. serialize(parent: any): any;
  70003. }
  70004. /**
  70005. * This defines an action responsible to stop an animation once triggered.
  70006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70007. */
  70008. export class StopAnimationAction extends Action {
  70009. private _target;
  70010. /**
  70011. * Instantiate the action
  70012. * @param triggerOptions defines the trigger options
  70013. * @param target defines the target animation or animation name
  70014. * @param condition defines the trigger related conditions
  70015. */
  70016. constructor(triggerOptions: any, target: any, condition?: Condition);
  70017. /** @hidden */
  70018. _prepare(): void;
  70019. /**
  70020. * Execute the action and stop the animation.
  70021. */
  70022. execute(): void;
  70023. /**
  70024. * Serializes the actions and its related information.
  70025. * @param parent defines the object to serialize in
  70026. * @returns the serialized object
  70027. */
  70028. serialize(parent: any): any;
  70029. }
  70030. /**
  70031. * This defines an action responsible that does nothing once triggered.
  70032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70033. */
  70034. export class DoNothingAction extends Action {
  70035. /**
  70036. * Instantiate the action
  70037. * @param triggerOptions defines the trigger options
  70038. * @param condition defines the trigger related conditions
  70039. */
  70040. constructor(triggerOptions?: any, condition?: Condition);
  70041. /**
  70042. * Execute the action and do nothing.
  70043. */
  70044. execute(): void;
  70045. /**
  70046. * Serializes the actions and its related information.
  70047. * @param parent defines the object to serialize in
  70048. * @returns the serialized object
  70049. */
  70050. serialize(parent: any): any;
  70051. }
  70052. /**
  70053. * This defines an action responsible to trigger several actions once triggered.
  70054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70055. */
  70056. export class CombineAction extends Action {
  70057. /**
  70058. * The list of aggregated animations to run.
  70059. */
  70060. children: Action[];
  70061. /**
  70062. * Instantiate the action
  70063. * @param triggerOptions defines the trigger options
  70064. * @param children defines the list of aggregated animations to run
  70065. * @param condition defines the trigger related conditions
  70066. */
  70067. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70068. /** @hidden */
  70069. _prepare(): void;
  70070. /**
  70071. * Execute the action and executes all the aggregated actions.
  70072. */
  70073. execute(evt: ActionEvent): void;
  70074. /**
  70075. * Serializes the actions and its related information.
  70076. * @param parent defines the object to serialize in
  70077. * @returns the serialized object
  70078. */
  70079. serialize(parent: any): any;
  70080. }
  70081. /**
  70082. * This defines an action responsible to run code (external event) once triggered.
  70083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70084. */
  70085. export class ExecuteCodeAction extends Action {
  70086. /**
  70087. * The callback function to run.
  70088. */
  70089. func: (evt: ActionEvent) => void;
  70090. /**
  70091. * Instantiate the action
  70092. * @param triggerOptions defines the trigger options
  70093. * @param func defines the callback function to run
  70094. * @param condition defines the trigger related conditions
  70095. */
  70096. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70097. /**
  70098. * Execute the action and run the attached code.
  70099. */
  70100. execute(evt: ActionEvent): void;
  70101. }
  70102. /**
  70103. * This defines an action responsible to set the parent property of the target once triggered.
  70104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70105. */
  70106. export class SetParentAction extends Action {
  70107. private _parent;
  70108. private _target;
  70109. /**
  70110. * Instantiate the action
  70111. * @param triggerOptions defines the trigger options
  70112. * @param target defines the target containing the parent property
  70113. * @param parent defines from where the animation should start (animation frame)
  70114. * @param condition defines the trigger related conditions
  70115. */
  70116. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70117. /** @hidden */
  70118. _prepare(): void;
  70119. /**
  70120. * Execute the action and set the parent property.
  70121. */
  70122. execute(): void;
  70123. /**
  70124. * Serializes the actions and its related information.
  70125. * @param parent defines the object to serialize in
  70126. * @returns the serialized object
  70127. */
  70128. serialize(parent: any): any;
  70129. }
  70130. }
  70131. declare module BABYLON {
  70132. /**
  70133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70136. */
  70137. export class ActionManager extends AbstractActionManager {
  70138. /**
  70139. * Nothing
  70140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70141. */
  70142. static readonly NothingTrigger: number;
  70143. /**
  70144. * On pick
  70145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70146. */
  70147. static readonly OnPickTrigger: number;
  70148. /**
  70149. * On left pick
  70150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70151. */
  70152. static readonly OnLeftPickTrigger: number;
  70153. /**
  70154. * On right pick
  70155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70156. */
  70157. static readonly OnRightPickTrigger: number;
  70158. /**
  70159. * On center pick
  70160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70161. */
  70162. static readonly OnCenterPickTrigger: number;
  70163. /**
  70164. * On pick down
  70165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70166. */
  70167. static readonly OnPickDownTrigger: number;
  70168. /**
  70169. * On double pick
  70170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70171. */
  70172. static readonly OnDoublePickTrigger: number;
  70173. /**
  70174. * On pick up
  70175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70176. */
  70177. static readonly OnPickUpTrigger: number;
  70178. /**
  70179. * On pick out.
  70180. * This trigger will only be raised if you also declared a OnPickDown
  70181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70182. */
  70183. static readonly OnPickOutTrigger: number;
  70184. /**
  70185. * On long press
  70186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70187. */
  70188. static readonly OnLongPressTrigger: number;
  70189. /**
  70190. * On pointer over
  70191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70192. */
  70193. static readonly OnPointerOverTrigger: number;
  70194. /**
  70195. * On pointer out
  70196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70197. */
  70198. static readonly OnPointerOutTrigger: number;
  70199. /**
  70200. * On every frame
  70201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70202. */
  70203. static readonly OnEveryFrameTrigger: number;
  70204. /**
  70205. * On intersection enter
  70206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70207. */
  70208. static readonly OnIntersectionEnterTrigger: number;
  70209. /**
  70210. * On intersection exit
  70211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70212. */
  70213. static readonly OnIntersectionExitTrigger: number;
  70214. /**
  70215. * On key down
  70216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70217. */
  70218. static readonly OnKeyDownTrigger: number;
  70219. /**
  70220. * On key up
  70221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70222. */
  70223. static readonly OnKeyUpTrigger: number;
  70224. private _scene;
  70225. /**
  70226. * Creates a new action manager
  70227. * @param scene defines the hosting scene
  70228. */
  70229. constructor(scene: Scene);
  70230. /**
  70231. * Releases all associated resources
  70232. */
  70233. dispose(): void;
  70234. /**
  70235. * Gets hosting scene
  70236. * @returns the hosting scene
  70237. */
  70238. getScene(): Scene;
  70239. /**
  70240. * Does this action manager handles actions of any of the given triggers
  70241. * @param triggers defines the triggers to be tested
  70242. * @return a boolean indicating whether one (or more) of the triggers is handled
  70243. */
  70244. hasSpecificTriggers(triggers: number[]): boolean;
  70245. /**
  70246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70247. * speed.
  70248. * @param triggerA defines the trigger to be tested
  70249. * @param triggerB defines the trigger to be tested
  70250. * @return a boolean indicating whether one (or more) of the triggers is handled
  70251. */
  70252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70253. /**
  70254. * Does this action manager handles actions of a given trigger
  70255. * @param trigger defines the trigger to be tested
  70256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70257. * @return whether the trigger is handled
  70258. */
  70259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70260. /**
  70261. * Does this action manager has pointer triggers
  70262. */
  70263. readonly hasPointerTriggers: boolean;
  70264. /**
  70265. * Does this action manager has pick triggers
  70266. */
  70267. readonly hasPickTriggers: boolean;
  70268. /**
  70269. * Registers an action to this action manager
  70270. * @param action defines the action to be registered
  70271. * @return the action amended (prepared) after registration
  70272. */
  70273. registerAction(action: IAction): Nullable<IAction>;
  70274. /**
  70275. * Unregisters an action to this action manager
  70276. * @param action defines the action to be unregistered
  70277. * @return a boolean indicating whether the action has been unregistered
  70278. */
  70279. unregisterAction(action: IAction): Boolean;
  70280. /**
  70281. * Process a specific trigger
  70282. * @param trigger defines the trigger to process
  70283. * @param evt defines the event details to be processed
  70284. */
  70285. processTrigger(trigger: number, evt?: IActionEvent): void;
  70286. /** @hidden */
  70287. _getEffectiveTarget(target: any, propertyPath: string): any;
  70288. /** @hidden */
  70289. _getProperty(propertyPath: string): string;
  70290. /**
  70291. * Serialize this manager to a JSON object
  70292. * @param name defines the property name to store this manager
  70293. * @returns a JSON representation of this manager
  70294. */
  70295. serialize(name: string): any;
  70296. /**
  70297. * Creates a new ActionManager from a JSON data
  70298. * @param parsedActions defines the JSON data to read from
  70299. * @param object defines the hosting mesh
  70300. * @param scene defines the hosting scene
  70301. */
  70302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70303. /**
  70304. * Get a trigger name by index
  70305. * @param trigger defines the trigger index
  70306. * @returns a trigger name
  70307. */
  70308. static GetTriggerName(trigger: number): string;
  70309. }
  70310. }
  70311. declare module BABYLON {
  70312. /**
  70313. * Class representing a ray with position and direction
  70314. */
  70315. export class Ray {
  70316. /** origin point */
  70317. origin: Vector3;
  70318. /** direction */
  70319. direction: Vector3;
  70320. /** length of the ray */
  70321. length: number;
  70322. private static readonly TmpVector3;
  70323. private _tmpRay;
  70324. /**
  70325. * Creates a new ray
  70326. * @param origin origin point
  70327. * @param direction direction
  70328. * @param length length of the ray
  70329. */
  70330. constructor(
  70331. /** origin point */
  70332. origin: Vector3,
  70333. /** direction */
  70334. direction: Vector3,
  70335. /** length of the ray */
  70336. length?: number);
  70337. /**
  70338. * Checks if the ray intersects a box
  70339. * @param minimum bound of the box
  70340. * @param maximum bound of the box
  70341. * @param intersectionTreshold extra extend to be added to the box in all direction
  70342. * @returns if the box was hit
  70343. */
  70344. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70345. /**
  70346. * Checks if the ray intersects a box
  70347. * @param box the bounding box to check
  70348. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70349. * @returns if the box was hit
  70350. */
  70351. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70352. /**
  70353. * If the ray hits a sphere
  70354. * @param sphere the bounding sphere to check
  70355. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70356. * @returns true if it hits the sphere
  70357. */
  70358. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70359. /**
  70360. * If the ray hits a triange
  70361. * @param vertex0 triangle vertex
  70362. * @param vertex1 triangle vertex
  70363. * @param vertex2 triangle vertex
  70364. * @returns intersection information if hit
  70365. */
  70366. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70367. /**
  70368. * Checks if ray intersects a plane
  70369. * @param plane the plane to check
  70370. * @returns the distance away it was hit
  70371. */
  70372. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70373. /**
  70374. * Checks if ray intersects a mesh
  70375. * @param mesh the mesh to check
  70376. * @param fastCheck if only the bounding box should checked
  70377. * @returns picking info of the intersecton
  70378. */
  70379. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70380. /**
  70381. * Checks if ray intersects a mesh
  70382. * @param meshes the meshes to check
  70383. * @param fastCheck if only the bounding box should checked
  70384. * @param results array to store result in
  70385. * @returns Array of picking infos
  70386. */
  70387. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70388. private _comparePickingInfo;
  70389. private static smallnum;
  70390. private static rayl;
  70391. /**
  70392. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70393. * @param sega the first point of the segment to test the intersection against
  70394. * @param segb the second point of the segment to test the intersection against
  70395. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70396. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70397. */
  70398. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70399. /**
  70400. * Update the ray from viewport position
  70401. * @param x position
  70402. * @param y y position
  70403. * @param viewportWidth viewport width
  70404. * @param viewportHeight viewport height
  70405. * @param world world matrix
  70406. * @param view view matrix
  70407. * @param projection projection matrix
  70408. * @returns this ray updated
  70409. */
  70410. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70411. /**
  70412. * Creates a ray with origin and direction of 0,0,0
  70413. * @returns the new ray
  70414. */
  70415. static Zero(): Ray;
  70416. /**
  70417. * Creates a new ray from screen space and viewport
  70418. * @param x position
  70419. * @param y y position
  70420. * @param viewportWidth viewport width
  70421. * @param viewportHeight viewport height
  70422. * @param world world matrix
  70423. * @param view view matrix
  70424. * @param projection projection matrix
  70425. * @returns new ray
  70426. */
  70427. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70428. /**
  70429. * 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
  70430. * transformed to the given world matrix.
  70431. * @param origin The origin point
  70432. * @param end The end point
  70433. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70434. * @returns the new ray
  70435. */
  70436. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70437. /**
  70438. * Transforms a ray by a matrix
  70439. * @param ray ray to transform
  70440. * @param matrix matrix to apply
  70441. * @returns the resulting new ray
  70442. */
  70443. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70444. /**
  70445. * Transforms a ray by a matrix
  70446. * @param ray ray to transform
  70447. * @param matrix matrix to apply
  70448. * @param result ray to store result in
  70449. */
  70450. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70451. /**
  70452. * Unproject a ray from screen space to object space
  70453. * @param sourceX defines the screen space x coordinate to use
  70454. * @param sourceY defines the screen space y coordinate to use
  70455. * @param viewportWidth defines the current width of the viewport
  70456. * @param viewportHeight defines the current height of the viewport
  70457. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70458. * @param view defines the view matrix to use
  70459. * @param projection defines the projection matrix to use
  70460. */
  70461. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70462. }
  70463. /**
  70464. * Type used to define predicate used to select faces when a mesh intersection is detected
  70465. */
  70466. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70467. interface Scene {
  70468. /** @hidden */
  70469. _tempPickingRay: Nullable<Ray>;
  70470. /** @hidden */
  70471. _cachedRayForTransform: Ray;
  70472. /** @hidden */
  70473. _pickWithRayInverseMatrix: Matrix;
  70474. /** @hidden */
  70475. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70476. /** @hidden */
  70477. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70478. }
  70479. }
  70480. declare module BABYLON {
  70481. /**
  70482. * Groups all the scene component constants in one place to ease maintenance.
  70483. * @hidden
  70484. */
  70485. export class SceneComponentConstants {
  70486. static readonly NAME_EFFECTLAYER: string;
  70487. static readonly NAME_LAYER: string;
  70488. static readonly NAME_LENSFLARESYSTEM: string;
  70489. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70490. static readonly NAME_PARTICLESYSTEM: string;
  70491. static readonly NAME_GAMEPAD: string;
  70492. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70493. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70494. static readonly NAME_DEPTHRENDERER: string;
  70495. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70496. static readonly NAME_SPRITE: string;
  70497. static readonly NAME_OUTLINERENDERER: string;
  70498. static readonly NAME_PROCEDURALTEXTURE: string;
  70499. static readonly NAME_SHADOWGENERATOR: string;
  70500. static readonly NAME_OCTREE: string;
  70501. static readonly NAME_PHYSICSENGINE: string;
  70502. static readonly NAME_AUDIO: string;
  70503. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70504. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70505. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70506. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70507. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70508. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70509. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70510. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70511. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70512. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70513. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70514. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70515. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70516. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70517. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70518. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70519. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70520. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70521. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70522. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70523. static readonly STEP_AFTERRENDER_AUDIO: number;
  70524. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70525. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70526. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70527. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70528. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70529. static readonly STEP_POINTERMOVE_SPRITE: number;
  70530. static readonly STEP_POINTERDOWN_SPRITE: number;
  70531. static readonly STEP_POINTERUP_SPRITE: number;
  70532. }
  70533. /**
  70534. * This represents a scene component.
  70535. *
  70536. * This is used to decouple the dependency the scene is having on the different workloads like
  70537. * layers, post processes...
  70538. */
  70539. export interface ISceneComponent {
  70540. /**
  70541. * The name of the component. Each component must have a unique name.
  70542. */
  70543. name: string;
  70544. /**
  70545. * The scene the component belongs to.
  70546. */
  70547. scene: Scene;
  70548. /**
  70549. * Register the component to one instance of a scene.
  70550. */
  70551. register(): void;
  70552. /**
  70553. * Rebuilds the elements related to this component in case of
  70554. * context lost for instance.
  70555. */
  70556. rebuild(): void;
  70557. /**
  70558. * Disposes the component and the associated ressources.
  70559. */
  70560. dispose(): void;
  70561. }
  70562. /**
  70563. * This represents a SERIALIZABLE scene component.
  70564. *
  70565. * This extends Scene Component to add Serialization methods on top.
  70566. */
  70567. export interface ISceneSerializableComponent extends ISceneComponent {
  70568. /**
  70569. * Adds all the element from the container to the scene
  70570. * @param container the container holding the elements
  70571. */
  70572. addFromContainer(container: AbstractScene): void;
  70573. /**
  70574. * Removes all the elements in the container from the scene
  70575. * @param container contains the elements to remove
  70576. * @param dispose if the removed element should be disposed (default: false)
  70577. */
  70578. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70579. /**
  70580. * Serializes the component data to the specified json object
  70581. * @param serializationObject The object to serialize to
  70582. */
  70583. serialize(serializationObject: any): void;
  70584. }
  70585. /**
  70586. * Strong typing of a Mesh related stage step action
  70587. */
  70588. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70589. /**
  70590. * Strong typing of a Evaluate Sub Mesh related stage step action
  70591. */
  70592. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70593. /**
  70594. * Strong typing of a Active Mesh related stage step action
  70595. */
  70596. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70597. /**
  70598. * Strong typing of a Camera related stage step action
  70599. */
  70600. export type CameraStageAction = (camera: Camera) => void;
  70601. /**
  70602. * Strong typing of a Render Target related stage step action
  70603. */
  70604. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70605. /**
  70606. * Strong typing of a RenderingGroup related stage step action
  70607. */
  70608. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70609. /**
  70610. * Strong typing of a Mesh Render related stage step action
  70611. */
  70612. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70613. /**
  70614. * Strong typing of a simple stage step action
  70615. */
  70616. export type SimpleStageAction = () => void;
  70617. /**
  70618. * Strong typing of a render target action.
  70619. */
  70620. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70621. /**
  70622. * Strong typing of a pointer move action.
  70623. */
  70624. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70625. /**
  70626. * Strong typing of a pointer up/down action.
  70627. */
  70628. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70629. /**
  70630. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70631. * @hidden
  70632. */
  70633. export class Stage<T extends Function> extends Array<{
  70634. index: number;
  70635. component: ISceneComponent;
  70636. action: T;
  70637. }> {
  70638. /**
  70639. * Hide ctor from the rest of the world.
  70640. * @param items The items to add.
  70641. */
  70642. private constructor();
  70643. /**
  70644. * Creates a new Stage.
  70645. * @returns A new instance of a Stage
  70646. */
  70647. static Create<T extends Function>(): Stage<T>;
  70648. /**
  70649. * Registers a step in an ordered way in the targeted stage.
  70650. * @param index Defines the position to register the step in
  70651. * @param component Defines the component attached to the step
  70652. * @param action Defines the action to launch during the step
  70653. */
  70654. registerStep(index: number, component: ISceneComponent, action: T): void;
  70655. /**
  70656. * Clears all the steps from the stage.
  70657. */
  70658. clear(): void;
  70659. }
  70660. }
  70661. declare module BABYLON {
  70662. interface Scene {
  70663. /** @hidden */
  70664. _pointerOverSprite: Nullable<Sprite>;
  70665. /** @hidden */
  70666. _pickedDownSprite: Nullable<Sprite>;
  70667. /** @hidden */
  70668. _tempSpritePickingRay: Nullable<Ray>;
  70669. /**
  70670. * All of the sprite managers added to this scene
  70671. * @see http://doc.babylonjs.com/babylon101/sprites
  70672. */
  70673. spriteManagers: Array<ISpriteManager>;
  70674. /**
  70675. * An event triggered when sprites rendering is about to start
  70676. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70677. */
  70678. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70679. /**
  70680. * An event triggered when sprites rendering is done
  70681. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70682. */
  70683. onAfterSpritesRenderingObservable: Observable<Scene>;
  70684. /** @hidden */
  70685. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70686. /** Launch a ray to try to pick a sprite in the scene
  70687. * @param x position on screen
  70688. * @param y position on screen
  70689. * @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
  70690. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70691. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70692. * @returns a PickingInfo
  70693. */
  70694. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70695. /** Use the given ray to pick a sprite in the scene
  70696. * @param ray The ray (in world space) to use to pick meshes
  70697. * @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
  70698. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70699. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70700. * @returns a PickingInfo
  70701. */
  70702. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70703. /**
  70704. * Force the sprite under the pointer
  70705. * @param sprite defines the sprite to use
  70706. */
  70707. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70708. /**
  70709. * Gets the sprite under the pointer
  70710. * @returns a Sprite or null if no sprite is under the pointer
  70711. */
  70712. getPointerOverSprite(): Nullable<Sprite>;
  70713. }
  70714. /**
  70715. * Defines the sprite scene component responsible to manage sprites
  70716. * in a given scene.
  70717. */
  70718. export class SpriteSceneComponent implements ISceneComponent {
  70719. /**
  70720. * The component name helpfull to identify the component in the list of scene components.
  70721. */
  70722. readonly name: string;
  70723. /**
  70724. * The scene the component belongs to.
  70725. */
  70726. scene: Scene;
  70727. /** @hidden */
  70728. private _spritePredicate;
  70729. /**
  70730. * Creates a new instance of the component for the given scene
  70731. * @param scene Defines the scene to register the component in
  70732. */
  70733. constructor(scene: Scene);
  70734. /**
  70735. * Registers the component in a given scene
  70736. */
  70737. register(): void;
  70738. /**
  70739. * Rebuilds the elements related to this component in case of
  70740. * context lost for instance.
  70741. */
  70742. rebuild(): void;
  70743. /**
  70744. * Disposes the component and the associated ressources.
  70745. */
  70746. dispose(): void;
  70747. private _pickSpriteButKeepRay;
  70748. private _pointerMove;
  70749. private _pointerDown;
  70750. private _pointerUp;
  70751. }
  70752. }
  70753. declare module BABYLON {
  70754. /** @hidden */
  70755. export var fogFragmentDeclaration: {
  70756. name: string;
  70757. shader: string;
  70758. };
  70759. }
  70760. declare module BABYLON {
  70761. /** @hidden */
  70762. export var fogFragment: {
  70763. name: string;
  70764. shader: string;
  70765. };
  70766. }
  70767. declare module BABYLON {
  70768. /** @hidden */
  70769. export var spritesPixelShader: {
  70770. name: string;
  70771. shader: string;
  70772. };
  70773. }
  70774. declare module BABYLON {
  70775. /** @hidden */
  70776. export var fogVertexDeclaration: {
  70777. name: string;
  70778. shader: string;
  70779. };
  70780. }
  70781. declare module BABYLON {
  70782. /** @hidden */
  70783. export var spritesVertexShader: {
  70784. name: string;
  70785. shader: string;
  70786. };
  70787. }
  70788. declare module BABYLON {
  70789. /**
  70790. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70791. */
  70792. export interface ISpriteManager extends IDisposable {
  70793. /**
  70794. * Restricts the camera to viewing objects with the same layerMask.
  70795. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70796. */
  70797. layerMask: number;
  70798. /**
  70799. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70800. */
  70801. isPickable: boolean;
  70802. /**
  70803. * Specifies the rendering group id for this mesh (0 by default)
  70804. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70805. */
  70806. renderingGroupId: number;
  70807. /**
  70808. * Defines the list of sprites managed by the manager.
  70809. */
  70810. sprites: Array<Sprite>;
  70811. /**
  70812. * Tests the intersection of a sprite with a specific ray.
  70813. * @param ray The ray we are sending to test the collision
  70814. * @param camera The camera space we are sending rays in
  70815. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70816. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70817. * @returns picking info or null.
  70818. */
  70819. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70820. /**
  70821. * Renders the list of sprites on screen.
  70822. */
  70823. render(): void;
  70824. }
  70825. /**
  70826. * Class used to manage multiple sprites on the same spritesheet
  70827. * @see http://doc.babylonjs.com/babylon101/sprites
  70828. */
  70829. export class SpriteManager implements ISpriteManager {
  70830. /** defines the manager's name */
  70831. name: string;
  70832. /** Gets the list of sprites */
  70833. sprites: Sprite[];
  70834. /** Gets or sets the rendering group id (0 by default) */
  70835. renderingGroupId: number;
  70836. /** Gets or sets camera layer mask */
  70837. layerMask: number;
  70838. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70839. fogEnabled: boolean;
  70840. /** Gets or sets a boolean indicating if the sprites are pickable */
  70841. isPickable: boolean;
  70842. /** Defines the default width of a cell in the spritesheet */
  70843. cellWidth: number;
  70844. /** Defines the default height of a cell in the spritesheet */
  70845. cellHeight: number;
  70846. /**
  70847. * An event triggered when the manager is disposed.
  70848. */
  70849. onDisposeObservable: Observable<SpriteManager>;
  70850. private _onDisposeObserver;
  70851. /**
  70852. * Callback called when the manager is disposed
  70853. */
  70854. onDispose: () => void;
  70855. private _capacity;
  70856. private _spriteTexture;
  70857. private _epsilon;
  70858. private _scene;
  70859. private _vertexData;
  70860. private _buffer;
  70861. private _vertexBuffers;
  70862. private _indexBuffer;
  70863. private _effectBase;
  70864. private _effectFog;
  70865. /**
  70866. * Gets or sets the spritesheet texture
  70867. */
  70868. texture: Texture;
  70869. /**
  70870. * Creates a new sprite manager
  70871. * @param name defines the manager's name
  70872. * @param imgUrl defines the sprite sheet url
  70873. * @param capacity defines the maximum allowed number of sprites
  70874. * @param cellSize defines the size of a sprite cell
  70875. * @param scene defines the hosting scene
  70876. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70877. * @param samplingMode defines the smapling mode to use with spritesheet
  70878. */
  70879. constructor(
  70880. /** defines the manager's name */
  70881. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70882. private _appendSpriteVertex;
  70883. /**
  70884. * Intersects the sprites with a ray
  70885. * @param ray defines the ray to intersect with
  70886. * @param camera defines the current active camera
  70887. * @param predicate defines a predicate used to select candidate sprites
  70888. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70889. * @returns null if no hit or a PickingInfo
  70890. */
  70891. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70892. /**
  70893. * Render all child sprites
  70894. */
  70895. render(): void;
  70896. /**
  70897. * Release associated resources
  70898. */
  70899. dispose(): void;
  70900. }
  70901. }
  70902. declare module BABYLON {
  70903. /**
  70904. * Class used to represent a sprite
  70905. * @see http://doc.babylonjs.com/babylon101/sprites
  70906. */
  70907. export class Sprite {
  70908. /** defines the name */
  70909. name: string;
  70910. /** Gets or sets the current world position */
  70911. position: Vector3;
  70912. /** Gets or sets the main color */
  70913. color: Color4;
  70914. /** Gets or sets the width */
  70915. width: number;
  70916. /** Gets or sets the height */
  70917. height: number;
  70918. /** Gets or sets rotation angle */
  70919. angle: number;
  70920. /** Gets or sets the cell index in the sprite sheet */
  70921. cellIndex: number;
  70922. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70923. invertU: number;
  70924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70925. invertV: number;
  70926. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70927. disposeWhenFinishedAnimating: boolean;
  70928. /** Gets the list of attached animations */
  70929. animations: Animation[];
  70930. /** Gets or sets a boolean indicating if the sprite can be picked */
  70931. isPickable: boolean;
  70932. /**
  70933. * Gets or sets the associated action manager
  70934. */
  70935. actionManager: Nullable<ActionManager>;
  70936. private _animationStarted;
  70937. private _loopAnimation;
  70938. private _fromIndex;
  70939. private _toIndex;
  70940. private _delay;
  70941. private _direction;
  70942. private _manager;
  70943. private _time;
  70944. private _onAnimationEnd;
  70945. /**
  70946. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70947. */
  70948. isVisible: boolean;
  70949. /**
  70950. * Gets or sets the sprite size
  70951. */
  70952. size: number;
  70953. /**
  70954. * Creates a new Sprite
  70955. * @param name defines the name
  70956. * @param manager defines the manager
  70957. */
  70958. constructor(
  70959. /** defines the name */
  70960. name: string, manager: ISpriteManager);
  70961. /**
  70962. * Starts an animation
  70963. * @param from defines the initial key
  70964. * @param to defines the end key
  70965. * @param loop defines if the animation must loop
  70966. * @param delay defines the start delay (in ms)
  70967. * @param onAnimationEnd defines a callback to call when animation ends
  70968. */
  70969. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70970. /** Stops current animation (if any) */
  70971. stopAnimation(): void;
  70972. /** @hidden */
  70973. _animate(deltaTime: number): void;
  70974. /** Release associated resources */
  70975. dispose(): void;
  70976. }
  70977. }
  70978. declare module BABYLON {
  70979. /**
  70980. * Information about the result of picking within a scene
  70981. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70982. */
  70983. export class PickingInfo {
  70984. /** @hidden */
  70985. _pickingUnavailable: boolean;
  70986. /**
  70987. * If the pick collided with an object
  70988. */
  70989. hit: boolean;
  70990. /**
  70991. * Distance away where the pick collided
  70992. */
  70993. distance: number;
  70994. /**
  70995. * The location of pick collision
  70996. */
  70997. pickedPoint: Nullable<Vector3>;
  70998. /**
  70999. * The mesh corresponding the the pick collision
  71000. */
  71001. pickedMesh: Nullable<AbstractMesh>;
  71002. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71003. bu: number;
  71004. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71005. bv: number;
  71006. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71007. faceId: number;
  71008. /** Id of the the submesh that was picked */
  71009. subMeshId: number;
  71010. /** If a sprite was picked, this will be the sprite the pick collided with */
  71011. pickedSprite: Nullable<Sprite>;
  71012. /**
  71013. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71014. */
  71015. originMesh: Nullable<AbstractMesh>;
  71016. /**
  71017. * The ray that was used to perform the picking.
  71018. */
  71019. ray: Nullable<Ray>;
  71020. /**
  71021. * Gets the normal correspodning to the face the pick collided with
  71022. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71023. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71024. * @returns The normal correspodning to the face the pick collided with
  71025. */
  71026. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71027. /**
  71028. * Gets the texture coordinates of where the pick occured
  71029. * @returns the vector containing the coordnates of the texture
  71030. */
  71031. getTextureCoordinates(): Nullable<Vector2>;
  71032. }
  71033. }
  71034. declare module BABYLON {
  71035. /**
  71036. * Gather the list of pointer event types as constants.
  71037. */
  71038. export class PointerEventTypes {
  71039. /**
  71040. * 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.
  71041. */
  71042. static readonly POINTERDOWN: number;
  71043. /**
  71044. * The pointerup event is fired when a pointer is no longer active.
  71045. */
  71046. static readonly POINTERUP: number;
  71047. /**
  71048. * The pointermove event is fired when a pointer changes coordinates.
  71049. */
  71050. static readonly POINTERMOVE: number;
  71051. /**
  71052. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71053. */
  71054. static readonly POINTERWHEEL: number;
  71055. /**
  71056. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71057. */
  71058. static readonly POINTERPICK: number;
  71059. /**
  71060. * The pointertap event is fired when a the object has been touched and released without drag.
  71061. */
  71062. static readonly POINTERTAP: number;
  71063. /**
  71064. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71065. */
  71066. static readonly POINTERDOUBLETAP: number;
  71067. }
  71068. /**
  71069. * Base class of pointer info types.
  71070. */
  71071. export class PointerInfoBase {
  71072. /**
  71073. * Defines the type of event (PointerEventTypes)
  71074. */
  71075. type: number;
  71076. /**
  71077. * Defines the related dom event
  71078. */
  71079. event: PointerEvent | MouseWheelEvent;
  71080. /**
  71081. * Instantiates the base class of pointers info.
  71082. * @param type Defines the type of event (PointerEventTypes)
  71083. * @param event Defines the related dom event
  71084. */
  71085. constructor(
  71086. /**
  71087. * Defines the type of event (PointerEventTypes)
  71088. */
  71089. type: number,
  71090. /**
  71091. * Defines the related dom event
  71092. */
  71093. event: PointerEvent | MouseWheelEvent);
  71094. }
  71095. /**
  71096. * This class is used to store pointer related info for the onPrePointerObservable event.
  71097. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71098. */
  71099. export class PointerInfoPre extends PointerInfoBase {
  71100. /**
  71101. * Ray from a pointer if availible (eg. 6dof controller)
  71102. */
  71103. ray: Nullable<Ray>;
  71104. /**
  71105. * Defines the local position of the pointer on the canvas.
  71106. */
  71107. localPosition: Vector2;
  71108. /**
  71109. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71110. */
  71111. skipOnPointerObservable: boolean;
  71112. /**
  71113. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71114. * @param type Defines the type of event (PointerEventTypes)
  71115. * @param event Defines the related dom event
  71116. * @param localX Defines the local x coordinates of the pointer when the event occured
  71117. * @param localY Defines the local y coordinates of the pointer when the event occured
  71118. */
  71119. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71120. }
  71121. /**
  71122. * This type contains all the data related to a pointer event in Babylon.js.
  71123. * 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.
  71124. */
  71125. export class PointerInfo extends PointerInfoBase {
  71126. /**
  71127. * Defines the picking info associated to the info (if any)\
  71128. */
  71129. pickInfo: Nullable<PickingInfo>;
  71130. /**
  71131. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71132. * @param type Defines the type of event (PointerEventTypes)
  71133. * @param event Defines the related dom event
  71134. * @param pickInfo Defines the picking info associated to the info (if any)\
  71135. */
  71136. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71137. /**
  71138. * Defines the picking info associated to the info (if any)\
  71139. */
  71140. pickInfo: Nullable<PickingInfo>);
  71141. }
  71142. /**
  71143. * Data relating to a touch event on the screen.
  71144. */
  71145. export interface PointerTouch {
  71146. /**
  71147. * X coordinate of touch.
  71148. */
  71149. x: number;
  71150. /**
  71151. * Y coordinate of touch.
  71152. */
  71153. y: number;
  71154. /**
  71155. * Id of touch. Unique for each finger.
  71156. */
  71157. pointerId: number;
  71158. /**
  71159. * Event type passed from DOM.
  71160. */
  71161. type: any;
  71162. }
  71163. }
  71164. declare module BABYLON {
  71165. /**
  71166. * Manage the mouse inputs to control the movement of a free camera.
  71167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71168. */
  71169. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71170. /**
  71171. * Define if touch is enabled in the mouse input
  71172. */
  71173. touchEnabled: boolean;
  71174. /**
  71175. * Defines the camera the input is attached to.
  71176. */
  71177. camera: FreeCamera;
  71178. /**
  71179. * Defines the buttons associated with the input to handle camera move.
  71180. */
  71181. buttons: number[];
  71182. /**
  71183. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71184. */
  71185. angularSensibility: number;
  71186. private _pointerInput;
  71187. private _onMouseMove;
  71188. private _observer;
  71189. private previousPosition;
  71190. /**
  71191. * Observable for when a pointer move event occurs containing the move offset
  71192. */
  71193. onPointerMovedObservable: Observable<{
  71194. offsetX: number;
  71195. offsetY: number;
  71196. }>;
  71197. /**
  71198. * @hidden
  71199. * If the camera should be rotated automatically based on pointer movement
  71200. */
  71201. _allowCameraRotation: boolean;
  71202. /**
  71203. * Manage the mouse inputs to control the movement of a free camera.
  71204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71205. * @param touchEnabled Defines if touch is enabled or not
  71206. */
  71207. constructor(
  71208. /**
  71209. * Define if touch is enabled in the mouse input
  71210. */
  71211. touchEnabled?: boolean);
  71212. /**
  71213. * Attach the input controls to a specific dom element to get the input from.
  71214. * @param element Defines the element the controls should be listened from
  71215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71216. */
  71217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71218. /**
  71219. * Called on JS contextmenu event.
  71220. * Override this method to provide functionality.
  71221. */
  71222. protected onContextMenu(evt: PointerEvent): void;
  71223. /**
  71224. * Detach the current controls from the specified dom element.
  71225. * @param element Defines the element to stop listening the inputs from
  71226. */
  71227. detachControl(element: Nullable<HTMLElement>): void;
  71228. /**
  71229. * Gets the class name of the current intput.
  71230. * @returns the class name
  71231. */
  71232. getClassName(): string;
  71233. /**
  71234. * Get the friendly name associated with the input class.
  71235. * @returns the input friendly name
  71236. */
  71237. getSimpleName(): string;
  71238. }
  71239. }
  71240. declare module BABYLON {
  71241. /**
  71242. * Manage the touch inputs to control the movement of a free camera.
  71243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71244. */
  71245. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71246. /**
  71247. * Defines the camera the input is attached to.
  71248. */
  71249. camera: FreeCamera;
  71250. /**
  71251. * Defines the touch sensibility for rotation.
  71252. * The higher the faster.
  71253. */
  71254. touchAngularSensibility: number;
  71255. /**
  71256. * Defines the touch sensibility for move.
  71257. * The higher the faster.
  71258. */
  71259. touchMoveSensibility: number;
  71260. private _offsetX;
  71261. private _offsetY;
  71262. private _pointerPressed;
  71263. private _pointerInput;
  71264. private _observer;
  71265. private _onLostFocus;
  71266. /**
  71267. * Attach the input controls to a specific dom element to get the input from.
  71268. * @param element Defines the element the controls should be listened from
  71269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71270. */
  71271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71272. /**
  71273. * Detach the current controls from the specified dom element.
  71274. * @param element Defines the element to stop listening the inputs from
  71275. */
  71276. detachControl(element: Nullable<HTMLElement>): void;
  71277. /**
  71278. * Update the current camera state depending on the inputs that have been used this frame.
  71279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71280. */
  71281. checkInputs(): void;
  71282. /**
  71283. * Gets the class name of the current intput.
  71284. * @returns the class name
  71285. */
  71286. getClassName(): string;
  71287. /**
  71288. * Get the friendly name associated with the input class.
  71289. * @returns the input friendly name
  71290. */
  71291. getSimpleName(): string;
  71292. }
  71293. }
  71294. declare module BABYLON {
  71295. /**
  71296. * Default Inputs manager for the FreeCamera.
  71297. * It groups all the default supported inputs for ease of use.
  71298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71299. */
  71300. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71301. /**
  71302. * @hidden
  71303. */
  71304. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71305. /**
  71306. * @hidden
  71307. */
  71308. _mouseInput: Nullable<FreeCameraMouseInput>;
  71309. /**
  71310. * Instantiates a new FreeCameraInputsManager.
  71311. * @param camera Defines the camera the inputs belong to
  71312. */
  71313. constructor(camera: FreeCamera);
  71314. /**
  71315. * Add keyboard input support to the input manager.
  71316. * @returns the current input manager
  71317. */
  71318. addKeyboard(): FreeCameraInputsManager;
  71319. /**
  71320. * Add mouse input support to the input manager.
  71321. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71322. * @returns the current input manager
  71323. */
  71324. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71325. /**
  71326. * Removes the mouse input support from the manager
  71327. * @returns the current input manager
  71328. */
  71329. removeMouse(): FreeCameraInputsManager;
  71330. /**
  71331. * Add touch input support to the input manager.
  71332. * @returns the current input manager
  71333. */
  71334. addTouch(): FreeCameraInputsManager;
  71335. }
  71336. }
  71337. declare module BABYLON {
  71338. /**
  71339. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71340. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71341. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71342. */
  71343. export class FreeCamera extends TargetCamera {
  71344. /**
  71345. * Define the collision ellipsoid of the camera.
  71346. * This is helpful to simulate a camera body like the player body around the camera
  71347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71348. */
  71349. ellipsoid: Vector3;
  71350. /**
  71351. * Define an offset for the position of the ellipsoid around the camera.
  71352. * This can be helpful to determine the center of the body near the gravity center of the body
  71353. * instead of its head.
  71354. */
  71355. ellipsoidOffset: Vector3;
  71356. /**
  71357. * Enable or disable collisions of the camera with the rest of the scene objects.
  71358. */
  71359. checkCollisions: boolean;
  71360. /**
  71361. * Enable or disable gravity on the camera.
  71362. */
  71363. applyGravity: boolean;
  71364. /**
  71365. * Define the input manager associated to the camera.
  71366. */
  71367. inputs: FreeCameraInputsManager;
  71368. /**
  71369. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71370. * Higher values reduce sensitivity.
  71371. */
  71372. /**
  71373. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71374. * Higher values reduce sensitivity.
  71375. */
  71376. angularSensibility: number;
  71377. /**
  71378. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71379. */
  71380. keysUp: number[];
  71381. /**
  71382. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71383. */
  71384. keysDown: number[];
  71385. /**
  71386. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71387. */
  71388. keysLeft: number[];
  71389. /**
  71390. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71391. */
  71392. keysRight: number[];
  71393. /**
  71394. * Event raised when the camera collide with a mesh in the scene.
  71395. */
  71396. onCollide: (collidedMesh: AbstractMesh) => void;
  71397. private _collider;
  71398. private _needMoveForGravity;
  71399. private _oldPosition;
  71400. private _diffPosition;
  71401. private _newPosition;
  71402. /** @hidden */
  71403. _localDirection: Vector3;
  71404. /** @hidden */
  71405. _transformedDirection: Vector3;
  71406. /**
  71407. * Instantiates a Free Camera.
  71408. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71409. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71410. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71411. * @param name Define the name of the camera in the scene
  71412. * @param position Define the start position of the camera in the scene
  71413. * @param scene Define the scene the camera belongs to
  71414. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71415. */
  71416. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71417. /**
  71418. * Attached controls to the current camera.
  71419. * @param element Defines the element the controls should be listened from
  71420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71421. */
  71422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71423. /**
  71424. * Detach the current controls from the camera.
  71425. * The camera will stop reacting to inputs.
  71426. * @param element Defines the element to stop listening the inputs from
  71427. */
  71428. detachControl(element: HTMLElement): void;
  71429. private _collisionMask;
  71430. /**
  71431. * Define a collision mask to limit the list of object the camera can collide with
  71432. */
  71433. collisionMask: number;
  71434. /** @hidden */
  71435. _collideWithWorld(displacement: Vector3): void;
  71436. private _onCollisionPositionChange;
  71437. /** @hidden */
  71438. _checkInputs(): void;
  71439. /** @hidden */
  71440. _decideIfNeedsToMove(): boolean;
  71441. /** @hidden */
  71442. _updatePosition(): void;
  71443. /**
  71444. * Destroy the camera and release the current resources hold by it.
  71445. */
  71446. dispose(): void;
  71447. /**
  71448. * Gets the current object class name.
  71449. * @return the class name
  71450. */
  71451. getClassName(): string;
  71452. }
  71453. }
  71454. declare module BABYLON {
  71455. /**
  71456. * Represents a gamepad control stick position
  71457. */
  71458. export class StickValues {
  71459. /**
  71460. * The x component of the control stick
  71461. */
  71462. x: number;
  71463. /**
  71464. * The y component of the control stick
  71465. */
  71466. y: number;
  71467. /**
  71468. * Initializes the gamepad x and y control stick values
  71469. * @param x The x component of the gamepad control stick value
  71470. * @param y The y component of the gamepad control stick value
  71471. */
  71472. constructor(
  71473. /**
  71474. * The x component of the control stick
  71475. */
  71476. x: number,
  71477. /**
  71478. * The y component of the control stick
  71479. */
  71480. y: number);
  71481. }
  71482. /**
  71483. * An interface which manages callbacks for gamepad button changes
  71484. */
  71485. export interface GamepadButtonChanges {
  71486. /**
  71487. * Called when a gamepad has been changed
  71488. */
  71489. changed: boolean;
  71490. /**
  71491. * Called when a gamepad press event has been triggered
  71492. */
  71493. pressChanged: boolean;
  71494. /**
  71495. * Called when a touch event has been triggered
  71496. */
  71497. touchChanged: boolean;
  71498. /**
  71499. * Called when a value has changed
  71500. */
  71501. valueChanged: boolean;
  71502. }
  71503. /**
  71504. * Represents a gamepad
  71505. */
  71506. export class Gamepad {
  71507. /**
  71508. * The id of the gamepad
  71509. */
  71510. id: string;
  71511. /**
  71512. * The index of the gamepad
  71513. */
  71514. index: number;
  71515. /**
  71516. * The browser gamepad
  71517. */
  71518. browserGamepad: any;
  71519. /**
  71520. * Specifies what type of gamepad this represents
  71521. */
  71522. type: number;
  71523. private _leftStick;
  71524. private _rightStick;
  71525. /** @hidden */
  71526. _isConnected: boolean;
  71527. private _leftStickAxisX;
  71528. private _leftStickAxisY;
  71529. private _rightStickAxisX;
  71530. private _rightStickAxisY;
  71531. /**
  71532. * Triggered when the left control stick has been changed
  71533. */
  71534. private _onleftstickchanged;
  71535. /**
  71536. * Triggered when the right control stick has been changed
  71537. */
  71538. private _onrightstickchanged;
  71539. /**
  71540. * Represents a gamepad controller
  71541. */
  71542. static GAMEPAD: number;
  71543. /**
  71544. * Represents a generic controller
  71545. */
  71546. static GENERIC: number;
  71547. /**
  71548. * Represents an XBox controller
  71549. */
  71550. static XBOX: number;
  71551. /**
  71552. * Represents a pose-enabled controller
  71553. */
  71554. static POSE_ENABLED: number;
  71555. /**
  71556. * Specifies whether the left control stick should be Y-inverted
  71557. */
  71558. protected _invertLeftStickY: boolean;
  71559. /**
  71560. * Specifies if the gamepad has been connected
  71561. */
  71562. readonly isConnected: boolean;
  71563. /**
  71564. * Initializes the gamepad
  71565. * @param id The id of the gamepad
  71566. * @param index The index of the gamepad
  71567. * @param browserGamepad The browser gamepad
  71568. * @param leftStickX The x component of the left joystick
  71569. * @param leftStickY The y component of the left joystick
  71570. * @param rightStickX The x component of the right joystick
  71571. * @param rightStickY The y component of the right joystick
  71572. */
  71573. constructor(
  71574. /**
  71575. * The id of the gamepad
  71576. */
  71577. id: string,
  71578. /**
  71579. * The index of the gamepad
  71580. */
  71581. index: number,
  71582. /**
  71583. * The browser gamepad
  71584. */
  71585. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71586. /**
  71587. * Callback triggered when the left joystick has changed
  71588. * @param callback
  71589. */
  71590. onleftstickchanged(callback: (values: StickValues) => void): void;
  71591. /**
  71592. * Callback triggered when the right joystick has changed
  71593. * @param callback
  71594. */
  71595. onrightstickchanged(callback: (values: StickValues) => void): void;
  71596. /**
  71597. * Gets the left joystick
  71598. */
  71599. /**
  71600. * Sets the left joystick values
  71601. */
  71602. leftStick: StickValues;
  71603. /**
  71604. * Gets the right joystick
  71605. */
  71606. /**
  71607. * Sets the right joystick value
  71608. */
  71609. rightStick: StickValues;
  71610. /**
  71611. * Updates the gamepad joystick positions
  71612. */
  71613. update(): void;
  71614. /**
  71615. * Disposes the gamepad
  71616. */
  71617. dispose(): void;
  71618. }
  71619. /**
  71620. * Represents a generic gamepad
  71621. */
  71622. export class GenericPad extends Gamepad {
  71623. private _buttons;
  71624. private _onbuttondown;
  71625. private _onbuttonup;
  71626. /**
  71627. * Observable triggered when a button has been pressed
  71628. */
  71629. onButtonDownObservable: Observable<number>;
  71630. /**
  71631. * Observable triggered when a button has been released
  71632. */
  71633. onButtonUpObservable: Observable<number>;
  71634. /**
  71635. * Callback triggered when a button has been pressed
  71636. * @param callback Called when a button has been pressed
  71637. */
  71638. onbuttondown(callback: (buttonPressed: number) => void): void;
  71639. /**
  71640. * Callback triggered when a button has been released
  71641. * @param callback Called when a button has been released
  71642. */
  71643. onbuttonup(callback: (buttonReleased: number) => void): void;
  71644. /**
  71645. * Initializes the generic gamepad
  71646. * @param id The id of the generic gamepad
  71647. * @param index The index of the generic gamepad
  71648. * @param browserGamepad The browser gamepad
  71649. */
  71650. constructor(id: string, index: number, browserGamepad: any);
  71651. private _setButtonValue;
  71652. /**
  71653. * Updates the generic gamepad
  71654. */
  71655. update(): void;
  71656. /**
  71657. * Disposes the generic gamepad
  71658. */
  71659. dispose(): void;
  71660. }
  71661. }
  71662. declare module BABYLON {
  71663. /**
  71664. * Defines the types of pose enabled controllers that are supported
  71665. */
  71666. export enum PoseEnabledControllerType {
  71667. /**
  71668. * HTC Vive
  71669. */
  71670. VIVE = 0,
  71671. /**
  71672. * Oculus Rift
  71673. */
  71674. OCULUS = 1,
  71675. /**
  71676. * Windows mixed reality
  71677. */
  71678. WINDOWS = 2,
  71679. /**
  71680. * Samsung gear VR
  71681. */
  71682. GEAR_VR = 3,
  71683. /**
  71684. * Google Daydream
  71685. */
  71686. DAYDREAM = 4,
  71687. /**
  71688. * Generic
  71689. */
  71690. GENERIC = 5
  71691. }
  71692. /**
  71693. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71694. */
  71695. export interface MutableGamepadButton {
  71696. /**
  71697. * Value of the button/trigger
  71698. */
  71699. value: number;
  71700. /**
  71701. * If the button/trigger is currently touched
  71702. */
  71703. touched: boolean;
  71704. /**
  71705. * If the button/trigger is currently pressed
  71706. */
  71707. pressed: boolean;
  71708. }
  71709. /**
  71710. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71711. * @hidden
  71712. */
  71713. export interface ExtendedGamepadButton extends GamepadButton {
  71714. /**
  71715. * If the button/trigger is currently pressed
  71716. */
  71717. readonly pressed: boolean;
  71718. /**
  71719. * If the button/trigger is currently touched
  71720. */
  71721. readonly touched: boolean;
  71722. /**
  71723. * Value of the button/trigger
  71724. */
  71725. readonly value: number;
  71726. }
  71727. /** @hidden */
  71728. export interface _GamePadFactory {
  71729. /**
  71730. * Returns wether or not the current gamepad can be created for this type of controller.
  71731. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71732. * @returns true if it can be created, otherwise false
  71733. */
  71734. canCreate(gamepadInfo: any): boolean;
  71735. /**
  71736. * Creates a new instance of the Gamepad.
  71737. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71738. * @returns the new gamepad instance
  71739. */
  71740. create(gamepadInfo: any): Gamepad;
  71741. }
  71742. /**
  71743. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71744. */
  71745. export class PoseEnabledControllerHelper {
  71746. /** @hidden */
  71747. static _ControllerFactories: _GamePadFactory[];
  71748. /** @hidden */
  71749. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71750. /**
  71751. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71752. * @param vrGamepad the gamepad to initialized
  71753. * @returns a vr controller of the type the gamepad identified as
  71754. */
  71755. static InitiateController(vrGamepad: any): Gamepad;
  71756. }
  71757. /**
  71758. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71759. */
  71760. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71761. private _deviceRoomPosition;
  71762. private _deviceRoomRotationQuaternion;
  71763. /**
  71764. * The device position in babylon space
  71765. */
  71766. devicePosition: Vector3;
  71767. /**
  71768. * The device rotation in babylon space
  71769. */
  71770. deviceRotationQuaternion: Quaternion;
  71771. /**
  71772. * The scale factor of the device in babylon space
  71773. */
  71774. deviceScaleFactor: number;
  71775. /**
  71776. * (Likely devicePosition should be used instead) The device position in its room space
  71777. */
  71778. position: Vector3;
  71779. /**
  71780. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71781. */
  71782. rotationQuaternion: Quaternion;
  71783. /**
  71784. * The type of controller (Eg. Windows mixed reality)
  71785. */
  71786. controllerType: PoseEnabledControllerType;
  71787. protected _calculatedPosition: Vector3;
  71788. private _calculatedRotation;
  71789. /**
  71790. * The raw pose from the device
  71791. */
  71792. rawPose: DevicePose;
  71793. private _trackPosition;
  71794. private _maxRotationDistFromHeadset;
  71795. private _draggedRoomRotation;
  71796. /**
  71797. * @hidden
  71798. */
  71799. _disableTrackPosition(fixedPosition: Vector3): void;
  71800. /**
  71801. * Internal, the mesh attached to the controller
  71802. * @hidden
  71803. */
  71804. _mesh: Nullable<AbstractMesh>;
  71805. private _poseControlledCamera;
  71806. private _leftHandSystemQuaternion;
  71807. /**
  71808. * Internal, matrix used to convert room space to babylon space
  71809. * @hidden
  71810. */
  71811. _deviceToWorld: Matrix;
  71812. /**
  71813. * Node to be used when casting a ray from the controller
  71814. * @hidden
  71815. */
  71816. _pointingPoseNode: Nullable<TransformNode>;
  71817. /**
  71818. * Name of the child mesh that can be used to cast a ray from the controller
  71819. */
  71820. static readonly POINTING_POSE: string;
  71821. /**
  71822. * Creates a new PoseEnabledController from a gamepad
  71823. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71824. */
  71825. constructor(browserGamepad: any);
  71826. private _workingMatrix;
  71827. /**
  71828. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71829. */
  71830. update(): void;
  71831. /**
  71832. * Updates only the pose device and mesh without doing any button event checking
  71833. */
  71834. protected _updatePoseAndMesh(): void;
  71835. /**
  71836. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71837. * @param poseData raw pose fromthe device
  71838. */
  71839. updateFromDevice(poseData: DevicePose): void;
  71840. /**
  71841. * @hidden
  71842. */
  71843. _meshAttachedObservable: Observable<AbstractMesh>;
  71844. /**
  71845. * Attaches a mesh to the controller
  71846. * @param mesh the mesh to be attached
  71847. */
  71848. attachToMesh(mesh: AbstractMesh): void;
  71849. /**
  71850. * Attaches the controllers mesh to a camera
  71851. * @param camera the camera the mesh should be attached to
  71852. */
  71853. attachToPoseControlledCamera(camera: TargetCamera): void;
  71854. /**
  71855. * Disposes of the controller
  71856. */
  71857. dispose(): void;
  71858. /**
  71859. * The mesh that is attached to the controller
  71860. */
  71861. readonly mesh: Nullable<AbstractMesh>;
  71862. /**
  71863. * Gets the ray of the controller in the direction the controller is pointing
  71864. * @param length the length the resulting ray should be
  71865. * @returns a ray in the direction the controller is pointing
  71866. */
  71867. getForwardRay(length?: number): Ray;
  71868. }
  71869. }
  71870. declare module BABYLON {
  71871. /**
  71872. * Defines the WebVRController object that represents controllers tracked in 3D space
  71873. */
  71874. export abstract class WebVRController extends PoseEnabledController {
  71875. /**
  71876. * Internal, the default controller model for the controller
  71877. */
  71878. protected _defaultModel: AbstractMesh;
  71879. /**
  71880. * Fired when the trigger state has changed
  71881. */
  71882. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71883. /**
  71884. * Fired when the main button state has changed
  71885. */
  71886. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71887. /**
  71888. * Fired when the secondary button state has changed
  71889. */
  71890. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71891. /**
  71892. * Fired when the pad state has changed
  71893. */
  71894. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71895. /**
  71896. * Fired when controllers stick values have changed
  71897. */
  71898. onPadValuesChangedObservable: Observable<StickValues>;
  71899. /**
  71900. * Array of button availible on the controller
  71901. */
  71902. protected _buttons: Array<MutableGamepadButton>;
  71903. private _onButtonStateChange;
  71904. /**
  71905. * Fired when a controller button's state has changed
  71906. * @param callback the callback containing the button that was modified
  71907. */
  71908. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71909. /**
  71910. * X and Y axis corrisponding to the controllers joystick
  71911. */
  71912. pad: StickValues;
  71913. /**
  71914. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71915. */
  71916. hand: string;
  71917. /**
  71918. * The default controller model for the controller
  71919. */
  71920. readonly defaultModel: AbstractMesh;
  71921. /**
  71922. * Creates a new WebVRController from a gamepad
  71923. * @param vrGamepad the gamepad that the WebVRController should be created from
  71924. */
  71925. constructor(vrGamepad: any);
  71926. /**
  71927. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71928. */
  71929. update(): void;
  71930. /**
  71931. * Function to be called when a button is modified
  71932. */
  71933. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71934. /**
  71935. * Loads a mesh and attaches it to the controller
  71936. * @param scene the scene the mesh should be added to
  71937. * @param meshLoaded callback for when the mesh has been loaded
  71938. */
  71939. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71940. private _setButtonValue;
  71941. private _changes;
  71942. private _checkChanges;
  71943. /**
  71944. * Disposes of th webVRCOntroller
  71945. */
  71946. dispose(): void;
  71947. }
  71948. }
  71949. declare module BABYLON {
  71950. /**
  71951. * The HemisphericLight simulates the ambient environment light,
  71952. * so the passed direction is the light reflection direction, not the incoming direction.
  71953. */
  71954. export class HemisphericLight extends Light {
  71955. /**
  71956. * The groundColor is the light in the opposite direction to the one specified during creation.
  71957. * 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.
  71958. */
  71959. groundColor: Color3;
  71960. /**
  71961. * The light reflection direction, not the incoming direction.
  71962. */
  71963. direction: Vector3;
  71964. /**
  71965. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71966. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71967. * The HemisphericLight can't cast shadows.
  71968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71969. * @param name The friendly name of the light
  71970. * @param direction The direction of the light reflection
  71971. * @param scene The scene the light belongs to
  71972. */
  71973. constructor(name: string, direction: Vector3, scene: Scene);
  71974. protected _buildUniformLayout(): void;
  71975. /**
  71976. * Returns the string "HemisphericLight".
  71977. * @return The class name
  71978. */
  71979. getClassName(): string;
  71980. /**
  71981. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71982. * Returns the updated direction.
  71983. * @param target The target the direction should point to
  71984. * @return The computed direction
  71985. */
  71986. setDirectionToTarget(target: Vector3): Vector3;
  71987. /**
  71988. * Returns the shadow generator associated to the light.
  71989. * @returns Always null for hemispheric lights because it does not support shadows.
  71990. */
  71991. getShadowGenerator(): Nullable<IShadowGenerator>;
  71992. /**
  71993. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71994. * @param effect The effect to update
  71995. * @param lightIndex The index of the light in the effect to update
  71996. * @returns The hemispheric light
  71997. */
  71998. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71999. /**
  72000. * Computes the world matrix of the node
  72001. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72002. * @param useWasUpdatedFlag defines a reserved property
  72003. * @returns the world matrix
  72004. */
  72005. computeWorldMatrix(): Matrix;
  72006. /**
  72007. * Returns the integer 3.
  72008. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72009. */
  72010. getTypeID(): number;
  72011. /**
  72012. * Prepares the list of defines specific to the light type.
  72013. * @param defines the list of defines
  72014. * @param lightIndex defines the index of the light for the effect
  72015. */
  72016. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72017. }
  72018. }
  72019. declare module BABYLON {
  72020. /** @hidden */
  72021. export var vrMultiviewToSingleviewPixelShader: {
  72022. name: string;
  72023. shader: string;
  72024. };
  72025. }
  72026. declare module BABYLON {
  72027. /**
  72028. * Renders to multiple views with a single draw call
  72029. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72030. */
  72031. export class MultiviewRenderTarget extends RenderTargetTexture {
  72032. /**
  72033. * Creates a multiview render target
  72034. * @param scene scene used with the render target
  72035. * @param size the size of the render target (used for each view)
  72036. */
  72037. constructor(scene: Scene, size?: number | {
  72038. width: number;
  72039. height: number;
  72040. } | {
  72041. ratio: number;
  72042. });
  72043. /**
  72044. * @hidden
  72045. * @param faceIndex the face index, if its a cube texture
  72046. */
  72047. _bindFrameBuffer(faceIndex?: number): void;
  72048. /**
  72049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72050. * @returns the view count
  72051. */
  72052. getViewCount(): number;
  72053. }
  72054. }
  72055. declare module BABYLON {
  72056. interface Engine {
  72057. /**
  72058. * Creates a new multiview render target
  72059. * @param width defines the width of the texture
  72060. * @param height defines the height of the texture
  72061. * @returns the created multiview texture
  72062. */
  72063. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72064. /**
  72065. * Binds a multiview framebuffer to be drawn to
  72066. * @param multiviewTexture texture to bind
  72067. */
  72068. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72069. }
  72070. interface Camera {
  72071. /**
  72072. * @hidden
  72073. * 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)
  72074. */
  72075. _useMultiviewToSingleView: boolean;
  72076. /**
  72077. * @hidden
  72078. * 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)
  72079. */
  72080. _multiviewTexture: Nullable<RenderTargetTexture>;
  72081. /**
  72082. * @hidden
  72083. * ensures the multiview texture of the camera exists and has the specified width/height
  72084. * @param width height to set on the multiview texture
  72085. * @param height width to set on the multiview texture
  72086. */
  72087. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72088. }
  72089. interface Scene {
  72090. /** @hidden */
  72091. _transformMatrixR: Matrix;
  72092. /** @hidden */
  72093. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72094. /** @hidden */
  72095. _createMultiviewUbo(): void;
  72096. /** @hidden */
  72097. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72098. /** @hidden */
  72099. _renderMultiviewToSingleView(camera: Camera): void;
  72100. }
  72101. }
  72102. declare module BABYLON {
  72103. /**
  72104. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72105. * This will not be used for webXR as it supports displaying texture arrays directly
  72106. */
  72107. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72108. /**
  72109. * Initializes a VRMultiviewToSingleview
  72110. * @param name name of the post process
  72111. * @param camera camera to be applied to
  72112. * @param scaleFactor scaling factor to the size of the output texture
  72113. */
  72114. constructor(name: string, camera: Camera, scaleFactor: number);
  72115. }
  72116. }
  72117. declare module BABYLON {
  72118. /**
  72119. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72120. * IMPORTANT!! The data is right-hand data.
  72121. * @export
  72122. * @interface DevicePose
  72123. */
  72124. export interface DevicePose {
  72125. /**
  72126. * The position of the device, values in array are [x,y,z].
  72127. */
  72128. readonly position: Nullable<Float32Array>;
  72129. /**
  72130. * The linearVelocity of the device, values in array are [x,y,z].
  72131. */
  72132. readonly linearVelocity: Nullable<Float32Array>;
  72133. /**
  72134. * The linearAcceleration of the device, values in array are [x,y,z].
  72135. */
  72136. readonly linearAcceleration: Nullable<Float32Array>;
  72137. /**
  72138. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72139. */
  72140. readonly orientation: Nullable<Float32Array>;
  72141. /**
  72142. * The angularVelocity of the device, values in array are [x,y,z].
  72143. */
  72144. readonly angularVelocity: Nullable<Float32Array>;
  72145. /**
  72146. * The angularAcceleration of the device, values in array are [x,y,z].
  72147. */
  72148. readonly angularAcceleration: Nullable<Float32Array>;
  72149. }
  72150. /**
  72151. * Interface representing a pose controlled object in Babylon.
  72152. * A pose controlled object has both regular pose values as well as pose values
  72153. * from an external device such as a VR head mounted display
  72154. */
  72155. export interface PoseControlled {
  72156. /**
  72157. * The position of the object in babylon space.
  72158. */
  72159. position: Vector3;
  72160. /**
  72161. * The rotation quaternion of the object in babylon space.
  72162. */
  72163. rotationQuaternion: Quaternion;
  72164. /**
  72165. * The position of the device in babylon space.
  72166. */
  72167. devicePosition?: Vector3;
  72168. /**
  72169. * The rotation quaternion of the device in babylon space.
  72170. */
  72171. deviceRotationQuaternion: Quaternion;
  72172. /**
  72173. * The raw pose coming from the device.
  72174. */
  72175. rawPose: Nullable<DevicePose>;
  72176. /**
  72177. * The scale of the device to be used when translating from device space to babylon space.
  72178. */
  72179. deviceScaleFactor: number;
  72180. /**
  72181. * Updates the poseControlled values based on the input device pose.
  72182. * @param poseData the pose data to update the object with
  72183. */
  72184. updateFromDevice(poseData: DevicePose): void;
  72185. }
  72186. /**
  72187. * Set of options to customize the webVRCamera
  72188. */
  72189. export interface WebVROptions {
  72190. /**
  72191. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72192. */
  72193. trackPosition?: boolean;
  72194. /**
  72195. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72196. */
  72197. positionScale?: number;
  72198. /**
  72199. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72200. */
  72201. displayName?: string;
  72202. /**
  72203. * Should the native controller meshes be initialized. (default: true)
  72204. */
  72205. controllerMeshes?: boolean;
  72206. /**
  72207. * Creating a default HemiLight only on controllers. (default: true)
  72208. */
  72209. defaultLightingOnControllers?: boolean;
  72210. /**
  72211. * If you don't want to use the default VR button of the helper. (default: false)
  72212. */
  72213. useCustomVRButton?: boolean;
  72214. /**
  72215. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72216. */
  72217. customVRButton?: HTMLButtonElement;
  72218. /**
  72219. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72220. */
  72221. rayLength?: number;
  72222. /**
  72223. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72224. */
  72225. defaultHeight?: number;
  72226. /**
  72227. * If multiview should be used if availible (default: false)
  72228. */
  72229. useMultiview?: boolean;
  72230. }
  72231. /**
  72232. * This represents a WebVR camera.
  72233. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72234. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72235. */
  72236. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72237. private webVROptions;
  72238. /**
  72239. * @hidden
  72240. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72241. */
  72242. _vrDevice: any;
  72243. /**
  72244. * The rawPose of the vrDevice.
  72245. */
  72246. rawPose: Nullable<DevicePose>;
  72247. private _onVREnabled;
  72248. private _specsVersion;
  72249. private _attached;
  72250. private _frameData;
  72251. protected _descendants: Array<Node>;
  72252. private _deviceRoomPosition;
  72253. /** @hidden */
  72254. _deviceRoomRotationQuaternion: Quaternion;
  72255. private _standingMatrix;
  72256. /**
  72257. * Represents device position in babylon space.
  72258. */
  72259. devicePosition: Vector3;
  72260. /**
  72261. * Represents device rotation in babylon space.
  72262. */
  72263. deviceRotationQuaternion: Quaternion;
  72264. /**
  72265. * The scale of the device to be used when translating from device space to babylon space.
  72266. */
  72267. deviceScaleFactor: number;
  72268. private _deviceToWorld;
  72269. private _worldToDevice;
  72270. /**
  72271. * References to the webVR controllers for the vrDevice.
  72272. */
  72273. controllers: Array<WebVRController>;
  72274. /**
  72275. * Emits an event when a controller is attached.
  72276. */
  72277. onControllersAttachedObservable: Observable<WebVRController[]>;
  72278. /**
  72279. * Emits an event when a controller's mesh has been loaded;
  72280. */
  72281. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72282. /**
  72283. * Emits an event when the HMD's pose has been updated.
  72284. */
  72285. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72286. private _poseSet;
  72287. /**
  72288. * If the rig cameras be used as parent instead of this camera.
  72289. */
  72290. rigParenting: boolean;
  72291. private _lightOnControllers;
  72292. private _defaultHeight?;
  72293. /**
  72294. * Instantiates a WebVRFreeCamera.
  72295. * @param name The name of the WebVRFreeCamera
  72296. * @param position The starting anchor position for the camera
  72297. * @param scene The scene the camera belongs to
  72298. * @param webVROptions a set of customizable options for the webVRCamera
  72299. */
  72300. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72301. /**
  72302. * Gets the device distance from the ground in meters.
  72303. * @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.
  72304. */
  72305. deviceDistanceToRoomGround(): number;
  72306. /**
  72307. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72308. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72309. */
  72310. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72311. /**
  72312. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72313. * @returns A promise with a boolean set to if the standing matrix is supported.
  72314. */
  72315. useStandingMatrixAsync(): Promise<boolean>;
  72316. /**
  72317. * Disposes the camera
  72318. */
  72319. dispose(): void;
  72320. /**
  72321. * Gets a vrController by name.
  72322. * @param name The name of the controller to retreive
  72323. * @returns the controller matching the name specified or null if not found
  72324. */
  72325. getControllerByName(name: string): Nullable<WebVRController>;
  72326. private _leftController;
  72327. /**
  72328. * The controller corrisponding to the users left hand.
  72329. */
  72330. readonly leftController: Nullable<WebVRController>;
  72331. private _rightController;
  72332. /**
  72333. * The controller corrisponding to the users right hand.
  72334. */
  72335. readonly rightController: Nullable<WebVRController>;
  72336. /**
  72337. * Casts a ray forward from the vrCamera's gaze.
  72338. * @param length Length of the ray (default: 100)
  72339. * @returns the ray corrisponding to the gaze
  72340. */
  72341. getForwardRay(length?: number): Ray;
  72342. /**
  72343. * @hidden
  72344. * Updates the camera based on device's frame data
  72345. */
  72346. _checkInputs(): void;
  72347. /**
  72348. * Updates the poseControlled values based on the input device pose.
  72349. * @param poseData Pose coming from the device
  72350. */
  72351. updateFromDevice(poseData: DevicePose): void;
  72352. private _htmlElementAttached;
  72353. private _detachIfAttached;
  72354. /**
  72355. * WebVR's attach control will start broadcasting frames to the device.
  72356. * Note that in certain browsers (chrome for example) this function must be called
  72357. * within a user-interaction callback. Example:
  72358. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72359. *
  72360. * @param element html element to attach the vrDevice to
  72361. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72362. */
  72363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72364. /**
  72365. * Detaches the camera from the html element and disables VR
  72366. *
  72367. * @param element html element to detach from
  72368. */
  72369. detachControl(element: HTMLElement): void;
  72370. /**
  72371. * @returns the name of this class
  72372. */
  72373. getClassName(): string;
  72374. /**
  72375. * Calls resetPose on the vrDisplay
  72376. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72377. */
  72378. resetToCurrentRotation(): void;
  72379. /**
  72380. * @hidden
  72381. * Updates the rig cameras (left and right eye)
  72382. */
  72383. _updateRigCameras(): void;
  72384. private _workingVector;
  72385. private _oneVector;
  72386. private _workingMatrix;
  72387. private updateCacheCalled;
  72388. private _correctPositionIfNotTrackPosition;
  72389. /**
  72390. * @hidden
  72391. * Updates the cached values of the camera
  72392. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72393. */
  72394. _updateCache(ignoreParentClass?: boolean): void;
  72395. /**
  72396. * @hidden
  72397. * Get current device position in babylon world
  72398. */
  72399. _computeDevicePosition(): void;
  72400. /**
  72401. * Updates the current device position and rotation in the babylon world
  72402. */
  72403. update(): void;
  72404. /**
  72405. * @hidden
  72406. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72407. * @returns an identity matrix
  72408. */
  72409. _getViewMatrix(): Matrix;
  72410. private _tmpMatrix;
  72411. /**
  72412. * This function is called by the two RIG cameras.
  72413. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72414. * @hidden
  72415. */
  72416. _getWebVRViewMatrix(): Matrix;
  72417. /** @hidden */
  72418. _getWebVRProjectionMatrix(): Matrix;
  72419. private _onGamepadConnectedObserver;
  72420. private _onGamepadDisconnectedObserver;
  72421. private _updateCacheWhenTrackingDisabledObserver;
  72422. /**
  72423. * Initializes the controllers and their meshes
  72424. */
  72425. initControllers(): void;
  72426. }
  72427. }
  72428. declare module BABYLON {
  72429. /**
  72430. * Size options for a post process
  72431. */
  72432. export type PostProcessOptions = {
  72433. width: number;
  72434. height: number;
  72435. };
  72436. /**
  72437. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72438. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72439. */
  72440. export class PostProcess {
  72441. /** Name of the PostProcess. */
  72442. name: string;
  72443. /**
  72444. * Gets or sets the unique id of the post process
  72445. */
  72446. uniqueId: number;
  72447. /**
  72448. * Width of the texture to apply the post process on
  72449. */
  72450. width: number;
  72451. /**
  72452. * Height of the texture to apply the post process on
  72453. */
  72454. height: number;
  72455. /**
  72456. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72457. * @hidden
  72458. */
  72459. _outputTexture: Nullable<InternalTexture>;
  72460. /**
  72461. * Sampling mode used by the shader
  72462. * See https://doc.babylonjs.com/classes/3.1/texture
  72463. */
  72464. renderTargetSamplingMode: number;
  72465. /**
  72466. * Clear color to use when screen clearing
  72467. */
  72468. clearColor: Color4;
  72469. /**
  72470. * If the buffer needs to be cleared before applying the post process. (default: true)
  72471. * Should be set to false if shader will overwrite all previous pixels.
  72472. */
  72473. autoClear: boolean;
  72474. /**
  72475. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72476. */
  72477. alphaMode: number;
  72478. /**
  72479. * Sets the setAlphaBlendConstants of the babylon engine
  72480. */
  72481. alphaConstants: Color4;
  72482. /**
  72483. * Animations to be used for the post processing
  72484. */
  72485. animations: Animation[];
  72486. /**
  72487. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72488. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72489. */
  72490. enablePixelPerfectMode: boolean;
  72491. /**
  72492. * Force the postprocess to be applied without taking in account viewport
  72493. */
  72494. forceFullscreenViewport: boolean;
  72495. /**
  72496. * List of inspectable custom properties (used by the Inspector)
  72497. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72498. */
  72499. inspectableCustomProperties: IInspectable[];
  72500. /**
  72501. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72502. *
  72503. * | Value | Type | Description |
  72504. * | ----- | ----------------------------------- | ----------- |
  72505. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72506. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72507. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72508. *
  72509. */
  72510. scaleMode: number;
  72511. /**
  72512. * Force textures to be a power of two (default: false)
  72513. */
  72514. alwaysForcePOT: boolean;
  72515. private _samples;
  72516. /**
  72517. * Number of sample textures (default: 1)
  72518. */
  72519. samples: number;
  72520. /**
  72521. * Modify the scale of the post process to be the same as the viewport (default: false)
  72522. */
  72523. adaptScaleToCurrentViewport: boolean;
  72524. private _camera;
  72525. private _scene;
  72526. private _engine;
  72527. private _options;
  72528. private _reusable;
  72529. private _textureType;
  72530. /**
  72531. * Smart array of input and output textures for the post process.
  72532. * @hidden
  72533. */
  72534. _textures: SmartArray<InternalTexture>;
  72535. /**
  72536. * The index in _textures that corresponds to the output texture.
  72537. * @hidden
  72538. */
  72539. _currentRenderTextureInd: number;
  72540. private _effect;
  72541. private _samplers;
  72542. private _fragmentUrl;
  72543. private _vertexUrl;
  72544. private _parameters;
  72545. private _scaleRatio;
  72546. protected _indexParameters: any;
  72547. private _shareOutputWithPostProcess;
  72548. private _texelSize;
  72549. private _forcedOutputTexture;
  72550. /**
  72551. * Returns the fragment url or shader name used in the post process.
  72552. * @returns the fragment url or name in the shader store.
  72553. */
  72554. getEffectName(): string;
  72555. /**
  72556. * An event triggered when the postprocess is activated.
  72557. */
  72558. onActivateObservable: Observable<Camera>;
  72559. private _onActivateObserver;
  72560. /**
  72561. * A function that is added to the onActivateObservable
  72562. */
  72563. onActivate: Nullable<(camera: Camera) => void>;
  72564. /**
  72565. * An event triggered when the postprocess changes its size.
  72566. */
  72567. onSizeChangedObservable: Observable<PostProcess>;
  72568. private _onSizeChangedObserver;
  72569. /**
  72570. * A function that is added to the onSizeChangedObservable
  72571. */
  72572. onSizeChanged: (postProcess: PostProcess) => void;
  72573. /**
  72574. * An event triggered when the postprocess applies its effect.
  72575. */
  72576. onApplyObservable: Observable<Effect>;
  72577. private _onApplyObserver;
  72578. /**
  72579. * A function that is added to the onApplyObservable
  72580. */
  72581. onApply: (effect: Effect) => void;
  72582. /**
  72583. * An event triggered before rendering the postprocess
  72584. */
  72585. onBeforeRenderObservable: Observable<Effect>;
  72586. private _onBeforeRenderObserver;
  72587. /**
  72588. * A function that is added to the onBeforeRenderObservable
  72589. */
  72590. onBeforeRender: (effect: Effect) => void;
  72591. /**
  72592. * An event triggered after rendering the postprocess
  72593. */
  72594. onAfterRenderObservable: Observable<Effect>;
  72595. private _onAfterRenderObserver;
  72596. /**
  72597. * A function that is added to the onAfterRenderObservable
  72598. */
  72599. onAfterRender: (efect: Effect) => void;
  72600. /**
  72601. * 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
  72602. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72603. */
  72604. inputTexture: InternalTexture;
  72605. /**
  72606. * Gets the camera which post process is applied to.
  72607. * @returns The camera the post process is applied to.
  72608. */
  72609. getCamera(): Camera;
  72610. /**
  72611. * Gets the texel size of the postprocess.
  72612. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72613. */
  72614. readonly texelSize: Vector2;
  72615. /**
  72616. * Creates a new instance PostProcess
  72617. * @param name The name of the PostProcess.
  72618. * @param fragmentUrl The url of the fragment shader to be used.
  72619. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72620. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72621. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72622. * @param camera The camera to apply the render pass to.
  72623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72624. * @param engine The engine which the post process will be applied. (default: current engine)
  72625. * @param reusable If the post process can be reused on the same frame. (default: false)
  72626. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72627. * @param textureType Type of textures used when performing the post process. (default: 0)
  72628. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72629. * @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
  72630. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72631. */
  72632. constructor(
  72633. /** Name of the PostProcess. */
  72634. 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);
  72635. /**
  72636. * Gets a string idenfifying the name of the class
  72637. * @returns "PostProcess" string
  72638. */
  72639. getClassName(): string;
  72640. /**
  72641. * Gets the engine which this post process belongs to.
  72642. * @returns The engine the post process was enabled with.
  72643. */
  72644. getEngine(): Engine;
  72645. /**
  72646. * The effect that is created when initializing the post process.
  72647. * @returns The created effect corrisponding the the postprocess.
  72648. */
  72649. getEffect(): Effect;
  72650. /**
  72651. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72652. * @param postProcess The post process to share the output with.
  72653. * @returns This post process.
  72654. */
  72655. shareOutputWith(postProcess: PostProcess): PostProcess;
  72656. /**
  72657. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72658. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72659. */
  72660. useOwnOutput(): void;
  72661. /**
  72662. * Updates the effect with the current post process compile time values and recompiles the shader.
  72663. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72664. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72665. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72666. * @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
  72667. * @param onCompiled Called when the shader has been compiled.
  72668. * @param onError Called if there is an error when compiling a shader.
  72669. */
  72670. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72671. /**
  72672. * The post process is reusable if it can be used multiple times within one frame.
  72673. * @returns If the post process is reusable
  72674. */
  72675. isReusable(): boolean;
  72676. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72677. markTextureDirty(): void;
  72678. /**
  72679. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72680. * 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.
  72681. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72682. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72683. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72684. * @returns The target texture that was bound to be written to.
  72685. */
  72686. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72687. /**
  72688. * If the post process is supported.
  72689. */
  72690. readonly isSupported: boolean;
  72691. /**
  72692. * The aspect ratio of the output texture.
  72693. */
  72694. readonly aspectRatio: number;
  72695. /**
  72696. * Get a value indicating if the post-process is ready to be used
  72697. * @returns true if the post-process is ready (shader is compiled)
  72698. */
  72699. isReady(): boolean;
  72700. /**
  72701. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72702. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72703. */
  72704. apply(): Nullable<Effect>;
  72705. private _disposeTextures;
  72706. /**
  72707. * Disposes the post process.
  72708. * @param camera The camera to dispose the post process on.
  72709. */
  72710. dispose(camera?: Camera): void;
  72711. }
  72712. }
  72713. declare module BABYLON {
  72714. /**
  72715. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72716. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72717. */
  72718. export class PostProcessManager {
  72719. private _scene;
  72720. private _indexBuffer;
  72721. private _vertexBuffers;
  72722. /**
  72723. * Creates a new instance PostProcess
  72724. * @param scene The scene that the post process is associated with.
  72725. */
  72726. constructor(scene: Scene);
  72727. private _prepareBuffers;
  72728. private _buildIndexBuffer;
  72729. /**
  72730. * Rebuilds the vertex buffers of the manager.
  72731. * @hidden
  72732. */
  72733. _rebuild(): void;
  72734. /**
  72735. * Prepares a frame to be run through a post process.
  72736. * @param sourceTexture The input texture to the post procesess. (default: null)
  72737. * @param postProcesses An array of post processes to be run. (default: null)
  72738. * @returns True if the post processes were able to be run.
  72739. * @hidden
  72740. */
  72741. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72742. /**
  72743. * Manually render a set of post processes to a texture.
  72744. * @param postProcesses An array of post processes to be run.
  72745. * @param targetTexture The target texture to render to.
  72746. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72747. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72748. * @param lodLevel defines which lod of the texture to render to
  72749. */
  72750. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72751. /**
  72752. * Finalize the result of the output of the postprocesses.
  72753. * @param doNotPresent If true the result will not be displayed to the screen.
  72754. * @param targetTexture The target texture to render to.
  72755. * @param faceIndex The index of the face to bind the target texture to.
  72756. * @param postProcesses The array of post processes to render.
  72757. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72758. * @hidden
  72759. */
  72760. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72761. /**
  72762. * Disposes of the post process manager.
  72763. */
  72764. dispose(): void;
  72765. }
  72766. }
  72767. declare module BABYLON {
  72768. interface AbstractScene {
  72769. /**
  72770. * The list of layers (background and foreground) of the scene
  72771. */
  72772. layers: Array<Layer>;
  72773. }
  72774. /**
  72775. * Defines the layer scene component responsible to manage any layers
  72776. * in a given scene.
  72777. */
  72778. export class LayerSceneComponent implements ISceneComponent {
  72779. /**
  72780. * The component name helpfull to identify the component in the list of scene components.
  72781. */
  72782. readonly name: string;
  72783. /**
  72784. * The scene the component belongs to.
  72785. */
  72786. scene: Scene;
  72787. private _engine;
  72788. /**
  72789. * Creates a new instance of the component for the given scene
  72790. * @param scene Defines the scene to register the component in
  72791. */
  72792. constructor(scene: Scene);
  72793. /**
  72794. * Registers the component in a given scene
  72795. */
  72796. register(): void;
  72797. /**
  72798. * Rebuilds the elements related to this component in case of
  72799. * context lost for instance.
  72800. */
  72801. rebuild(): void;
  72802. /**
  72803. * Disposes the component and the associated ressources.
  72804. */
  72805. dispose(): void;
  72806. private _draw;
  72807. private _drawCameraPredicate;
  72808. private _drawCameraBackground;
  72809. private _drawCameraForeground;
  72810. private _drawRenderTargetPredicate;
  72811. private _drawRenderTargetBackground;
  72812. private _drawRenderTargetForeground;
  72813. }
  72814. }
  72815. declare module BABYLON {
  72816. /** @hidden */
  72817. export var layerPixelShader: {
  72818. name: string;
  72819. shader: string;
  72820. };
  72821. }
  72822. declare module BABYLON {
  72823. /** @hidden */
  72824. export var layerVertexShader: {
  72825. name: string;
  72826. shader: string;
  72827. };
  72828. }
  72829. declare module BABYLON {
  72830. /**
  72831. * This represents a full screen 2d layer.
  72832. * This can be useful to display a picture in the background of your scene for instance.
  72833. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72834. */
  72835. export class Layer {
  72836. /**
  72837. * Define the name of the layer.
  72838. */
  72839. name: string;
  72840. /**
  72841. * Define the texture the layer should display.
  72842. */
  72843. texture: Nullable<Texture>;
  72844. /**
  72845. * Is the layer in background or foreground.
  72846. */
  72847. isBackground: boolean;
  72848. /**
  72849. * Define the color of the layer (instead of texture).
  72850. */
  72851. color: Color4;
  72852. /**
  72853. * Define the scale of the layer in order to zoom in out of the texture.
  72854. */
  72855. scale: Vector2;
  72856. /**
  72857. * Define an offset for the layer in order to shift the texture.
  72858. */
  72859. offset: Vector2;
  72860. /**
  72861. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72862. */
  72863. alphaBlendingMode: number;
  72864. /**
  72865. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72866. * Alpha test will not mix with the background color in case of transparency.
  72867. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72868. */
  72869. alphaTest: boolean;
  72870. /**
  72871. * Define a mask to restrict the layer to only some of the scene cameras.
  72872. */
  72873. layerMask: number;
  72874. /**
  72875. * Define the list of render target the layer is visible into.
  72876. */
  72877. renderTargetTextures: RenderTargetTexture[];
  72878. /**
  72879. * Define if the layer is only used in renderTarget or if it also
  72880. * renders in the main frame buffer of the canvas.
  72881. */
  72882. renderOnlyInRenderTargetTextures: boolean;
  72883. private _scene;
  72884. private _vertexBuffers;
  72885. private _indexBuffer;
  72886. private _effect;
  72887. private _alphaTestEffect;
  72888. /**
  72889. * An event triggered when the layer is disposed.
  72890. */
  72891. onDisposeObservable: Observable<Layer>;
  72892. private _onDisposeObserver;
  72893. /**
  72894. * Back compatibility with callback before the onDisposeObservable existed.
  72895. * The set callback will be triggered when the layer has been disposed.
  72896. */
  72897. onDispose: () => void;
  72898. /**
  72899. * An event triggered before rendering the scene
  72900. */
  72901. onBeforeRenderObservable: Observable<Layer>;
  72902. private _onBeforeRenderObserver;
  72903. /**
  72904. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72905. * The set callback will be triggered just before rendering the layer.
  72906. */
  72907. onBeforeRender: () => void;
  72908. /**
  72909. * An event triggered after rendering the scene
  72910. */
  72911. onAfterRenderObservable: Observable<Layer>;
  72912. private _onAfterRenderObserver;
  72913. /**
  72914. * Back compatibility with callback before the onAfterRenderObservable existed.
  72915. * The set callback will be triggered just after rendering the layer.
  72916. */
  72917. onAfterRender: () => void;
  72918. /**
  72919. * Instantiates a new layer.
  72920. * This represents a full screen 2d layer.
  72921. * This can be useful to display a picture in the background of your scene for instance.
  72922. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72923. * @param name Define the name of the layer in the scene
  72924. * @param imgUrl Define the url of the texture to display in the layer
  72925. * @param scene Define the scene the layer belongs to
  72926. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72927. * @param color Defines a color for the layer
  72928. */
  72929. constructor(
  72930. /**
  72931. * Define the name of the layer.
  72932. */
  72933. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72934. private _createIndexBuffer;
  72935. /** @hidden */
  72936. _rebuild(): void;
  72937. /**
  72938. * Renders the layer in the scene.
  72939. */
  72940. render(): void;
  72941. /**
  72942. * Disposes and releases the associated ressources.
  72943. */
  72944. dispose(): void;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. interface AbstractScene {
  72949. /**
  72950. * The list of procedural textures added to the scene
  72951. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72952. */
  72953. proceduralTextures: Array<ProceduralTexture>;
  72954. }
  72955. /**
  72956. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72957. * in a given scene.
  72958. */
  72959. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72960. /**
  72961. * The component name helpfull to identify the component in the list of scene components.
  72962. */
  72963. readonly name: string;
  72964. /**
  72965. * The scene the component belongs to.
  72966. */
  72967. scene: Scene;
  72968. /**
  72969. * Creates a new instance of the component for the given scene
  72970. * @param scene Defines the scene to register the component in
  72971. */
  72972. constructor(scene: Scene);
  72973. /**
  72974. * Registers the component in a given scene
  72975. */
  72976. register(): void;
  72977. /**
  72978. * Rebuilds the elements related to this component in case of
  72979. * context lost for instance.
  72980. */
  72981. rebuild(): void;
  72982. /**
  72983. * Disposes the component and the associated ressources.
  72984. */
  72985. dispose(): void;
  72986. private _beforeClear;
  72987. }
  72988. }
  72989. declare module BABYLON {
  72990. /** @hidden */
  72991. export var proceduralVertexShader: {
  72992. name: string;
  72993. shader: string;
  72994. };
  72995. }
  72996. declare module BABYLON {
  72997. /**
  72998. * 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.
  72999. * This is the base class of any Procedural texture and contains most of the shareable code.
  73000. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73001. */
  73002. export class ProceduralTexture extends Texture {
  73003. isCube: boolean;
  73004. /**
  73005. * Define if the texture is enabled or not (disabled texture will not render)
  73006. */
  73007. isEnabled: boolean;
  73008. /**
  73009. * Define if the texture must be cleared before rendering (default is true)
  73010. */
  73011. autoClear: boolean;
  73012. /**
  73013. * Callback called when the texture is generated
  73014. */
  73015. onGenerated: () => void;
  73016. /**
  73017. * Event raised when the texture is generated
  73018. */
  73019. onGeneratedObservable: Observable<ProceduralTexture>;
  73020. /** @hidden */
  73021. _generateMipMaps: boolean;
  73022. /** @hidden **/
  73023. _effect: Effect;
  73024. /** @hidden */
  73025. _textures: {
  73026. [key: string]: Texture;
  73027. };
  73028. private _size;
  73029. private _currentRefreshId;
  73030. private _refreshRate;
  73031. private _vertexBuffers;
  73032. private _indexBuffer;
  73033. private _uniforms;
  73034. private _samplers;
  73035. private _fragment;
  73036. private _floats;
  73037. private _ints;
  73038. private _floatsArrays;
  73039. private _colors3;
  73040. private _colors4;
  73041. private _vectors2;
  73042. private _vectors3;
  73043. private _matrices;
  73044. private _fallbackTexture;
  73045. private _fallbackTextureUsed;
  73046. private _engine;
  73047. private _cachedDefines;
  73048. private _contentUpdateId;
  73049. private _contentData;
  73050. /**
  73051. * Instantiates a new procedural texture.
  73052. * 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.
  73053. * This is the base class of any Procedural texture and contains most of the shareable code.
  73054. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73055. * @param name Define the name of the texture
  73056. * @param size Define the size of the texture to create
  73057. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73058. * @param scene Define the scene the texture belongs to
  73059. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73060. * @param generateMipMaps Define if the texture should creates mip maps or not
  73061. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73062. */
  73063. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73064. /**
  73065. * The effect that is created when initializing the post process.
  73066. * @returns The created effect corrisponding the the postprocess.
  73067. */
  73068. getEffect(): Effect;
  73069. /**
  73070. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73071. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73072. */
  73073. getContent(): Nullable<ArrayBufferView>;
  73074. private _createIndexBuffer;
  73075. /** @hidden */
  73076. _rebuild(): void;
  73077. /**
  73078. * Resets the texture in order to recreate its associated resources.
  73079. * This can be called in case of context loss
  73080. */
  73081. reset(): void;
  73082. protected _getDefines(): string;
  73083. /**
  73084. * Is the texture ready to be used ? (rendered at least once)
  73085. * @returns true if ready, otherwise, false.
  73086. */
  73087. isReady(): boolean;
  73088. /**
  73089. * Resets the refresh counter of the texture and start bak from scratch.
  73090. * Could be useful to regenerate the texture if it is setup to render only once.
  73091. */
  73092. resetRefreshCounter(): void;
  73093. /**
  73094. * Set the fragment shader to use in order to render the texture.
  73095. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73096. */
  73097. setFragment(fragment: any): void;
  73098. /**
  73099. * Define the refresh rate of the texture or the rendering frequency.
  73100. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73101. */
  73102. refreshRate: number;
  73103. /** @hidden */
  73104. _shouldRender(): boolean;
  73105. /**
  73106. * Get the size the texture is rendering at.
  73107. * @returns the size (texture is always squared)
  73108. */
  73109. getRenderSize(): number;
  73110. /**
  73111. * Resize the texture to new value.
  73112. * @param size Define the new size the texture should have
  73113. * @param generateMipMaps Define whether the new texture should create mip maps
  73114. */
  73115. resize(size: number, generateMipMaps: boolean): void;
  73116. private _checkUniform;
  73117. /**
  73118. * Set a texture in the shader program used to render.
  73119. * @param name Define the name of the uniform samplers as defined in the shader
  73120. * @param texture Define the texture to bind to this sampler
  73121. * @return the texture itself allowing "fluent" like uniform updates
  73122. */
  73123. setTexture(name: string, texture: Texture): ProceduralTexture;
  73124. /**
  73125. * Set a float in the shader.
  73126. * @param name Define the name of the uniform as defined in the shader
  73127. * @param value Define the value to give to the uniform
  73128. * @return the texture itself allowing "fluent" like uniform updates
  73129. */
  73130. setFloat(name: string, value: number): ProceduralTexture;
  73131. /**
  73132. * Set a int in the shader.
  73133. * @param name Define the name of the uniform as defined in the shader
  73134. * @param value Define the value to give to the uniform
  73135. * @return the texture itself allowing "fluent" like uniform updates
  73136. */
  73137. setInt(name: string, value: number): ProceduralTexture;
  73138. /**
  73139. * Set an array of floats in the shader.
  73140. * @param name Define the name of the uniform as defined in the shader
  73141. * @param value Define the value to give to the uniform
  73142. * @return the texture itself allowing "fluent" like uniform updates
  73143. */
  73144. setFloats(name: string, value: number[]): ProceduralTexture;
  73145. /**
  73146. * Set a vec3 in the shader from a Color3.
  73147. * @param name Define the name of the uniform as defined in the shader
  73148. * @param value Define the value to give to the uniform
  73149. * @return the texture itself allowing "fluent" like uniform updates
  73150. */
  73151. setColor3(name: string, value: Color3): ProceduralTexture;
  73152. /**
  73153. * Set a vec4 in the shader from a Color4.
  73154. * @param name Define the name of the uniform as defined in the shader
  73155. * @param value Define the value to give to the uniform
  73156. * @return the texture itself allowing "fluent" like uniform updates
  73157. */
  73158. setColor4(name: string, value: Color4): ProceduralTexture;
  73159. /**
  73160. * Set a vec2 in the shader from a Vector2.
  73161. * @param name Define the name of the uniform as defined in the shader
  73162. * @param value Define the value to give to the uniform
  73163. * @return the texture itself allowing "fluent" like uniform updates
  73164. */
  73165. setVector2(name: string, value: Vector2): ProceduralTexture;
  73166. /**
  73167. * Set a vec3 in the shader from a Vector3.
  73168. * @param name Define the name of the uniform as defined in the shader
  73169. * @param value Define the value to give to the uniform
  73170. * @return the texture itself allowing "fluent" like uniform updates
  73171. */
  73172. setVector3(name: string, value: Vector3): ProceduralTexture;
  73173. /**
  73174. * Set a mat4 in the shader from a MAtrix.
  73175. * @param name Define the name of the uniform as defined in the shader
  73176. * @param value Define the value to give to the uniform
  73177. * @return the texture itself allowing "fluent" like uniform updates
  73178. */
  73179. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73180. /**
  73181. * Render the texture to its associated render target.
  73182. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73183. */
  73184. render(useCameraPostProcess?: boolean): void;
  73185. /**
  73186. * Clone the texture.
  73187. * @returns the cloned texture
  73188. */
  73189. clone(): ProceduralTexture;
  73190. /**
  73191. * Dispose the texture and release its asoociated resources.
  73192. */
  73193. dispose(): void;
  73194. }
  73195. }
  73196. declare module BABYLON {
  73197. /**
  73198. * This represents the base class for particle system in Babylon.
  73199. * 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.
  73200. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73201. * @example https://doc.babylonjs.com/babylon101/particles
  73202. */
  73203. export class BaseParticleSystem {
  73204. /**
  73205. * Source color is added to the destination color without alpha affecting the result
  73206. */
  73207. static BLENDMODE_ONEONE: number;
  73208. /**
  73209. * Blend current color and particle color using particle’s alpha
  73210. */
  73211. static BLENDMODE_STANDARD: number;
  73212. /**
  73213. * Add current color and particle color multiplied by particle’s alpha
  73214. */
  73215. static BLENDMODE_ADD: number;
  73216. /**
  73217. * Multiply current color with particle color
  73218. */
  73219. static BLENDMODE_MULTIPLY: number;
  73220. /**
  73221. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73222. */
  73223. static BLENDMODE_MULTIPLYADD: number;
  73224. /**
  73225. * List of animations used by the particle system.
  73226. */
  73227. animations: Animation[];
  73228. /**
  73229. * The id of the Particle system.
  73230. */
  73231. id: string;
  73232. /**
  73233. * The friendly name of the Particle system.
  73234. */
  73235. name: string;
  73236. /**
  73237. * The rendering group used by the Particle system to chose when to render.
  73238. */
  73239. renderingGroupId: number;
  73240. /**
  73241. * The emitter represents the Mesh or position we are attaching the particle system to.
  73242. */
  73243. emitter: Nullable<AbstractMesh | Vector3>;
  73244. /**
  73245. * The maximum number of particles to emit per frame
  73246. */
  73247. emitRate: number;
  73248. /**
  73249. * If you want to launch only a few particles at once, that can be done, as well.
  73250. */
  73251. manualEmitCount: number;
  73252. /**
  73253. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73254. */
  73255. updateSpeed: number;
  73256. /**
  73257. * The amount of time the particle system is running (depends of the overall update speed).
  73258. */
  73259. targetStopDuration: number;
  73260. /**
  73261. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73262. */
  73263. disposeOnStop: boolean;
  73264. /**
  73265. * Minimum power of emitting particles.
  73266. */
  73267. minEmitPower: number;
  73268. /**
  73269. * Maximum power of emitting particles.
  73270. */
  73271. maxEmitPower: number;
  73272. /**
  73273. * Minimum life time of emitting particles.
  73274. */
  73275. minLifeTime: number;
  73276. /**
  73277. * Maximum life time of emitting particles.
  73278. */
  73279. maxLifeTime: number;
  73280. /**
  73281. * Minimum Size of emitting particles.
  73282. */
  73283. minSize: number;
  73284. /**
  73285. * Maximum Size of emitting particles.
  73286. */
  73287. maxSize: number;
  73288. /**
  73289. * Minimum scale of emitting particles on X axis.
  73290. */
  73291. minScaleX: number;
  73292. /**
  73293. * Maximum scale of emitting particles on X axis.
  73294. */
  73295. maxScaleX: number;
  73296. /**
  73297. * Minimum scale of emitting particles on Y axis.
  73298. */
  73299. minScaleY: number;
  73300. /**
  73301. * Maximum scale of emitting particles on Y axis.
  73302. */
  73303. maxScaleY: number;
  73304. /**
  73305. * Gets or sets the minimal initial rotation in radians.
  73306. */
  73307. minInitialRotation: number;
  73308. /**
  73309. * Gets or sets the maximal initial rotation in radians.
  73310. */
  73311. maxInitialRotation: number;
  73312. /**
  73313. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73314. */
  73315. minAngularSpeed: number;
  73316. /**
  73317. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73318. */
  73319. maxAngularSpeed: number;
  73320. /**
  73321. * The texture used to render each particle. (this can be a spritesheet)
  73322. */
  73323. particleTexture: Nullable<Texture>;
  73324. /**
  73325. * The layer mask we are rendering the particles through.
  73326. */
  73327. layerMask: number;
  73328. /**
  73329. * This can help using your own shader to render the particle system.
  73330. * The according effect will be created
  73331. */
  73332. customShader: any;
  73333. /**
  73334. * By default particle system starts as soon as they are created. This prevents the
  73335. * automatic start to happen and let you decide when to start emitting particles.
  73336. */
  73337. preventAutoStart: boolean;
  73338. private _noiseTexture;
  73339. /**
  73340. * Gets or sets a texture used to add random noise to particle positions
  73341. */
  73342. noiseTexture: Nullable<ProceduralTexture>;
  73343. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73344. noiseStrength: Vector3;
  73345. /**
  73346. * Callback triggered when the particle animation is ending.
  73347. */
  73348. onAnimationEnd: Nullable<() => void>;
  73349. /**
  73350. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73351. */
  73352. blendMode: number;
  73353. /**
  73354. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73355. * to override the particles.
  73356. */
  73357. forceDepthWrite: boolean;
  73358. /** 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 */
  73359. preWarmCycles: number;
  73360. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73361. preWarmStepOffset: number;
  73362. /**
  73363. * 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)
  73364. */
  73365. spriteCellChangeSpeed: number;
  73366. /**
  73367. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73368. */
  73369. startSpriteCellID: number;
  73370. /**
  73371. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73372. */
  73373. endSpriteCellID: number;
  73374. /**
  73375. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73376. */
  73377. spriteCellWidth: number;
  73378. /**
  73379. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73380. */
  73381. spriteCellHeight: number;
  73382. /**
  73383. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73384. */
  73385. spriteRandomStartCell: boolean;
  73386. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73387. translationPivot: Vector2;
  73388. /** @hidden */
  73389. protected _isAnimationSheetEnabled: boolean;
  73390. /**
  73391. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73392. */
  73393. beginAnimationOnStart: boolean;
  73394. /**
  73395. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73396. */
  73397. beginAnimationFrom: number;
  73398. /**
  73399. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73400. */
  73401. beginAnimationTo: number;
  73402. /**
  73403. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73404. */
  73405. beginAnimationLoop: boolean;
  73406. /**
  73407. * Gets or sets a world offset applied to all particles
  73408. */
  73409. worldOffset: Vector3;
  73410. /**
  73411. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73412. */
  73413. isAnimationSheetEnabled: boolean;
  73414. /**
  73415. * Get hosting scene
  73416. * @returns the scene
  73417. */
  73418. getScene(): Scene;
  73419. /**
  73420. * You can use gravity if you want to give an orientation to your particles.
  73421. */
  73422. gravity: Vector3;
  73423. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73424. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73425. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73426. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73427. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73428. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73429. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73430. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73431. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73432. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73433. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73434. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73435. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73436. /**
  73437. * Defines the delay in milliseconds before starting the system (0 by default)
  73438. */
  73439. startDelay: number;
  73440. /**
  73441. * Gets the current list of drag gradients.
  73442. * You must use addDragGradient and removeDragGradient to udpate this list
  73443. * @returns the list of drag gradients
  73444. */
  73445. getDragGradients(): Nullable<Array<FactorGradient>>;
  73446. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73447. limitVelocityDamping: number;
  73448. /**
  73449. * Gets the current list of limit velocity gradients.
  73450. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73451. * @returns the list of limit velocity gradients
  73452. */
  73453. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73454. /**
  73455. * Gets the current list of color gradients.
  73456. * You must use addColorGradient and removeColorGradient to udpate this list
  73457. * @returns the list of color gradients
  73458. */
  73459. getColorGradients(): Nullable<Array<ColorGradient>>;
  73460. /**
  73461. * Gets the current list of size gradients.
  73462. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73463. * @returns the list of size gradients
  73464. */
  73465. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73466. /**
  73467. * Gets the current list of color remap gradients.
  73468. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73469. * @returns the list of color remap gradients
  73470. */
  73471. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73472. /**
  73473. * Gets the current list of alpha remap gradients.
  73474. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73475. * @returns the list of alpha remap gradients
  73476. */
  73477. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73478. /**
  73479. * Gets the current list of life time gradients.
  73480. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73481. * @returns the list of life time gradients
  73482. */
  73483. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73484. /**
  73485. * Gets the current list of angular speed gradients.
  73486. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73487. * @returns the list of angular speed gradients
  73488. */
  73489. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73490. /**
  73491. * Gets the current list of velocity gradients.
  73492. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73493. * @returns the list of velocity gradients
  73494. */
  73495. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73496. /**
  73497. * Gets the current list of start size gradients.
  73498. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73499. * @returns the list of start size gradients
  73500. */
  73501. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73502. /**
  73503. * Gets the current list of emit rate gradients.
  73504. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73505. * @returns the list of emit rate gradients
  73506. */
  73507. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73508. /**
  73509. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73510. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73511. */
  73512. direction1: Vector3;
  73513. /**
  73514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73515. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73516. */
  73517. direction2: Vector3;
  73518. /**
  73519. * 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.
  73520. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73521. */
  73522. minEmitBox: Vector3;
  73523. /**
  73524. * 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.
  73525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73526. */
  73527. maxEmitBox: Vector3;
  73528. /**
  73529. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73530. */
  73531. color1: Color4;
  73532. /**
  73533. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73534. */
  73535. color2: Color4;
  73536. /**
  73537. * Color the particle will have at the end of its lifetime
  73538. */
  73539. colorDead: Color4;
  73540. /**
  73541. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73542. */
  73543. textureMask: Color4;
  73544. /**
  73545. * The particle emitter type defines the emitter used by the particle system.
  73546. * It can be for example box, sphere, or cone...
  73547. */
  73548. particleEmitterType: IParticleEmitterType;
  73549. /** @hidden */
  73550. _isSubEmitter: boolean;
  73551. /**
  73552. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73553. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73554. */
  73555. billboardMode: number;
  73556. protected _isBillboardBased: boolean;
  73557. /**
  73558. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73559. */
  73560. isBillboardBased: boolean;
  73561. /**
  73562. * The scene the particle system belongs to.
  73563. */
  73564. protected _scene: Scene;
  73565. /**
  73566. * Local cache of defines for image processing.
  73567. */
  73568. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73569. /**
  73570. * Default configuration related to image processing available in the standard Material.
  73571. */
  73572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73573. /**
  73574. * Gets the image processing configuration used either in this material.
  73575. */
  73576. /**
  73577. * Sets the Default image processing configuration used either in the this material.
  73578. *
  73579. * If sets to null, the scene one is in use.
  73580. */
  73581. imageProcessingConfiguration: ImageProcessingConfiguration;
  73582. /**
  73583. * Attaches a new image processing configuration to the Standard Material.
  73584. * @param configuration
  73585. */
  73586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73587. /** @hidden */
  73588. protected _reset(): void;
  73589. /** @hidden */
  73590. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73591. /**
  73592. * Instantiates a particle system.
  73593. * 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.
  73594. * @param name The name of the particle system
  73595. */
  73596. constructor(name: string);
  73597. /**
  73598. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73601. * @returns the emitter
  73602. */
  73603. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73604. /**
  73605. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73606. * @param radius The radius of the hemisphere to emit from
  73607. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73608. * @returns the emitter
  73609. */
  73610. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73611. /**
  73612. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73613. * @param radius The radius of the sphere to emit from
  73614. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73615. * @returns the emitter
  73616. */
  73617. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73618. /**
  73619. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73620. * @param radius The radius of the sphere to emit from
  73621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73623. * @returns the emitter
  73624. */
  73625. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73626. /**
  73627. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73628. * @param radius The radius of the emission cylinder
  73629. * @param height The height of the emission cylinder
  73630. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73631. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73632. * @returns the emitter
  73633. */
  73634. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73635. /**
  73636. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73637. * @param radius The radius of the cylinder to emit from
  73638. * @param height The height of the emission cylinder
  73639. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73640. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73641. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73642. * @returns the emitter
  73643. */
  73644. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73645. /**
  73646. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73647. * @param radius The radius of the cone to emit from
  73648. * @param angle The base angle of the cone
  73649. * @returns the emitter
  73650. */
  73651. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73652. /**
  73653. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73656. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73657. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73658. * @returns the emitter
  73659. */
  73660. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73661. }
  73662. }
  73663. declare module BABYLON {
  73664. /**
  73665. * Type of sub emitter
  73666. */
  73667. export enum SubEmitterType {
  73668. /**
  73669. * Attached to the particle over it's lifetime
  73670. */
  73671. ATTACHED = 0,
  73672. /**
  73673. * Created when the particle dies
  73674. */
  73675. END = 1
  73676. }
  73677. /**
  73678. * Sub emitter class used to emit particles from an existing particle
  73679. */
  73680. export class SubEmitter {
  73681. /**
  73682. * the particle system to be used by the sub emitter
  73683. */
  73684. particleSystem: ParticleSystem;
  73685. /**
  73686. * Type of the submitter (Default: END)
  73687. */
  73688. type: SubEmitterType;
  73689. /**
  73690. * 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)
  73691. * Note: This only is supported when using an emitter of type Mesh
  73692. */
  73693. inheritDirection: boolean;
  73694. /**
  73695. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73696. */
  73697. inheritedVelocityAmount: number;
  73698. /**
  73699. * Creates a sub emitter
  73700. * @param particleSystem the particle system to be used by the sub emitter
  73701. */
  73702. constructor(
  73703. /**
  73704. * the particle system to be used by the sub emitter
  73705. */
  73706. particleSystem: ParticleSystem);
  73707. /**
  73708. * Clones the sub emitter
  73709. * @returns the cloned sub emitter
  73710. */
  73711. clone(): SubEmitter;
  73712. /**
  73713. * Serialize current object to a JSON object
  73714. * @returns the serialized object
  73715. */
  73716. serialize(): any;
  73717. /** @hidden */
  73718. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73719. /**
  73720. * Creates a new SubEmitter from a serialized JSON version
  73721. * @param serializationObject defines the JSON object to read from
  73722. * @param scene defines the hosting scene
  73723. * @param rootUrl defines the rootUrl for data loading
  73724. * @returns a new SubEmitter
  73725. */
  73726. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73727. /** Release associated resources */
  73728. dispose(): void;
  73729. }
  73730. }
  73731. declare module BABYLON {
  73732. /** @hidden */
  73733. export var clipPlaneFragmentDeclaration: {
  73734. name: string;
  73735. shader: string;
  73736. };
  73737. }
  73738. declare module BABYLON {
  73739. /** @hidden */
  73740. export var imageProcessingDeclaration: {
  73741. name: string;
  73742. shader: string;
  73743. };
  73744. }
  73745. declare module BABYLON {
  73746. /** @hidden */
  73747. export var imageProcessingFunctions: {
  73748. name: string;
  73749. shader: string;
  73750. };
  73751. }
  73752. declare module BABYLON {
  73753. /** @hidden */
  73754. export var clipPlaneFragment: {
  73755. name: string;
  73756. shader: string;
  73757. };
  73758. }
  73759. declare module BABYLON {
  73760. /** @hidden */
  73761. export var particlesPixelShader: {
  73762. name: string;
  73763. shader: string;
  73764. };
  73765. }
  73766. declare module BABYLON {
  73767. /** @hidden */
  73768. export var clipPlaneVertexDeclaration: {
  73769. name: string;
  73770. shader: string;
  73771. };
  73772. }
  73773. declare module BABYLON {
  73774. /** @hidden */
  73775. export var clipPlaneVertex: {
  73776. name: string;
  73777. shader: string;
  73778. };
  73779. }
  73780. declare module BABYLON {
  73781. /** @hidden */
  73782. export var particlesVertexShader: {
  73783. name: string;
  73784. shader: string;
  73785. };
  73786. }
  73787. declare module BABYLON {
  73788. /**
  73789. * This represents a particle system in Babylon.
  73790. * 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.
  73791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73792. * @example https://doc.babylonjs.com/babylon101/particles
  73793. */
  73794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73795. /**
  73796. * Billboard mode will only apply to Y axis
  73797. */
  73798. static readonly BILLBOARDMODE_Y: number;
  73799. /**
  73800. * Billboard mode will apply to all axes
  73801. */
  73802. static readonly BILLBOARDMODE_ALL: number;
  73803. /**
  73804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73805. */
  73806. static readonly BILLBOARDMODE_STRETCHED: number;
  73807. /**
  73808. * This function can be defined to provide custom update for active particles.
  73809. * This function will be called instead of regular update (age, position, color, etc.).
  73810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73811. */
  73812. updateFunction: (particles: Particle[]) => void;
  73813. private _emitterWorldMatrix;
  73814. /**
  73815. * This function can be defined to specify initial direction for every new particle.
  73816. * It by default use the emitterType defined function
  73817. */
  73818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73819. /**
  73820. * This function can be defined to specify initial position for every new particle.
  73821. * It by default use the emitterType defined function
  73822. */
  73823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73824. /**
  73825. * @hidden
  73826. */
  73827. _inheritedVelocityOffset: Vector3;
  73828. /**
  73829. * An event triggered when the system is disposed
  73830. */
  73831. onDisposeObservable: Observable<ParticleSystem>;
  73832. private _onDisposeObserver;
  73833. /**
  73834. * Sets a callback that will be triggered when the system is disposed
  73835. */
  73836. onDispose: () => void;
  73837. private _particles;
  73838. private _epsilon;
  73839. private _capacity;
  73840. private _stockParticles;
  73841. private _newPartsExcess;
  73842. private _vertexData;
  73843. private _vertexBuffer;
  73844. private _vertexBuffers;
  73845. private _spriteBuffer;
  73846. private _indexBuffer;
  73847. private _effect;
  73848. private _customEffect;
  73849. private _cachedDefines;
  73850. private _scaledColorStep;
  73851. private _colorDiff;
  73852. private _scaledDirection;
  73853. private _scaledGravity;
  73854. private _currentRenderId;
  73855. private _alive;
  73856. private _useInstancing;
  73857. private _started;
  73858. private _stopped;
  73859. private _actualFrame;
  73860. private _scaledUpdateSpeed;
  73861. private _vertexBufferSize;
  73862. /** @hidden */
  73863. _currentEmitRateGradient: Nullable<FactorGradient>;
  73864. /** @hidden */
  73865. _currentEmitRate1: number;
  73866. /** @hidden */
  73867. _currentEmitRate2: number;
  73868. /** @hidden */
  73869. _currentStartSizeGradient: Nullable<FactorGradient>;
  73870. /** @hidden */
  73871. _currentStartSize1: number;
  73872. /** @hidden */
  73873. _currentStartSize2: number;
  73874. private readonly _rawTextureWidth;
  73875. private _rampGradientsTexture;
  73876. private _useRampGradients;
  73877. /** Gets or sets a boolean indicating that ramp gradients must be used
  73878. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73879. */
  73880. useRampGradients: boolean;
  73881. /**
  73882. * 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.
  73883. * 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: [])
  73884. */
  73885. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73886. private _subEmitters;
  73887. /**
  73888. * @hidden
  73889. * If the particle systems emitter should be disposed when the particle system is disposed
  73890. */
  73891. _disposeEmitterOnDispose: boolean;
  73892. /**
  73893. * The current active Sub-systems, this property is used by the root particle system only.
  73894. */
  73895. activeSubSystems: Array<ParticleSystem>;
  73896. private _rootParticleSystem;
  73897. /**
  73898. * Gets the current list of active particles
  73899. */
  73900. readonly particles: Particle[];
  73901. /**
  73902. * Returns the string "ParticleSystem"
  73903. * @returns a string containing the class name
  73904. */
  73905. getClassName(): string;
  73906. /**
  73907. * Instantiates a particle system.
  73908. * 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.
  73909. * @param name The name of the particle system
  73910. * @param capacity The max number of particles alive at the same time
  73911. * @param scene The scene the particle system belongs to
  73912. * @param customEffect a custom effect used to change the way particles are rendered by default
  73913. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73914. * @param epsilon Offset used to render the particles
  73915. */
  73916. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73917. private _addFactorGradient;
  73918. private _removeFactorGradient;
  73919. /**
  73920. * Adds a new life time gradient
  73921. * @param gradient defines the gradient to use (between 0 and 1)
  73922. * @param factor defines the life time factor to affect to the specified gradient
  73923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73924. * @returns the current particle system
  73925. */
  73926. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73927. /**
  73928. * Remove a specific life time gradient
  73929. * @param gradient defines the gradient to remove
  73930. * @returns the current particle system
  73931. */
  73932. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73933. /**
  73934. * Adds a new size gradient
  73935. * @param gradient defines the gradient to use (between 0 and 1)
  73936. * @param factor defines the size factor to affect to the specified gradient
  73937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73938. * @returns the current particle system
  73939. */
  73940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73941. /**
  73942. * Remove a specific size gradient
  73943. * @param gradient defines the gradient to remove
  73944. * @returns the current particle system
  73945. */
  73946. removeSizeGradient(gradient: number): IParticleSystem;
  73947. /**
  73948. * Adds a new color remap gradient
  73949. * @param gradient defines the gradient to use (between 0 and 1)
  73950. * @param min defines the color remap minimal range
  73951. * @param max defines the color remap maximal range
  73952. * @returns the current particle system
  73953. */
  73954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73955. /**
  73956. * Remove a specific color remap gradient
  73957. * @param gradient defines the gradient to remove
  73958. * @returns the current particle system
  73959. */
  73960. removeColorRemapGradient(gradient: number): IParticleSystem;
  73961. /**
  73962. * Adds a new alpha remap gradient
  73963. * @param gradient defines the gradient to use (between 0 and 1)
  73964. * @param min defines the alpha remap minimal range
  73965. * @param max defines the alpha remap maximal range
  73966. * @returns the current particle system
  73967. */
  73968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73969. /**
  73970. * Remove a specific alpha remap gradient
  73971. * @param gradient defines the gradient to remove
  73972. * @returns the current particle system
  73973. */
  73974. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73975. /**
  73976. * Adds a new angular speed gradient
  73977. * @param gradient defines the gradient to use (between 0 and 1)
  73978. * @param factor defines the angular speed to affect to the specified gradient
  73979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73980. * @returns the current particle system
  73981. */
  73982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73983. /**
  73984. * Remove a specific angular speed gradient
  73985. * @param gradient defines the gradient to remove
  73986. * @returns the current particle system
  73987. */
  73988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73989. /**
  73990. * Adds a new velocity gradient
  73991. * @param gradient defines the gradient to use (between 0 and 1)
  73992. * @param factor defines the velocity to affect to the specified gradient
  73993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73994. * @returns the current particle system
  73995. */
  73996. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73997. /**
  73998. * Remove a specific velocity gradient
  73999. * @param gradient defines the gradient to remove
  74000. * @returns the current particle system
  74001. */
  74002. removeVelocityGradient(gradient: number): IParticleSystem;
  74003. /**
  74004. * Adds a new limit velocity gradient
  74005. * @param gradient defines the gradient to use (between 0 and 1)
  74006. * @param factor defines the limit velocity value to affect to the specified gradient
  74007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74008. * @returns the current particle system
  74009. */
  74010. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74011. /**
  74012. * Remove a specific limit velocity gradient
  74013. * @param gradient defines the gradient to remove
  74014. * @returns the current particle system
  74015. */
  74016. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74017. /**
  74018. * Adds a new drag gradient
  74019. * @param gradient defines the gradient to use (between 0 and 1)
  74020. * @param factor defines the drag value to affect to the specified gradient
  74021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74022. * @returns the current particle system
  74023. */
  74024. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74025. /**
  74026. * Remove a specific drag gradient
  74027. * @param gradient defines the gradient to remove
  74028. * @returns the current particle system
  74029. */
  74030. removeDragGradient(gradient: number): IParticleSystem;
  74031. /**
  74032. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74033. * @param gradient defines the gradient to use (between 0 and 1)
  74034. * @param factor defines the emit rate value to affect to the specified gradient
  74035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74036. * @returns the current particle system
  74037. */
  74038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74039. /**
  74040. * Remove a specific emit rate gradient
  74041. * @param gradient defines the gradient to remove
  74042. * @returns the current particle system
  74043. */
  74044. removeEmitRateGradient(gradient: number): IParticleSystem;
  74045. /**
  74046. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74047. * @param gradient defines the gradient to use (between 0 and 1)
  74048. * @param factor defines the start size value to affect to the specified gradient
  74049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74050. * @returns the current particle system
  74051. */
  74052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74053. /**
  74054. * Remove a specific start size gradient
  74055. * @param gradient defines the gradient to remove
  74056. * @returns the current particle system
  74057. */
  74058. removeStartSizeGradient(gradient: number): IParticleSystem;
  74059. private _createRampGradientTexture;
  74060. /**
  74061. * Gets the current list of ramp gradients.
  74062. * You must use addRampGradient and removeRampGradient to udpate this list
  74063. * @returns the list of ramp gradients
  74064. */
  74065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74066. /**
  74067. * Adds a new ramp gradient used to remap particle colors
  74068. * @param gradient defines the gradient to use (between 0 and 1)
  74069. * @param color defines the color to affect to the specified gradient
  74070. * @returns the current particle system
  74071. */
  74072. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74073. /**
  74074. * Remove a specific ramp gradient
  74075. * @param gradient defines the gradient to remove
  74076. * @returns the current particle system
  74077. */
  74078. removeRampGradient(gradient: number): ParticleSystem;
  74079. /**
  74080. * Adds a new color gradient
  74081. * @param gradient defines the gradient to use (between 0 and 1)
  74082. * @param color1 defines the color to affect to the specified gradient
  74083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74084. * @returns this particle system
  74085. */
  74086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74087. /**
  74088. * Remove a specific color gradient
  74089. * @param gradient defines the gradient to remove
  74090. * @returns this particle system
  74091. */
  74092. removeColorGradient(gradient: number): IParticleSystem;
  74093. private _fetchR;
  74094. protected _reset(): void;
  74095. private _resetEffect;
  74096. private _createVertexBuffers;
  74097. private _createIndexBuffer;
  74098. /**
  74099. * Gets the maximum number of particles active at the same time.
  74100. * @returns The max number of active particles.
  74101. */
  74102. getCapacity(): number;
  74103. /**
  74104. * Gets whether there are still active particles in the system.
  74105. * @returns True if it is alive, otherwise false.
  74106. */
  74107. isAlive(): boolean;
  74108. /**
  74109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74110. * @returns True if it has been started, otherwise false.
  74111. */
  74112. isStarted(): boolean;
  74113. private _prepareSubEmitterInternalArray;
  74114. /**
  74115. * Starts the particle system and begins to emit
  74116. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74117. */
  74118. start(delay?: number): void;
  74119. /**
  74120. * Stops the particle system.
  74121. * @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.
  74122. */
  74123. stop(stopSubEmitters?: boolean): void;
  74124. /**
  74125. * Remove all active particles
  74126. */
  74127. reset(): void;
  74128. /**
  74129. * @hidden (for internal use only)
  74130. */
  74131. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74132. /**
  74133. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74134. * Its lifetime will start back at 0.
  74135. */
  74136. recycleParticle: (particle: Particle) => void;
  74137. private _stopSubEmitters;
  74138. private _createParticle;
  74139. private _removeFromRoot;
  74140. private _emitFromParticle;
  74141. private _update;
  74142. /** @hidden */
  74143. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74144. /** @hidden */
  74145. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74146. /** @hidden */
  74147. private _getEffect;
  74148. /**
  74149. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74150. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74151. */
  74152. animate(preWarmOnly?: boolean): void;
  74153. private _appendParticleVertices;
  74154. /**
  74155. * Rebuilds the particle system.
  74156. */
  74157. rebuild(): void;
  74158. /**
  74159. * Is this system ready to be used/rendered
  74160. * @return true if the system is ready
  74161. */
  74162. isReady(): boolean;
  74163. private _render;
  74164. /**
  74165. * Renders the particle system in its current state.
  74166. * @returns the current number of particles
  74167. */
  74168. render(): number;
  74169. /**
  74170. * Disposes the particle system and free the associated resources
  74171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74172. */
  74173. dispose(disposeTexture?: boolean): void;
  74174. /**
  74175. * Clones the particle system.
  74176. * @param name The name of the cloned object
  74177. * @param newEmitter The new emitter to use
  74178. * @returns the cloned particle system
  74179. */
  74180. clone(name: string, newEmitter: any): ParticleSystem;
  74181. /**
  74182. * Serializes the particle system to a JSON object.
  74183. * @returns the JSON object
  74184. */
  74185. serialize(): any;
  74186. /** @hidden */
  74187. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74188. /** @hidden */
  74189. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74190. /**
  74191. * Parses a JSON object to create a particle system.
  74192. * @param parsedParticleSystem The JSON object to parse
  74193. * @param scene The scene to create the particle system in
  74194. * @param rootUrl The root url to use to load external dependencies like texture
  74195. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74196. * @returns the Parsed particle system
  74197. */
  74198. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74199. }
  74200. }
  74201. declare module BABYLON {
  74202. /**
  74203. * A particle represents one of the element emitted by a particle system.
  74204. * This is mainly define by its coordinates, direction, velocity and age.
  74205. */
  74206. export class Particle {
  74207. /**
  74208. * The particle system the particle belongs to.
  74209. */
  74210. particleSystem: ParticleSystem;
  74211. private static _Count;
  74212. /**
  74213. * Unique ID of the particle
  74214. */
  74215. id: number;
  74216. /**
  74217. * The world position of the particle in the scene.
  74218. */
  74219. position: Vector3;
  74220. /**
  74221. * The world direction of the particle in the scene.
  74222. */
  74223. direction: Vector3;
  74224. /**
  74225. * The color of the particle.
  74226. */
  74227. color: Color4;
  74228. /**
  74229. * The color change of the particle per step.
  74230. */
  74231. colorStep: Color4;
  74232. /**
  74233. * Defines how long will the life of the particle be.
  74234. */
  74235. lifeTime: number;
  74236. /**
  74237. * The current age of the particle.
  74238. */
  74239. age: number;
  74240. /**
  74241. * The current size of the particle.
  74242. */
  74243. size: number;
  74244. /**
  74245. * The current scale of the particle.
  74246. */
  74247. scale: Vector2;
  74248. /**
  74249. * The current angle of the particle.
  74250. */
  74251. angle: number;
  74252. /**
  74253. * Defines how fast is the angle changing.
  74254. */
  74255. angularSpeed: number;
  74256. /**
  74257. * Defines the cell index used by the particle to be rendered from a sprite.
  74258. */
  74259. cellIndex: number;
  74260. /**
  74261. * The information required to support color remapping
  74262. */
  74263. remapData: Vector4;
  74264. /** @hidden */
  74265. _randomCellOffset?: number;
  74266. /** @hidden */
  74267. _initialDirection: Nullable<Vector3>;
  74268. /** @hidden */
  74269. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74270. /** @hidden */
  74271. _initialStartSpriteCellID: number;
  74272. /** @hidden */
  74273. _initialEndSpriteCellID: number;
  74274. /** @hidden */
  74275. _currentColorGradient: Nullable<ColorGradient>;
  74276. /** @hidden */
  74277. _currentColor1: Color4;
  74278. /** @hidden */
  74279. _currentColor2: Color4;
  74280. /** @hidden */
  74281. _currentSizeGradient: Nullable<FactorGradient>;
  74282. /** @hidden */
  74283. _currentSize1: number;
  74284. /** @hidden */
  74285. _currentSize2: number;
  74286. /** @hidden */
  74287. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74288. /** @hidden */
  74289. _currentAngularSpeed1: number;
  74290. /** @hidden */
  74291. _currentAngularSpeed2: number;
  74292. /** @hidden */
  74293. _currentVelocityGradient: Nullable<FactorGradient>;
  74294. /** @hidden */
  74295. _currentVelocity1: number;
  74296. /** @hidden */
  74297. _currentVelocity2: number;
  74298. /** @hidden */
  74299. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74300. /** @hidden */
  74301. _currentLimitVelocity1: number;
  74302. /** @hidden */
  74303. _currentLimitVelocity2: number;
  74304. /** @hidden */
  74305. _currentDragGradient: Nullable<FactorGradient>;
  74306. /** @hidden */
  74307. _currentDrag1: number;
  74308. /** @hidden */
  74309. _currentDrag2: number;
  74310. /** @hidden */
  74311. _randomNoiseCoordinates1: Vector3;
  74312. /** @hidden */
  74313. _randomNoiseCoordinates2: Vector3;
  74314. /**
  74315. * Creates a new instance Particle
  74316. * @param particleSystem the particle system the particle belongs to
  74317. */
  74318. constructor(
  74319. /**
  74320. * The particle system the particle belongs to.
  74321. */
  74322. particleSystem: ParticleSystem);
  74323. private updateCellInfoFromSystem;
  74324. /**
  74325. * Defines how the sprite cell index is updated for the particle
  74326. */
  74327. updateCellIndex(): void;
  74328. /** @hidden */
  74329. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74330. /** @hidden */
  74331. _inheritParticleInfoToSubEmitters(): void;
  74332. /** @hidden */
  74333. _reset(): void;
  74334. /**
  74335. * Copy the properties of particle to another one.
  74336. * @param other the particle to copy the information to.
  74337. */
  74338. copyTo(other: Particle): void;
  74339. }
  74340. }
  74341. declare module BABYLON {
  74342. /**
  74343. * Particle emitter represents a volume emitting particles.
  74344. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74345. */
  74346. export interface IParticleEmitterType {
  74347. /**
  74348. * Called by the particle System when the direction is computed for the created particle.
  74349. * @param worldMatrix is the world matrix of the particle system
  74350. * @param directionToUpdate is the direction vector to update with the result
  74351. * @param particle is the particle we are computed the direction for
  74352. */
  74353. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74354. /**
  74355. * Called by the particle System when the position is computed for the created particle.
  74356. * @param worldMatrix is the world matrix of the particle system
  74357. * @param positionToUpdate is the position vector to update with the result
  74358. * @param particle is the particle we are computed the position for
  74359. */
  74360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74361. /**
  74362. * Clones the current emitter and returns a copy of it
  74363. * @returns the new emitter
  74364. */
  74365. clone(): IParticleEmitterType;
  74366. /**
  74367. * Called by the GPUParticleSystem to setup the update shader
  74368. * @param effect defines the update shader
  74369. */
  74370. applyToShader(effect: Effect): void;
  74371. /**
  74372. * Returns a string to use to update the GPU particles update shader
  74373. * @returns the effect defines string
  74374. */
  74375. getEffectDefines(): string;
  74376. /**
  74377. * Returns a string representing the class name
  74378. * @returns a string containing the class name
  74379. */
  74380. getClassName(): string;
  74381. /**
  74382. * Serializes the particle system to a JSON object.
  74383. * @returns the JSON object
  74384. */
  74385. serialize(): any;
  74386. /**
  74387. * Parse properties from a JSON object
  74388. * @param serializationObject defines the JSON object
  74389. */
  74390. parse(serializationObject: any): void;
  74391. }
  74392. }
  74393. declare module BABYLON {
  74394. /**
  74395. * Particle emitter emitting particles from the inside of a box.
  74396. * It emits the particles randomly between 2 given directions.
  74397. */
  74398. export class BoxParticleEmitter implements IParticleEmitterType {
  74399. /**
  74400. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74401. */
  74402. direction1: Vector3;
  74403. /**
  74404. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74405. */
  74406. direction2: Vector3;
  74407. /**
  74408. * 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.
  74409. */
  74410. minEmitBox: Vector3;
  74411. /**
  74412. * 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.
  74413. */
  74414. maxEmitBox: Vector3;
  74415. /**
  74416. * Creates a new instance BoxParticleEmitter
  74417. */
  74418. constructor();
  74419. /**
  74420. * Called by the particle System when the direction is computed for the created particle.
  74421. * @param worldMatrix is the world matrix of the particle system
  74422. * @param directionToUpdate is the direction vector to update with the result
  74423. * @param particle is the particle we are computed the direction for
  74424. */
  74425. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74426. /**
  74427. * Called by the particle System when the position is computed for the created particle.
  74428. * @param worldMatrix is the world matrix of the particle system
  74429. * @param positionToUpdate is the position vector to update with the result
  74430. * @param particle is the particle we are computed the position for
  74431. */
  74432. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74433. /**
  74434. * Clones the current emitter and returns a copy of it
  74435. * @returns the new emitter
  74436. */
  74437. clone(): BoxParticleEmitter;
  74438. /**
  74439. * Called by the GPUParticleSystem to setup the update shader
  74440. * @param effect defines the update shader
  74441. */
  74442. applyToShader(effect: Effect): void;
  74443. /**
  74444. * Returns a string to use to update the GPU particles update shader
  74445. * @returns a string containng the defines string
  74446. */
  74447. getEffectDefines(): string;
  74448. /**
  74449. * Returns the string "BoxParticleEmitter"
  74450. * @returns a string containing the class name
  74451. */
  74452. getClassName(): string;
  74453. /**
  74454. * Serializes the particle system to a JSON object.
  74455. * @returns the JSON object
  74456. */
  74457. serialize(): any;
  74458. /**
  74459. * Parse properties from a JSON object
  74460. * @param serializationObject defines the JSON object
  74461. */
  74462. parse(serializationObject: any): void;
  74463. }
  74464. }
  74465. declare module BABYLON {
  74466. /**
  74467. * Particle emitter emitting particles from the inside of a cone.
  74468. * It emits the particles alongside the cone volume from the base to the particle.
  74469. * The emission direction might be randomized.
  74470. */
  74471. export class ConeParticleEmitter implements IParticleEmitterType {
  74472. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74473. directionRandomizer: number;
  74474. private _radius;
  74475. private _angle;
  74476. private _height;
  74477. /**
  74478. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74479. */
  74480. radiusRange: number;
  74481. /**
  74482. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74483. */
  74484. heightRange: number;
  74485. /**
  74486. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74487. */
  74488. emitFromSpawnPointOnly: boolean;
  74489. /**
  74490. * Gets or sets the radius of the emission cone
  74491. */
  74492. radius: number;
  74493. /**
  74494. * Gets or sets the angle of the emission cone
  74495. */
  74496. angle: number;
  74497. private _buildHeight;
  74498. /**
  74499. * Creates a new instance ConeParticleEmitter
  74500. * @param radius the radius of the emission cone (1 by default)
  74501. * @param angle the cone base angle (PI by default)
  74502. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74503. */
  74504. constructor(radius?: number, angle?: number,
  74505. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74506. directionRandomizer?: number);
  74507. /**
  74508. * Called by the particle System when the direction is computed for the created particle.
  74509. * @param worldMatrix is the world matrix of the particle system
  74510. * @param directionToUpdate is the direction vector to update with the result
  74511. * @param particle is the particle we are computed the direction for
  74512. */
  74513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74514. /**
  74515. * Called by the particle System when the position is computed for the created particle.
  74516. * @param worldMatrix is the world matrix of the particle system
  74517. * @param positionToUpdate is the position vector to update with the result
  74518. * @param particle is the particle we are computed the position for
  74519. */
  74520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74521. /**
  74522. * Clones the current emitter and returns a copy of it
  74523. * @returns the new emitter
  74524. */
  74525. clone(): ConeParticleEmitter;
  74526. /**
  74527. * Called by the GPUParticleSystem to setup the update shader
  74528. * @param effect defines the update shader
  74529. */
  74530. applyToShader(effect: Effect): void;
  74531. /**
  74532. * Returns a string to use to update the GPU particles update shader
  74533. * @returns a string containng the defines string
  74534. */
  74535. getEffectDefines(): string;
  74536. /**
  74537. * Returns the string "ConeParticleEmitter"
  74538. * @returns a string containing the class name
  74539. */
  74540. getClassName(): string;
  74541. /**
  74542. * Serializes the particle system to a JSON object.
  74543. * @returns the JSON object
  74544. */
  74545. serialize(): any;
  74546. /**
  74547. * Parse properties from a JSON object
  74548. * @param serializationObject defines the JSON object
  74549. */
  74550. parse(serializationObject: any): void;
  74551. }
  74552. }
  74553. declare module BABYLON {
  74554. /**
  74555. * Particle emitter emitting particles from the inside of a cylinder.
  74556. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74557. */
  74558. export class CylinderParticleEmitter implements IParticleEmitterType {
  74559. /**
  74560. * The radius of the emission cylinder.
  74561. */
  74562. radius: number;
  74563. /**
  74564. * The height of the emission cylinder.
  74565. */
  74566. height: number;
  74567. /**
  74568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74569. */
  74570. radiusRange: number;
  74571. /**
  74572. * How much to randomize the particle direction [0-1].
  74573. */
  74574. directionRandomizer: number;
  74575. /**
  74576. * Creates a new instance CylinderParticleEmitter
  74577. * @param radius the radius of the emission cylinder (1 by default)
  74578. * @param height the height of the emission cylinder (1 by default)
  74579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74581. */
  74582. constructor(
  74583. /**
  74584. * The radius of the emission cylinder.
  74585. */
  74586. radius?: number,
  74587. /**
  74588. * The height of the emission cylinder.
  74589. */
  74590. height?: number,
  74591. /**
  74592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74593. */
  74594. radiusRange?: number,
  74595. /**
  74596. * How much to randomize the particle direction [0-1].
  74597. */
  74598. directionRandomizer?: number);
  74599. /**
  74600. * Called by the particle System when the direction is computed for the created particle.
  74601. * @param worldMatrix is the world matrix of the particle system
  74602. * @param directionToUpdate is the direction vector to update with the result
  74603. * @param particle is the particle we are computed the direction for
  74604. */
  74605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74606. /**
  74607. * Called by the particle System when the position is computed for the created particle.
  74608. * @param worldMatrix is the world matrix of the particle system
  74609. * @param positionToUpdate is the position vector to update with the result
  74610. * @param particle is the particle we are computed the position for
  74611. */
  74612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74613. /**
  74614. * Clones the current emitter and returns a copy of it
  74615. * @returns the new emitter
  74616. */
  74617. clone(): CylinderParticleEmitter;
  74618. /**
  74619. * Called by the GPUParticleSystem to setup the update shader
  74620. * @param effect defines the update shader
  74621. */
  74622. applyToShader(effect: Effect): void;
  74623. /**
  74624. * Returns a string to use to update the GPU particles update shader
  74625. * @returns a string containng the defines string
  74626. */
  74627. getEffectDefines(): string;
  74628. /**
  74629. * Returns the string "CylinderParticleEmitter"
  74630. * @returns a string containing the class name
  74631. */
  74632. getClassName(): string;
  74633. /**
  74634. * Serializes the particle system to a JSON object.
  74635. * @returns the JSON object
  74636. */
  74637. serialize(): any;
  74638. /**
  74639. * Parse properties from a JSON object
  74640. * @param serializationObject defines the JSON object
  74641. */
  74642. parse(serializationObject: any): void;
  74643. }
  74644. /**
  74645. * Particle emitter emitting particles from the inside of a cylinder.
  74646. * It emits the particles randomly between two vectors.
  74647. */
  74648. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74649. /**
  74650. * The min limit of the emission direction.
  74651. */
  74652. direction1: Vector3;
  74653. /**
  74654. * The max limit of the emission direction.
  74655. */
  74656. direction2: Vector3;
  74657. /**
  74658. * Creates a new instance CylinderDirectedParticleEmitter
  74659. * @param radius the radius of the emission cylinder (1 by default)
  74660. * @param height the height of the emission cylinder (1 by default)
  74661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74662. * @param direction1 the min limit of the emission direction (up vector by default)
  74663. * @param direction2 the max limit of the emission direction (up vector by default)
  74664. */
  74665. constructor(radius?: number, height?: number, radiusRange?: number,
  74666. /**
  74667. * The min limit of the emission direction.
  74668. */
  74669. direction1?: Vector3,
  74670. /**
  74671. * The max limit of the emission direction.
  74672. */
  74673. direction2?: Vector3);
  74674. /**
  74675. * Called by the particle System when the direction is computed for the created particle.
  74676. * @param worldMatrix is the world matrix of the particle system
  74677. * @param directionToUpdate is the direction vector to update with the result
  74678. * @param particle is the particle we are computed the direction for
  74679. */
  74680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74681. /**
  74682. * Clones the current emitter and returns a copy of it
  74683. * @returns the new emitter
  74684. */
  74685. clone(): CylinderDirectedParticleEmitter;
  74686. /**
  74687. * Called by the GPUParticleSystem to setup the update shader
  74688. * @param effect defines the update shader
  74689. */
  74690. applyToShader(effect: Effect): void;
  74691. /**
  74692. * Returns a string to use to update the GPU particles update shader
  74693. * @returns a string containng the defines string
  74694. */
  74695. getEffectDefines(): string;
  74696. /**
  74697. * Returns the string "CylinderDirectedParticleEmitter"
  74698. * @returns a string containing the class name
  74699. */
  74700. getClassName(): string;
  74701. /**
  74702. * Serializes the particle system to a JSON object.
  74703. * @returns the JSON object
  74704. */
  74705. serialize(): any;
  74706. /**
  74707. * Parse properties from a JSON object
  74708. * @param serializationObject defines the JSON object
  74709. */
  74710. parse(serializationObject: any): void;
  74711. }
  74712. }
  74713. declare module BABYLON {
  74714. /**
  74715. * Particle emitter emitting particles from the inside of a hemisphere.
  74716. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74717. */
  74718. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74719. /**
  74720. * The radius of the emission hemisphere.
  74721. */
  74722. radius: number;
  74723. /**
  74724. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74725. */
  74726. radiusRange: number;
  74727. /**
  74728. * How much to randomize the particle direction [0-1].
  74729. */
  74730. directionRandomizer: number;
  74731. /**
  74732. * Creates a new instance HemisphericParticleEmitter
  74733. * @param radius the radius of the emission hemisphere (1 by default)
  74734. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74735. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74736. */
  74737. constructor(
  74738. /**
  74739. * The radius of the emission hemisphere.
  74740. */
  74741. radius?: number,
  74742. /**
  74743. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74744. */
  74745. radiusRange?: number,
  74746. /**
  74747. * How much to randomize the particle direction [0-1].
  74748. */
  74749. directionRandomizer?: number);
  74750. /**
  74751. * Called by the particle System when the direction is computed for the created particle.
  74752. * @param worldMatrix is the world matrix of the particle system
  74753. * @param directionToUpdate is the direction vector to update with the result
  74754. * @param particle is the particle we are computed the direction for
  74755. */
  74756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74757. /**
  74758. * Called by the particle System when the position is computed for the created particle.
  74759. * @param worldMatrix is the world matrix of the particle system
  74760. * @param positionToUpdate is the position vector to update with the result
  74761. * @param particle is the particle we are computed the position for
  74762. */
  74763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74764. /**
  74765. * Clones the current emitter and returns a copy of it
  74766. * @returns the new emitter
  74767. */
  74768. clone(): HemisphericParticleEmitter;
  74769. /**
  74770. * Called by the GPUParticleSystem to setup the update shader
  74771. * @param effect defines the update shader
  74772. */
  74773. applyToShader(effect: Effect): void;
  74774. /**
  74775. * Returns a string to use to update the GPU particles update shader
  74776. * @returns a string containng the defines string
  74777. */
  74778. getEffectDefines(): string;
  74779. /**
  74780. * Returns the string "HemisphericParticleEmitter"
  74781. * @returns a string containing the class name
  74782. */
  74783. getClassName(): string;
  74784. /**
  74785. * Serializes the particle system to a JSON object.
  74786. * @returns the JSON object
  74787. */
  74788. serialize(): any;
  74789. /**
  74790. * Parse properties from a JSON object
  74791. * @param serializationObject defines the JSON object
  74792. */
  74793. parse(serializationObject: any): void;
  74794. }
  74795. }
  74796. declare module BABYLON {
  74797. /**
  74798. * Particle emitter emitting particles from a point.
  74799. * It emits the particles randomly between 2 given directions.
  74800. */
  74801. export class PointParticleEmitter implements IParticleEmitterType {
  74802. /**
  74803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74804. */
  74805. direction1: Vector3;
  74806. /**
  74807. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74808. */
  74809. direction2: Vector3;
  74810. /**
  74811. * Creates a new instance PointParticleEmitter
  74812. */
  74813. constructor();
  74814. /**
  74815. * Called by the particle System when the direction is computed for the created particle.
  74816. * @param worldMatrix is the world matrix of the particle system
  74817. * @param directionToUpdate is the direction vector to update with the result
  74818. * @param particle is the particle we are computed the direction for
  74819. */
  74820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74821. /**
  74822. * Called by the particle System when the position is computed for the created particle.
  74823. * @param worldMatrix is the world matrix of the particle system
  74824. * @param positionToUpdate is the position vector to update with the result
  74825. * @param particle is the particle we are computed the position for
  74826. */
  74827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74828. /**
  74829. * Clones the current emitter and returns a copy of it
  74830. * @returns the new emitter
  74831. */
  74832. clone(): PointParticleEmitter;
  74833. /**
  74834. * Called by the GPUParticleSystem to setup the update shader
  74835. * @param effect defines the update shader
  74836. */
  74837. applyToShader(effect: Effect): void;
  74838. /**
  74839. * Returns a string to use to update the GPU particles update shader
  74840. * @returns a string containng the defines string
  74841. */
  74842. getEffectDefines(): string;
  74843. /**
  74844. * Returns the string "PointParticleEmitter"
  74845. * @returns a string containing the class name
  74846. */
  74847. getClassName(): string;
  74848. /**
  74849. * Serializes the particle system to a JSON object.
  74850. * @returns the JSON object
  74851. */
  74852. serialize(): any;
  74853. /**
  74854. * Parse properties from a JSON object
  74855. * @param serializationObject defines the JSON object
  74856. */
  74857. parse(serializationObject: any): void;
  74858. }
  74859. }
  74860. declare module BABYLON {
  74861. /**
  74862. * Particle emitter emitting particles from the inside of a sphere.
  74863. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74864. */
  74865. export class SphereParticleEmitter implements IParticleEmitterType {
  74866. /**
  74867. * The radius of the emission sphere.
  74868. */
  74869. radius: number;
  74870. /**
  74871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74872. */
  74873. radiusRange: number;
  74874. /**
  74875. * How much to randomize the particle direction [0-1].
  74876. */
  74877. directionRandomizer: number;
  74878. /**
  74879. * Creates a new instance SphereParticleEmitter
  74880. * @param radius the radius of the emission sphere (1 by default)
  74881. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74883. */
  74884. constructor(
  74885. /**
  74886. * The radius of the emission sphere.
  74887. */
  74888. radius?: number,
  74889. /**
  74890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74891. */
  74892. radiusRange?: number,
  74893. /**
  74894. * How much to randomize the particle direction [0-1].
  74895. */
  74896. directionRandomizer?: number);
  74897. /**
  74898. * Called by the particle System when the direction is computed for the created particle.
  74899. * @param worldMatrix is the world matrix of the particle system
  74900. * @param directionToUpdate is the direction vector to update with the result
  74901. * @param particle is the particle we are computed the direction for
  74902. */
  74903. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74904. /**
  74905. * Called by the particle System when the position is computed for the created particle.
  74906. * @param worldMatrix is the world matrix of the particle system
  74907. * @param positionToUpdate is the position vector to update with the result
  74908. * @param particle is the particle we are computed the position for
  74909. */
  74910. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74911. /**
  74912. * Clones the current emitter and returns a copy of it
  74913. * @returns the new emitter
  74914. */
  74915. clone(): SphereParticleEmitter;
  74916. /**
  74917. * Called by the GPUParticleSystem to setup the update shader
  74918. * @param effect defines the update shader
  74919. */
  74920. applyToShader(effect: Effect): void;
  74921. /**
  74922. * Returns a string to use to update the GPU particles update shader
  74923. * @returns a string containng the defines string
  74924. */
  74925. getEffectDefines(): string;
  74926. /**
  74927. * Returns the string "SphereParticleEmitter"
  74928. * @returns a string containing the class name
  74929. */
  74930. getClassName(): string;
  74931. /**
  74932. * Serializes the particle system to a JSON object.
  74933. * @returns the JSON object
  74934. */
  74935. serialize(): any;
  74936. /**
  74937. * Parse properties from a JSON object
  74938. * @param serializationObject defines the JSON object
  74939. */
  74940. parse(serializationObject: any): void;
  74941. }
  74942. /**
  74943. * Particle emitter emitting particles from the inside of a sphere.
  74944. * It emits the particles randomly between two vectors.
  74945. */
  74946. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74947. /**
  74948. * The min limit of the emission direction.
  74949. */
  74950. direction1: Vector3;
  74951. /**
  74952. * The max limit of the emission direction.
  74953. */
  74954. direction2: Vector3;
  74955. /**
  74956. * Creates a new instance SphereDirectedParticleEmitter
  74957. * @param radius the radius of the emission sphere (1 by default)
  74958. * @param direction1 the min limit of the emission direction (up vector by default)
  74959. * @param direction2 the max limit of the emission direction (up vector by default)
  74960. */
  74961. constructor(radius?: number,
  74962. /**
  74963. * The min limit of the emission direction.
  74964. */
  74965. direction1?: Vector3,
  74966. /**
  74967. * The max limit of the emission direction.
  74968. */
  74969. direction2?: Vector3);
  74970. /**
  74971. * Called by the particle System when the direction is computed for the created particle.
  74972. * @param worldMatrix is the world matrix of the particle system
  74973. * @param directionToUpdate is the direction vector to update with the result
  74974. * @param particle is the particle we are computed the direction for
  74975. */
  74976. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74977. /**
  74978. * Clones the current emitter and returns a copy of it
  74979. * @returns the new emitter
  74980. */
  74981. clone(): SphereDirectedParticleEmitter;
  74982. /**
  74983. * Called by the GPUParticleSystem to setup the update shader
  74984. * @param effect defines the update shader
  74985. */
  74986. applyToShader(effect: Effect): void;
  74987. /**
  74988. * Returns a string to use to update the GPU particles update shader
  74989. * @returns a string containng the defines string
  74990. */
  74991. getEffectDefines(): string;
  74992. /**
  74993. * Returns the string "SphereDirectedParticleEmitter"
  74994. * @returns a string containing the class name
  74995. */
  74996. getClassName(): string;
  74997. /**
  74998. * Serializes the particle system to a JSON object.
  74999. * @returns the JSON object
  75000. */
  75001. serialize(): any;
  75002. /**
  75003. * Parse properties from a JSON object
  75004. * @param serializationObject defines the JSON object
  75005. */
  75006. parse(serializationObject: any): void;
  75007. }
  75008. }
  75009. declare module BABYLON {
  75010. /**
  75011. * Interface representing a particle system in Babylon.js.
  75012. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75013. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75014. */
  75015. export interface IParticleSystem {
  75016. /**
  75017. * List of animations used by the particle system.
  75018. */
  75019. animations: Animation[];
  75020. /**
  75021. * The id of the Particle system.
  75022. */
  75023. id: string;
  75024. /**
  75025. * The name of the Particle system.
  75026. */
  75027. name: string;
  75028. /**
  75029. * The emitter represents the Mesh or position we are attaching the particle system to.
  75030. */
  75031. emitter: Nullable<AbstractMesh | Vector3>;
  75032. /**
  75033. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75034. */
  75035. isBillboardBased: boolean;
  75036. /**
  75037. * The rendering group used by the Particle system to chose when to render.
  75038. */
  75039. renderingGroupId: number;
  75040. /**
  75041. * The layer mask we are rendering the particles through.
  75042. */
  75043. layerMask: number;
  75044. /**
  75045. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75046. */
  75047. updateSpeed: number;
  75048. /**
  75049. * The amount of time the particle system is running (depends of the overall update speed).
  75050. */
  75051. targetStopDuration: number;
  75052. /**
  75053. * The texture used to render each particle. (this can be a spritesheet)
  75054. */
  75055. particleTexture: Nullable<Texture>;
  75056. /**
  75057. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75058. */
  75059. blendMode: number;
  75060. /**
  75061. * Minimum life time of emitting particles.
  75062. */
  75063. minLifeTime: number;
  75064. /**
  75065. * Maximum life time of emitting particles.
  75066. */
  75067. maxLifeTime: number;
  75068. /**
  75069. * Minimum Size of emitting particles.
  75070. */
  75071. minSize: number;
  75072. /**
  75073. * Maximum Size of emitting particles.
  75074. */
  75075. maxSize: number;
  75076. /**
  75077. * Minimum scale of emitting particles on X axis.
  75078. */
  75079. minScaleX: number;
  75080. /**
  75081. * Maximum scale of emitting particles on X axis.
  75082. */
  75083. maxScaleX: number;
  75084. /**
  75085. * Minimum scale of emitting particles on Y axis.
  75086. */
  75087. minScaleY: number;
  75088. /**
  75089. * Maximum scale of emitting particles on Y axis.
  75090. */
  75091. maxScaleY: number;
  75092. /**
  75093. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75094. */
  75095. color1: Color4;
  75096. /**
  75097. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75098. */
  75099. color2: Color4;
  75100. /**
  75101. * Color the particle will have at the end of its lifetime.
  75102. */
  75103. colorDead: Color4;
  75104. /**
  75105. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75106. */
  75107. emitRate: number;
  75108. /**
  75109. * You can use gravity if you want to give an orientation to your particles.
  75110. */
  75111. gravity: Vector3;
  75112. /**
  75113. * Minimum power of emitting particles.
  75114. */
  75115. minEmitPower: number;
  75116. /**
  75117. * Maximum power of emitting particles.
  75118. */
  75119. maxEmitPower: number;
  75120. /**
  75121. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75122. */
  75123. minAngularSpeed: number;
  75124. /**
  75125. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75126. */
  75127. maxAngularSpeed: number;
  75128. /**
  75129. * Gets or sets the minimal initial rotation in radians.
  75130. */
  75131. minInitialRotation: number;
  75132. /**
  75133. * Gets or sets the maximal initial rotation in radians.
  75134. */
  75135. maxInitialRotation: number;
  75136. /**
  75137. * The particle emitter type defines the emitter used by the particle system.
  75138. * It can be for example box, sphere, or cone...
  75139. */
  75140. particleEmitterType: Nullable<IParticleEmitterType>;
  75141. /**
  75142. * Defines the delay in milliseconds before starting the system (0 by default)
  75143. */
  75144. startDelay: number;
  75145. /**
  75146. * 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
  75147. */
  75148. preWarmCycles: number;
  75149. /**
  75150. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75151. */
  75152. preWarmStepOffset: number;
  75153. /**
  75154. * 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)
  75155. */
  75156. spriteCellChangeSpeed: number;
  75157. /**
  75158. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75159. */
  75160. startSpriteCellID: number;
  75161. /**
  75162. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75163. */
  75164. endSpriteCellID: number;
  75165. /**
  75166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75167. */
  75168. spriteCellWidth: number;
  75169. /**
  75170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75171. */
  75172. spriteCellHeight: number;
  75173. /**
  75174. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75175. */
  75176. spriteRandomStartCell: boolean;
  75177. /**
  75178. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75179. */
  75180. isAnimationSheetEnabled: boolean;
  75181. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75182. translationPivot: Vector2;
  75183. /**
  75184. * Gets or sets a texture used to add random noise to particle positions
  75185. */
  75186. noiseTexture: Nullable<BaseTexture>;
  75187. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75188. noiseStrength: Vector3;
  75189. /**
  75190. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75191. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75192. */
  75193. billboardMode: number;
  75194. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75195. limitVelocityDamping: number;
  75196. /**
  75197. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75198. */
  75199. beginAnimationOnStart: boolean;
  75200. /**
  75201. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75202. */
  75203. beginAnimationFrom: number;
  75204. /**
  75205. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75206. */
  75207. beginAnimationTo: number;
  75208. /**
  75209. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75210. */
  75211. beginAnimationLoop: boolean;
  75212. /**
  75213. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75214. */
  75215. disposeOnStop: boolean;
  75216. /**
  75217. * Gets the maximum number of particles active at the same time.
  75218. * @returns The max number of active particles.
  75219. */
  75220. getCapacity(): number;
  75221. /**
  75222. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75223. * @returns True if it has been started, otherwise false.
  75224. */
  75225. isStarted(): boolean;
  75226. /**
  75227. * Animates the particle system for this frame.
  75228. */
  75229. animate(): void;
  75230. /**
  75231. * Renders the particle system in its current state.
  75232. * @returns the current number of particles
  75233. */
  75234. render(): number;
  75235. /**
  75236. * Dispose the particle system and frees its associated resources.
  75237. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75238. */
  75239. dispose(disposeTexture?: boolean): void;
  75240. /**
  75241. * Clones the particle system.
  75242. * @param name The name of the cloned object
  75243. * @param newEmitter The new emitter to use
  75244. * @returns the cloned particle system
  75245. */
  75246. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75247. /**
  75248. * Serializes the particle system to a JSON object.
  75249. * @returns the JSON object
  75250. */
  75251. serialize(): any;
  75252. /**
  75253. * Rebuild the particle system
  75254. */
  75255. rebuild(): void;
  75256. /**
  75257. * Starts the particle system and begins to emit
  75258. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75259. */
  75260. start(delay?: number): void;
  75261. /**
  75262. * Stops the particle system.
  75263. */
  75264. stop(): void;
  75265. /**
  75266. * Remove all active particles
  75267. */
  75268. reset(): void;
  75269. /**
  75270. * Is this system ready to be used/rendered
  75271. * @return true if the system is ready
  75272. */
  75273. isReady(): boolean;
  75274. /**
  75275. * Adds a new color gradient
  75276. * @param gradient defines the gradient to use (between 0 and 1)
  75277. * @param color1 defines the color to affect to the specified gradient
  75278. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75279. * @returns the current particle system
  75280. */
  75281. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75282. /**
  75283. * Remove a specific color gradient
  75284. * @param gradient defines the gradient to remove
  75285. * @returns the current particle system
  75286. */
  75287. removeColorGradient(gradient: number): IParticleSystem;
  75288. /**
  75289. * Adds a new size gradient
  75290. * @param gradient defines the gradient to use (between 0 and 1)
  75291. * @param factor defines the size factor to affect to the specified gradient
  75292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75293. * @returns the current particle system
  75294. */
  75295. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75296. /**
  75297. * Remove a specific size gradient
  75298. * @param gradient defines the gradient to remove
  75299. * @returns the current particle system
  75300. */
  75301. removeSizeGradient(gradient: number): IParticleSystem;
  75302. /**
  75303. * Gets the current list of color gradients.
  75304. * You must use addColorGradient and removeColorGradient to udpate this list
  75305. * @returns the list of color gradients
  75306. */
  75307. getColorGradients(): Nullable<Array<ColorGradient>>;
  75308. /**
  75309. * Gets the current list of size gradients.
  75310. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75311. * @returns the list of size gradients
  75312. */
  75313. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75314. /**
  75315. * Gets the current list of angular speed gradients.
  75316. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75317. * @returns the list of angular speed gradients
  75318. */
  75319. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75320. /**
  75321. * Adds a new angular speed gradient
  75322. * @param gradient defines the gradient to use (between 0 and 1)
  75323. * @param factor defines the angular speed to affect to the specified gradient
  75324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75325. * @returns the current particle system
  75326. */
  75327. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75328. /**
  75329. * Remove a specific angular speed gradient
  75330. * @param gradient defines the gradient to remove
  75331. * @returns the current particle system
  75332. */
  75333. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75334. /**
  75335. * Gets the current list of velocity gradients.
  75336. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75337. * @returns the list of velocity gradients
  75338. */
  75339. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75340. /**
  75341. * Adds a new velocity gradient
  75342. * @param gradient defines the gradient to use (between 0 and 1)
  75343. * @param factor defines the velocity to affect to the specified gradient
  75344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75345. * @returns the current particle system
  75346. */
  75347. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75348. /**
  75349. * Remove a specific velocity gradient
  75350. * @param gradient defines the gradient to remove
  75351. * @returns the current particle system
  75352. */
  75353. removeVelocityGradient(gradient: number): IParticleSystem;
  75354. /**
  75355. * Gets the current list of limit velocity gradients.
  75356. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75357. * @returns the list of limit velocity gradients
  75358. */
  75359. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75360. /**
  75361. * Adds a new limit velocity gradient
  75362. * @param gradient defines the gradient to use (between 0 and 1)
  75363. * @param factor defines the limit velocity to affect to the specified gradient
  75364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75365. * @returns the current particle system
  75366. */
  75367. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75368. /**
  75369. * Remove a specific limit velocity gradient
  75370. * @param gradient defines the gradient to remove
  75371. * @returns the current particle system
  75372. */
  75373. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75374. /**
  75375. * Adds a new drag gradient
  75376. * @param gradient defines the gradient to use (between 0 and 1)
  75377. * @param factor defines the drag to affect to the specified gradient
  75378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75379. * @returns the current particle system
  75380. */
  75381. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75382. /**
  75383. * Remove a specific drag gradient
  75384. * @param gradient defines the gradient to remove
  75385. * @returns the current particle system
  75386. */
  75387. removeDragGradient(gradient: number): IParticleSystem;
  75388. /**
  75389. * Gets the current list of drag gradients.
  75390. * You must use addDragGradient and removeDragGradient to udpate this list
  75391. * @returns the list of drag gradients
  75392. */
  75393. getDragGradients(): Nullable<Array<FactorGradient>>;
  75394. /**
  75395. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75396. * @param gradient defines the gradient to use (between 0 and 1)
  75397. * @param factor defines the emit rate to affect to the specified gradient
  75398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75399. * @returns the current particle system
  75400. */
  75401. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75402. /**
  75403. * Remove a specific emit rate gradient
  75404. * @param gradient defines the gradient to remove
  75405. * @returns the current particle system
  75406. */
  75407. removeEmitRateGradient(gradient: number): IParticleSystem;
  75408. /**
  75409. * Gets the current list of emit rate gradients.
  75410. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75411. * @returns the list of emit rate gradients
  75412. */
  75413. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75414. /**
  75415. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75416. * @param gradient defines the gradient to use (between 0 and 1)
  75417. * @param factor defines the start size to affect to the specified gradient
  75418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75419. * @returns the current particle system
  75420. */
  75421. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75422. /**
  75423. * Remove a specific start size gradient
  75424. * @param gradient defines the gradient to remove
  75425. * @returns the current particle system
  75426. */
  75427. removeStartSizeGradient(gradient: number): IParticleSystem;
  75428. /**
  75429. * Gets the current list of start size gradients.
  75430. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75431. * @returns the list of start size gradients
  75432. */
  75433. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75434. /**
  75435. * Adds a new life time gradient
  75436. * @param gradient defines the gradient to use (between 0 and 1)
  75437. * @param factor defines the life time factor to affect to the specified gradient
  75438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75439. * @returns the current particle system
  75440. */
  75441. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75442. /**
  75443. * Remove a specific life time gradient
  75444. * @param gradient defines the gradient to remove
  75445. * @returns the current particle system
  75446. */
  75447. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75448. /**
  75449. * Gets the current list of life time gradients.
  75450. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75451. * @returns the list of life time gradients
  75452. */
  75453. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75454. /**
  75455. * Gets the current list of color gradients.
  75456. * You must use addColorGradient and removeColorGradient to udpate this list
  75457. * @returns the list of color gradients
  75458. */
  75459. getColorGradients(): Nullable<Array<ColorGradient>>;
  75460. /**
  75461. * Adds a new ramp gradient used to remap particle colors
  75462. * @param gradient defines the gradient to use (between 0 and 1)
  75463. * @param color defines the color to affect to the specified gradient
  75464. * @returns the current particle system
  75465. */
  75466. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75467. /**
  75468. * Gets the current list of ramp gradients.
  75469. * You must use addRampGradient and removeRampGradient to udpate this list
  75470. * @returns the list of ramp gradients
  75471. */
  75472. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75473. /** Gets or sets a boolean indicating that ramp gradients must be used
  75474. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75475. */
  75476. useRampGradients: boolean;
  75477. /**
  75478. * Adds a new color remap gradient
  75479. * @param gradient defines the gradient to use (between 0 and 1)
  75480. * @param min defines the color remap minimal range
  75481. * @param max defines the color remap maximal range
  75482. * @returns the current particle system
  75483. */
  75484. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75485. /**
  75486. * Gets the current list of color remap gradients.
  75487. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75488. * @returns the list of color remap gradients
  75489. */
  75490. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75491. /**
  75492. * Adds a new alpha remap gradient
  75493. * @param gradient defines the gradient to use (between 0 and 1)
  75494. * @param min defines the alpha remap minimal range
  75495. * @param max defines the alpha remap maximal range
  75496. * @returns the current particle system
  75497. */
  75498. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75499. /**
  75500. * Gets the current list of alpha remap gradients.
  75501. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75502. * @returns the list of alpha remap gradients
  75503. */
  75504. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75505. /**
  75506. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75509. * @returns the emitter
  75510. */
  75511. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75512. /**
  75513. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75514. * @param radius The radius of the hemisphere to emit from
  75515. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75516. * @returns the emitter
  75517. */
  75518. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75519. /**
  75520. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75521. * @param radius The radius of the sphere to emit from
  75522. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75523. * @returns the emitter
  75524. */
  75525. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75526. /**
  75527. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75528. * @param radius The radius of the sphere to emit from
  75529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75531. * @returns the emitter
  75532. */
  75533. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75534. /**
  75535. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75536. * @param radius The radius of the emission cylinder
  75537. * @param height The height of the emission cylinder
  75538. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75539. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75540. * @returns the emitter
  75541. */
  75542. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75543. /**
  75544. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75545. * @param radius The radius of the cylinder to emit from
  75546. * @param height The height of the emission cylinder
  75547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75550. * @returns the emitter
  75551. */
  75552. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75553. /**
  75554. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75555. * @param radius The radius of the cone to emit from
  75556. * @param angle The base angle of the cone
  75557. * @returns the emitter
  75558. */
  75559. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75560. /**
  75561. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75564. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75565. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75566. * @returns the emitter
  75567. */
  75568. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75569. /**
  75570. * Get hosting scene
  75571. * @returns the scene
  75572. */
  75573. getScene(): Scene;
  75574. }
  75575. }
  75576. declare module BABYLON {
  75577. /**
  75578. * Creates an instance based on a source mesh.
  75579. */
  75580. export class InstancedMesh extends AbstractMesh {
  75581. private _sourceMesh;
  75582. private _currentLOD;
  75583. /** @hidden */
  75584. _indexInSourceMeshInstanceArray: number;
  75585. constructor(name: string, source: Mesh);
  75586. /**
  75587. * Returns the string "InstancedMesh".
  75588. */
  75589. getClassName(): string;
  75590. /**
  75591. * If the source mesh receives shadows
  75592. */
  75593. readonly receiveShadows: boolean;
  75594. /**
  75595. * The material of the source mesh
  75596. */
  75597. readonly material: Nullable<Material>;
  75598. /**
  75599. * Visibility of the source mesh
  75600. */
  75601. readonly visibility: number;
  75602. /**
  75603. * Skeleton of the source mesh
  75604. */
  75605. readonly skeleton: Nullable<Skeleton>;
  75606. /**
  75607. * Rendering ground id of the source mesh
  75608. */
  75609. renderingGroupId: number;
  75610. /**
  75611. * Returns the total number of vertices (integer).
  75612. */
  75613. getTotalVertices(): number;
  75614. /**
  75615. * Returns a positive integer : the total number of indices in this mesh geometry.
  75616. * @returns the numner of indices or zero if the mesh has no geometry.
  75617. */
  75618. getTotalIndices(): number;
  75619. /**
  75620. * The source mesh of the instance
  75621. */
  75622. readonly sourceMesh: Mesh;
  75623. /**
  75624. * Is this node ready to be used/rendered
  75625. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75626. * @return {boolean} is it ready
  75627. */
  75628. isReady(completeCheck?: boolean): boolean;
  75629. /**
  75630. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75631. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75632. * @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.
  75633. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75634. */
  75635. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75636. /**
  75637. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75638. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75639. * The `data` are either a numeric array either a Float32Array.
  75640. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75641. * 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).
  75642. * Note that a new underlying VertexBuffer object is created each call.
  75643. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75644. *
  75645. * Possible `kind` values :
  75646. * - VertexBuffer.PositionKind
  75647. * - VertexBuffer.UVKind
  75648. * - VertexBuffer.UV2Kind
  75649. * - VertexBuffer.UV3Kind
  75650. * - VertexBuffer.UV4Kind
  75651. * - VertexBuffer.UV5Kind
  75652. * - VertexBuffer.UV6Kind
  75653. * - VertexBuffer.ColorKind
  75654. * - VertexBuffer.MatricesIndicesKind
  75655. * - VertexBuffer.MatricesIndicesExtraKind
  75656. * - VertexBuffer.MatricesWeightsKind
  75657. * - VertexBuffer.MatricesWeightsExtraKind
  75658. *
  75659. * Returns the Mesh.
  75660. */
  75661. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75662. /**
  75663. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75664. * If the mesh has no geometry, it is simply returned as it is.
  75665. * The `data` are either a numeric array either a Float32Array.
  75666. * No new underlying VertexBuffer object is created.
  75667. * 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.
  75668. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75669. *
  75670. * Possible `kind` values :
  75671. * - VertexBuffer.PositionKind
  75672. * - VertexBuffer.UVKind
  75673. * - VertexBuffer.UV2Kind
  75674. * - VertexBuffer.UV3Kind
  75675. * - VertexBuffer.UV4Kind
  75676. * - VertexBuffer.UV5Kind
  75677. * - VertexBuffer.UV6Kind
  75678. * - VertexBuffer.ColorKind
  75679. * - VertexBuffer.MatricesIndicesKind
  75680. * - VertexBuffer.MatricesIndicesExtraKind
  75681. * - VertexBuffer.MatricesWeightsKind
  75682. * - VertexBuffer.MatricesWeightsExtraKind
  75683. *
  75684. * Returns the Mesh.
  75685. */
  75686. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75687. /**
  75688. * Sets the mesh indices.
  75689. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75690. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75691. * This method creates a new index buffer each call.
  75692. * Returns the Mesh.
  75693. */
  75694. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75695. /**
  75696. * Boolean : True if the mesh owns the requested kind of data.
  75697. */
  75698. isVerticesDataPresent(kind: string): boolean;
  75699. /**
  75700. * Returns an array of indices (IndicesArray).
  75701. */
  75702. getIndices(): Nullable<IndicesArray>;
  75703. readonly _positions: Nullable<Vector3[]>;
  75704. /**
  75705. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75706. * This means the mesh underlying bounding box and sphere are recomputed.
  75707. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75708. * @returns the current mesh
  75709. */
  75710. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75711. /** @hidden */
  75712. _preActivate(): InstancedMesh;
  75713. /** @hidden */
  75714. _activate(renderId: number): InstancedMesh;
  75715. /**
  75716. * Returns the current associated LOD AbstractMesh.
  75717. */
  75718. getLOD(camera: Camera): AbstractMesh;
  75719. /** @hidden */
  75720. _syncSubMeshes(): InstancedMesh;
  75721. /** @hidden */
  75722. _generatePointsArray(): boolean;
  75723. /**
  75724. * Creates a new InstancedMesh from the current mesh.
  75725. * - name (string) : the cloned mesh name
  75726. * - newParent (optional Node) : the optional Node to parent the clone to.
  75727. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75728. *
  75729. * Returns the clone.
  75730. */
  75731. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75732. /**
  75733. * Disposes the InstancedMesh.
  75734. * Returns nothing.
  75735. */
  75736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75737. }
  75738. }
  75739. declare module BABYLON {
  75740. /**
  75741. * Defines the options associated with the creation of a shader material.
  75742. */
  75743. export interface IShaderMaterialOptions {
  75744. /**
  75745. * Does the material work in alpha blend mode
  75746. */
  75747. needAlphaBlending: boolean;
  75748. /**
  75749. * Does the material work in alpha test mode
  75750. */
  75751. needAlphaTesting: boolean;
  75752. /**
  75753. * The list of attribute names used in the shader
  75754. */
  75755. attributes: string[];
  75756. /**
  75757. * The list of unifrom names used in the shader
  75758. */
  75759. uniforms: string[];
  75760. /**
  75761. * The list of UBO names used in the shader
  75762. */
  75763. uniformBuffers: string[];
  75764. /**
  75765. * The list of sampler names used in the shader
  75766. */
  75767. samplers: string[];
  75768. /**
  75769. * The list of defines used in the shader
  75770. */
  75771. defines: string[];
  75772. }
  75773. /**
  75774. * 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.
  75775. *
  75776. * This returned material effects how the mesh will look based on the code in the shaders.
  75777. *
  75778. * @see http://doc.babylonjs.com/how_to/shader_material
  75779. */
  75780. export class ShaderMaterial extends Material {
  75781. private _shaderPath;
  75782. private _options;
  75783. private _textures;
  75784. private _textureArrays;
  75785. private _floats;
  75786. private _ints;
  75787. private _floatsArrays;
  75788. private _colors3;
  75789. private _colors3Arrays;
  75790. private _colors4;
  75791. private _vectors2;
  75792. private _vectors3;
  75793. private _vectors4;
  75794. private _matrices;
  75795. private _matrices3x3;
  75796. private _matrices2x2;
  75797. private _vectors2Arrays;
  75798. private _vectors3Arrays;
  75799. private _cachedWorldViewMatrix;
  75800. private _renderId;
  75801. /**
  75802. * Instantiate a new shader material.
  75803. * 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.
  75804. * This returned material effects how the mesh will look based on the code in the shaders.
  75805. * @see http://doc.babylonjs.com/how_to/shader_material
  75806. * @param name Define the name of the material in the scene
  75807. * @param scene Define the scene the material belongs to
  75808. * @param shaderPath Defines the route to the shader code in one of three ways:
  75809. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75810. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75811. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75812. * @param options Define the options used to create the shader
  75813. */
  75814. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75815. /**
  75816. * Gets the options used to compile the shader.
  75817. * They can be modified to trigger a new compilation
  75818. */
  75819. readonly options: IShaderMaterialOptions;
  75820. /**
  75821. * Gets the current class name of the material e.g. "ShaderMaterial"
  75822. * Mainly use in serialization.
  75823. * @returns the class name
  75824. */
  75825. getClassName(): string;
  75826. /**
  75827. * Specifies if the material will require alpha blending
  75828. * @returns a boolean specifying if alpha blending is needed
  75829. */
  75830. needAlphaBlending(): boolean;
  75831. /**
  75832. * Specifies if this material should be rendered in alpha test mode
  75833. * @returns a boolean specifying if an alpha test is needed.
  75834. */
  75835. needAlphaTesting(): boolean;
  75836. private _checkUniform;
  75837. /**
  75838. * Set a texture in the shader.
  75839. * @param name Define the name of the uniform samplers as defined in the shader
  75840. * @param texture Define the texture to bind to this sampler
  75841. * @return the material itself allowing "fluent" like uniform updates
  75842. */
  75843. setTexture(name: string, texture: Texture): ShaderMaterial;
  75844. /**
  75845. * Set a texture array in the shader.
  75846. * @param name Define the name of the uniform sampler array as defined in the shader
  75847. * @param textures Define the list of textures to bind to this sampler
  75848. * @return the material itself allowing "fluent" like uniform updates
  75849. */
  75850. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75851. /**
  75852. * Set a float in the shader.
  75853. * @param name Define the name of the uniform as defined in the shader
  75854. * @param value Define the value to give to the uniform
  75855. * @return the material itself allowing "fluent" like uniform updates
  75856. */
  75857. setFloat(name: string, value: number): ShaderMaterial;
  75858. /**
  75859. * Set a int in the shader.
  75860. * @param name Define the name of the uniform as defined in the shader
  75861. * @param value Define the value to give to the uniform
  75862. * @return the material itself allowing "fluent" like uniform updates
  75863. */
  75864. setInt(name: string, value: number): ShaderMaterial;
  75865. /**
  75866. * Set an array of floats in the shader.
  75867. * @param name Define the name of the uniform as defined in the shader
  75868. * @param value Define the value to give to the uniform
  75869. * @return the material itself allowing "fluent" like uniform updates
  75870. */
  75871. setFloats(name: string, value: number[]): ShaderMaterial;
  75872. /**
  75873. * Set a vec3 in the shader from a Color3.
  75874. * @param name Define the name of the uniform as defined in the shader
  75875. * @param value Define the value to give to the uniform
  75876. * @return the material itself allowing "fluent" like uniform updates
  75877. */
  75878. setColor3(name: string, value: Color3): ShaderMaterial;
  75879. /**
  75880. * Set a vec3 array in the shader from a Color3 array.
  75881. * @param name Define the name of the uniform as defined in the shader
  75882. * @param value Define the value to give to the uniform
  75883. * @return the material itself allowing "fluent" like uniform updates
  75884. */
  75885. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75886. /**
  75887. * Set a vec4 in the shader from a Color4.
  75888. * @param name Define the name of the uniform as defined in the shader
  75889. * @param value Define the value to give to the uniform
  75890. * @return the material itself allowing "fluent" like uniform updates
  75891. */
  75892. setColor4(name: string, value: Color4): ShaderMaterial;
  75893. /**
  75894. * Set a vec2 in the shader from a Vector2.
  75895. * @param name Define the name of the uniform as defined in the shader
  75896. * @param value Define the value to give to the uniform
  75897. * @return the material itself allowing "fluent" like uniform updates
  75898. */
  75899. setVector2(name: string, value: Vector2): ShaderMaterial;
  75900. /**
  75901. * Set a vec3 in the shader from a Vector3.
  75902. * @param name Define the name of the uniform as defined in the shader
  75903. * @param value Define the value to give to the uniform
  75904. * @return the material itself allowing "fluent" like uniform updates
  75905. */
  75906. setVector3(name: string, value: Vector3): ShaderMaterial;
  75907. /**
  75908. * Set a vec4 in the shader from a Vector4.
  75909. * @param name Define the name of the uniform as defined in the shader
  75910. * @param value Define the value to give to the uniform
  75911. * @return the material itself allowing "fluent" like uniform updates
  75912. */
  75913. setVector4(name: string, value: Vector4): ShaderMaterial;
  75914. /**
  75915. * Set a mat4 in the shader from a Matrix.
  75916. * @param name Define the name of the uniform as defined in the shader
  75917. * @param value Define the value to give to the uniform
  75918. * @return the material itself allowing "fluent" like uniform updates
  75919. */
  75920. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75921. /**
  75922. * Set a mat3 in the shader from a Float32Array.
  75923. * @param name Define the name of the uniform as defined in the shader
  75924. * @param value Define the value to give to the uniform
  75925. * @return the material itself allowing "fluent" like uniform updates
  75926. */
  75927. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75928. /**
  75929. * Set a mat2 in the shader from a Float32Array.
  75930. * @param name Define the name of the uniform as defined in the shader
  75931. * @param value Define the value to give to the uniform
  75932. * @return the material itself allowing "fluent" like uniform updates
  75933. */
  75934. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75935. /**
  75936. * Set a vec2 array in the shader from a number array.
  75937. * @param name Define the name of the uniform as defined in the shader
  75938. * @param value Define the value to give to the uniform
  75939. * @return the material itself allowing "fluent" like uniform updates
  75940. */
  75941. setArray2(name: string, value: number[]): ShaderMaterial;
  75942. /**
  75943. * Set a vec3 array in the shader from a number array.
  75944. * @param name Define the name of the uniform as defined in the shader
  75945. * @param value Define the value to give to the uniform
  75946. * @return the material itself allowing "fluent" like uniform updates
  75947. */
  75948. setArray3(name: string, value: number[]): ShaderMaterial;
  75949. private _checkCache;
  75950. /**
  75951. * Specifies that the submesh is ready to be used
  75952. * @param mesh defines the mesh to check
  75953. * @param subMesh defines which submesh to check
  75954. * @param useInstances specifies that instances should be used
  75955. * @returns a boolean indicating that the submesh is ready or not
  75956. */
  75957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75958. /**
  75959. * Checks if the material is ready to render the requested mesh
  75960. * @param mesh Define the mesh to render
  75961. * @param useInstances Define whether or not the material is used with instances
  75962. * @returns true if ready, otherwise false
  75963. */
  75964. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75965. /**
  75966. * Binds the world matrix to the material
  75967. * @param world defines the world transformation matrix
  75968. */
  75969. bindOnlyWorldMatrix(world: Matrix): void;
  75970. /**
  75971. * Binds the material to the mesh
  75972. * @param world defines the world transformation matrix
  75973. * @param mesh defines the mesh to bind the material to
  75974. */
  75975. bind(world: Matrix, mesh?: Mesh): void;
  75976. /**
  75977. * Gets the active textures from the material
  75978. * @returns an array of textures
  75979. */
  75980. getActiveTextures(): BaseTexture[];
  75981. /**
  75982. * Specifies if the material uses a texture
  75983. * @param texture defines the texture to check against the material
  75984. * @returns a boolean specifying if the material uses the texture
  75985. */
  75986. hasTexture(texture: BaseTexture): boolean;
  75987. /**
  75988. * Makes a duplicate of the material, and gives it a new name
  75989. * @param name defines the new name for the duplicated material
  75990. * @returns the cloned material
  75991. */
  75992. clone(name: string): ShaderMaterial;
  75993. /**
  75994. * Disposes the material
  75995. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75996. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75997. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75998. */
  75999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76000. /**
  76001. * Serializes this material in a JSON representation
  76002. * @returns the serialized material object
  76003. */
  76004. serialize(): any;
  76005. /**
  76006. * Creates a shader material from parsed shader material data
  76007. * @param source defines the JSON represnetation of the material
  76008. * @param scene defines the hosting scene
  76009. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76010. * @returns a new material
  76011. */
  76012. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76013. }
  76014. }
  76015. declare module BABYLON {
  76016. /** @hidden */
  76017. export var colorPixelShader: {
  76018. name: string;
  76019. shader: string;
  76020. };
  76021. }
  76022. declare module BABYLON {
  76023. /** @hidden */
  76024. export var colorVertexShader: {
  76025. name: string;
  76026. shader: string;
  76027. };
  76028. }
  76029. declare module BABYLON {
  76030. /**
  76031. * Line mesh
  76032. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76033. */
  76034. export class LinesMesh extends Mesh {
  76035. /**
  76036. * If vertex color should be applied to the mesh
  76037. */
  76038. useVertexColor?: boolean | undefined;
  76039. /**
  76040. * If vertex alpha should be applied to the mesh
  76041. */
  76042. useVertexAlpha?: boolean | undefined;
  76043. /**
  76044. * Color of the line (Default: White)
  76045. */
  76046. color: Color3;
  76047. /**
  76048. * Alpha of the line (Default: 1)
  76049. */
  76050. alpha: number;
  76051. /**
  76052. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76053. * This margin is expressed in world space coordinates, so its value may vary.
  76054. * Default value is 0.1
  76055. */
  76056. intersectionThreshold: number;
  76057. private _colorShader;
  76058. /**
  76059. * Creates a new LinesMesh
  76060. * @param name defines the name
  76061. * @param scene defines the hosting scene
  76062. * @param parent defines the parent mesh if any
  76063. * @param source defines the optional source LinesMesh used to clone data from
  76064. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76065. * When false, achieved by calling a clone(), also passing False.
  76066. * This will make creation of children, recursive.
  76067. * @param useVertexColor defines if this LinesMesh supports vertex color
  76068. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76069. */
  76070. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76071. /**
  76072. * If vertex color should be applied to the mesh
  76073. */
  76074. useVertexColor?: boolean | undefined,
  76075. /**
  76076. * If vertex alpha should be applied to the mesh
  76077. */
  76078. useVertexAlpha?: boolean | undefined);
  76079. private _addClipPlaneDefine;
  76080. private _removeClipPlaneDefine;
  76081. isReady(): boolean;
  76082. /**
  76083. * Returns the string "LineMesh"
  76084. */
  76085. getClassName(): string;
  76086. /**
  76087. * @hidden
  76088. */
  76089. /**
  76090. * @hidden
  76091. */
  76092. material: Material;
  76093. /**
  76094. * @hidden
  76095. */
  76096. readonly checkCollisions: boolean;
  76097. /** @hidden */
  76098. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76099. /** @hidden */
  76100. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76101. /**
  76102. * Disposes of the line mesh
  76103. * @param doNotRecurse If children should be disposed
  76104. */
  76105. dispose(doNotRecurse?: boolean): void;
  76106. /**
  76107. * Returns a new LineMesh object cloned from the current one.
  76108. */
  76109. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76110. /**
  76111. * Creates a new InstancedLinesMesh object from the mesh model.
  76112. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76113. * @param name defines the name of the new instance
  76114. * @returns a new InstancedLinesMesh
  76115. */
  76116. createInstance(name: string): InstancedLinesMesh;
  76117. }
  76118. /**
  76119. * Creates an instance based on a source LinesMesh
  76120. */
  76121. export class InstancedLinesMesh extends InstancedMesh {
  76122. /**
  76123. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76124. * This margin is expressed in world space coordinates, so its value may vary.
  76125. * Initilized with the intersectionThreshold value of the source LinesMesh
  76126. */
  76127. intersectionThreshold: number;
  76128. constructor(name: string, source: LinesMesh);
  76129. /**
  76130. * Returns the string "InstancedLinesMesh".
  76131. */
  76132. getClassName(): string;
  76133. }
  76134. }
  76135. declare module BABYLON {
  76136. /** @hidden */
  76137. export var linePixelShader: {
  76138. name: string;
  76139. shader: string;
  76140. };
  76141. }
  76142. declare module BABYLON {
  76143. /** @hidden */
  76144. export var lineVertexShader: {
  76145. name: string;
  76146. shader: string;
  76147. };
  76148. }
  76149. declare module BABYLON {
  76150. interface AbstractMesh {
  76151. /**
  76152. * Disables the mesh edge rendering mode
  76153. * @returns the currentAbstractMesh
  76154. */
  76155. disableEdgesRendering(): AbstractMesh;
  76156. /**
  76157. * Enables the edge rendering mode on the mesh.
  76158. * This mode makes the mesh edges visible
  76159. * @param epsilon defines the maximal distance between two angles to detect a face
  76160. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76161. * @returns the currentAbstractMesh
  76162. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76163. */
  76164. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76165. /**
  76166. * Gets the edgesRenderer associated with the mesh
  76167. */
  76168. edgesRenderer: Nullable<EdgesRenderer>;
  76169. }
  76170. interface LinesMesh {
  76171. /**
  76172. * Enables the edge rendering mode on the mesh.
  76173. * This mode makes the mesh edges visible
  76174. * @param epsilon defines the maximal distance between two angles to detect a face
  76175. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76176. * @returns the currentAbstractMesh
  76177. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76178. */
  76179. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76180. }
  76181. interface InstancedLinesMesh {
  76182. /**
  76183. * Enables the edge rendering mode on the mesh.
  76184. * This mode makes the mesh edges visible
  76185. * @param epsilon defines the maximal distance between two angles to detect a face
  76186. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76187. * @returns the current InstancedLinesMesh
  76188. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76189. */
  76190. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76191. }
  76192. /**
  76193. * Defines the minimum contract an Edges renderer should follow.
  76194. */
  76195. export interface IEdgesRenderer extends IDisposable {
  76196. /**
  76197. * Gets or sets a boolean indicating if the edgesRenderer is active
  76198. */
  76199. isEnabled: boolean;
  76200. /**
  76201. * Renders the edges of the attached mesh,
  76202. */
  76203. render(): void;
  76204. /**
  76205. * Checks wether or not the edges renderer is ready to render.
  76206. * @return true if ready, otherwise false.
  76207. */
  76208. isReady(): boolean;
  76209. }
  76210. /**
  76211. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76212. */
  76213. export class EdgesRenderer implements IEdgesRenderer {
  76214. /**
  76215. * Define the size of the edges with an orthographic camera
  76216. */
  76217. edgesWidthScalerForOrthographic: number;
  76218. /**
  76219. * Define the size of the edges with a perspective camera
  76220. */
  76221. edgesWidthScalerForPerspective: number;
  76222. protected _source: AbstractMesh;
  76223. protected _linesPositions: number[];
  76224. protected _linesNormals: number[];
  76225. protected _linesIndices: number[];
  76226. protected _epsilon: number;
  76227. protected _indicesCount: number;
  76228. protected _lineShader: ShaderMaterial;
  76229. protected _ib: WebGLBuffer;
  76230. protected _buffers: {
  76231. [key: string]: Nullable<VertexBuffer>;
  76232. };
  76233. protected _checkVerticesInsteadOfIndices: boolean;
  76234. private _meshRebuildObserver;
  76235. private _meshDisposeObserver;
  76236. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76237. isEnabled: boolean;
  76238. /**
  76239. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76240. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76241. * @param source Mesh used to create edges
  76242. * @param epsilon sum of angles in adjacency to check for edge
  76243. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76244. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76245. */
  76246. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76247. protected _prepareRessources(): void;
  76248. /** @hidden */
  76249. _rebuild(): void;
  76250. /**
  76251. * Releases the required resources for the edges renderer
  76252. */
  76253. dispose(): void;
  76254. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76255. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76256. /**
  76257. * Checks if the pair of p0 and p1 is en edge
  76258. * @param faceIndex
  76259. * @param edge
  76260. * @param faceNormals
  76261. * @param p0
  76262. * @param p1
  76263. * @private
  76264. */
  76265. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76266. /**
  76267. * push line into the position, normal and index buffer
  76268. * @protected
  76269. */
  76270. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76271. /**
  76272. * Generates lines edges from adjacencjes
  76273. * @private
  76274. */
  76275. _generateEdgesLines(): void;
  76276. /**
  76277. * Checks wether or not the edges renderer is ready to render.
  76278. * @return true if ready, otherwise false.
  76279. */
  76280. isReady(): boolean;
  76281. /**
  76282. * Renders the edges of the attached mesh,
  76283. */
  76284. render(): void;
  76285. }
  76286. /**
  76287. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76288. */
  76289. export class LineEdgesRenderer extends EdgesRenderer {
  76290. /**
  76291. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76292. * @param source LineMesh used to generate edges
  76293. * @param epsilon not important (specified angle for edge detection)
  76294. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76295. */
  76296. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76297. /**
  76298. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76299. */
  76300. _generateEdgesLines(): void;
  76301. }
  76302. }
  76303. declare module BABYLON {
  76304. /**
  76305. * This represents the object necessary to create a rendering group.
  76306. * This is exclusively used and created by the rendering manager.
  76307. * To modify the behavior, you use the available helpers in your scene or meshes.
  76308. * @hidden
  76309. */
  76310. export class RenderingGroup {
  76311. index: number;
  76312. private _scene;
  76313. private _opaqueSubMeshes;
  76314. private _transparentSubMeshes;
  76315. private _alphaTestSubMeshes;
  76316. private _depthOnlySubMeshes;
  76317. private _particleSystems;
  76318. private _spriteManagers;
  76319. private _opaqueSortCompareFn;
  76320. private _alphaTestSortCompareFn;
  76321. private _transparentSortCompareFn;
  76322. private _renderOpaque;
  76323. private _renderAlphaTest;
  76324. private _renderTransparent;
  76325. private _edgesRenderers;
  76326. onBeforeTransparentRendering: () => void;
  76327. /**
  76328. * Set the opaque sort comparison function.
  76329. * If null the sub meshes will be render in the order they were created
  76330. */
  76331. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76332. /**
  76333. * Set the alpha test sort comparison function.
  76334. * If null the sub meshes will be render in the order they were created
  76335. */
  76336. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76337. /**
  76338. * Set the transparent sort comparison function.
  76339. * If null the sub meshes will be render in the order they were created
  76340. */
  76341. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76342. /**
  76343. * Creates a new rendering group.
  76344. * @param index The rendering group index
  76345. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76346. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76347. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76348. */
  76349. 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>);
  76350. /**
  76351. * Render all the sub meshes contained in the group.
  76352. * @param customRenderFunction Used to override the default render behaviour of the group.
  76353. * @returns true if rendered some submeshes.
  76354. */
  76355. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76356. /**
  76357. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76358. * @param subMeshes The submeshes to render
  76359. */
  76360. private renderOpaqueSorted;
  76361. /**
  76362. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76363. * @param subMeshes The submeshes to render
  76364. */
  76365. private renderAlphaTestSorted;
  76366. /**
  76367. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76368. * @param subMeshes The submeshes to render
  76369. */
  76370. private renderTransparentSorted;
  76371. /**
  76372. * Renders the submeshes in a specified order.
  76373. * @param subMeshes The submeshes to sort before render
  76374. * @param sortCompareFn The comparison function use to sort
  76375. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76376. * @param transparent Specifies to activate blending if true
  76377. */
  76378. private static renderSorted;
  76379. /**
  76380. * Renders the submeshes in the order they were dispatched (no sort applied).
  76381. * @param subMeshes The submeshes to render
  76382. */
  76383. private static renderUnsorted;
  76384. /**
  76385. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76386. * are rendered back to front if in the same alpha index.
  76387. *
  76388. * @param a The first submesh
  76389. * @param b The second submesh
  76390. * @returns The result of the comparison
  76391. */
  76392. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76393. /**
  76394. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76395. * are rendered back to front.
  76396. *
  76397. * @param a The first submesh
  76398. * @param b The second submesh
  76399. * @returns The result of the comparison
  76400. */
  76401. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76402. /**
  76403. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76404. * are rendered front to back (prevent overdraw).
  76405. *
  76406. * @param a The first submesh
  76407. * @param b The second submesh
  76408. * @returns The result of the comparison
  76409. */
  76410. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76411. /**
  76412. * Resets the different lists of submeshes to prepare a new frame.
  76413. */
  76414. prepare(): void;
  76415. dispose(): void;
  76416. /**
  76417. * Inserts the submesh in its correct queue depending on its material.
  76418. * @param subMesh The submesh to dispatch
  76419. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76420. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76421. */
  76422. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76423. dispatchSprites(spriteManager: ISpriteManager): void;
  76424. dispatchParticles(particleSystem: IParticleSystem): void;
  76425. private _renderParticles;
  76426. private _renderSprites;
  76427. }
  76428. }
  76429. declare module BABYLON {
  76430. /**
  76431. * Interface describing the different options available in the rendering manager
  76432. * regarding Auto Clear between groups.
  76433. */
  76434. export interface IRenderingManagerAutoClearSetup {
  76435. /**
  76436. * Defines whether or not autoclear is enable.
  76437. */
  76438. autoClear: boolean;
  76439. /**
  76440. * Defines whether or not to autoclear the depth buffer.
  76441. */
  76442. depth: boolean;
  76443. /**
  76444. * Defines whether or not to autoclear the stencil buffer.
  76445. */
  76446. stencil: boolean;
  76447. }
  76448. /**
  76449. * This class is used by the onRenderingGroupObservable
  76450. */
  76451. export class RenderingGroupInfo {
  76452. /**
  76453. * The Scene that being rendered
  76454. */
  76455. scene: Scene;
  76456. /**
  76457. * The camera currently used for the rendering pass
  76458. */
  76459. camera: Nullable<Camera>;
  76460. /**
  76461. * The ID of the renderingGroup being processed
  76462. */
  76463. renderingGroupId: number;
  76464. }
  76465. /**
  76466. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76467. * It is enable to manage the different groups as well as the different necessary sort functions.
  76468. * This should not be used directly aside of the few static configurations
  76469. */
  76470. export class RenderingManager {
  76471. /**
  76472. * The max id used for rendering groups (not included)
  76473. */
  76474. static MAX_RENDERINGGROUPS: number;
  76475. /**
  76476. * The min id used for rendering groups (included)
  76477. */
  76478. static MIN_RENDERINGGROUPS: number;
  76479. /**
  76480. * Used to globally prevent autoclearing scenes.
  76481. */
  76482. static AUTOCLEAR: boolean;
  76483. /**
  76484. * @hidden
  76485. */
  76486. _useSceneAutoClearSetup: boolean;
  76487. private _scene;
  76488. private _renderingGroups;
  76489. private _depthStencilBufferAlreadyCleaned;
  76490. private _autoClearDepthStencil;
  76491. private _customOpaqueSortCompareFn;
  76492. private _customAlphaTestSortCompareFn;
  76493. private _customTransparentSortCompareFn;
  76494. private _renderingGroupInfo;
  76495. /**
  76496. * Instantiates a new rendering group for a particular scene
  76497. * @param scene Defines the scene the groups belongs to
  76498. */
  76499. constructor(scene: Scene);
  76500. private _clearDepthStencilBuffer;
  76501. /**
  76502. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76503. * @hidden
  76504. */
  76505. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76506. /**
  76507. * Resets the different information of the group to prepare a new frame
  76508. * @hidden
  76509. */
  76510. reset(): void;
  76511. /**
  76512. * Dispose and release the group and its associated resources.
  76513. * @hidden
  76514. */
  76515. dispose(): void;
  76516. /**
  76517. * Clear the info related to rendering groups preventing retention points during dispose.
  76518. */
  76519. freeRenderingGroups(): void;
  76520. private _prepareRenderingGroup;
  76521. /**
  76522. * Add a sprite manager to the rendering manager in order to render it this frame.
  76523. * @param spriteManager Define the sprite manager to render
  76524. */
  76525. dispatchSprites(spriteManager: ISpriteManager): void;
  76526. /**
  76527. * Add a particle system to the rendering manager in order to render it this frame.
  76528. * @param particleSystem Define the particle system to render
  76529. */
  76530. dispatchParticles(particleSystem: IParticleSystem): void;
  76531. /**
  76532. * Add a submesh to the manager in order to render it this frame
  76533. * @param subMesh The submesh to dispatch
  76534. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76535. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76536. */
  76537. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76538. /**
  76539. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76540. * This allowed control for front to back rendering or reversly depending of the special needs.
  76541. *
  76542. * @param renderingGroupId The rendering group id corresponding to its index
  76543. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76544. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76545. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76546. */
  76547. 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;
  76548. /**
  76549. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76550. *
  76551. * @param renderingGroupId The rendering group id corresponding to its index
  76552. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76553. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76554. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76555. */
  76556. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76557. /**
  76558. * Gets the current auto clear configuration for one rendering group of the rendering
  76559. * manager.
  76560. * @param index the rendering group index to get the information for
  76561. * @returns The auto clear setup for the requested rendering group
  76562. */
  76563. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76564. }
  76565. }
  76566. declare module BABYLON {
  76567. /**
  76568. * This Helps creating a texture that will be created from a camera in your scene.
  76569. * It is basically a dynamic texture that could be used to create special effects for instance.
  76570. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76571. */
  76572. export class RenderTargetTexture extends Texture {
  76573. isCube: boolean;
  76574. /**
  76575. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76576. */
  76577. static readonly REFRESHRATE_RENDER_ONCE: number;
  76578. /**
  76579. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76580. */
  76581. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76582. /**
  76583. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76584. * the central point of your effect and can save a lot of performances.
  76585. */
  76586. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76587. /**
  76588. * Use this predicate to dynamically define the list of mesh you want to render.
  76589. * If set, the renderList property will be overwritten.
  76590. */
  76591. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76592. private _renderList;
  76593. /**
  76594. * Use this list to define the list of mesh you want to render.
  76595. */
  76596. renderList: Nullable<Array<AbstractMesh>>;
  76597. private _hookArray;
  76598. /**
  76599. * Define if particles should be rendered in your texture.
  76600. */
  76601. renderParticles: boolean;
  76602. /**
  76603. * Define if sprites should be rendered in your texture.
  76604. */
  76605. renderSprites: boolean;
  76606. /**
  76607. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76608. */
  76609. coordinatesMode: number;
  76610. /**
  76611. * Define the camera used to render the texture.
  76612. */
  76613. activeCamera: Nullable<Camera>;
  76614. /**
  76615. * Override the render function of the texture with your own one.
  76616. */
  76617. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76618. /**
  76619. * Define if camera post processes should be use while rendering the texture.
  76620. */
  76621. useCameraPostProcesses: boolean;
  76622. /**
  76623. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76624. */
  76625. ignoreCameraViewport: boolean;
  76626. private _postProcessManager;
  76627. private _postProcesses;
  76628. private _resizeObserver;
  76629. /**
  76630. * An event triggered when the texture is unbind.
  76631. */
  76632. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76633. /**
  76634. * An event triggered when the texture is unbind.
  76635. */
  76636. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76637. private _onAfterUnbindObserver;
  76638. /**
  76639. * Set a after unbind callback in the texture.
  76640. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76641. */
  76642. onAfterUnbind: () => void;
  76643. /**
  76644. * An event triggered before rendering the texture
  76645. */
  76646. onBeforeRenderObservable: Observable<number>;
  76647. private _onBeforeRenderObserver;
  76648. /**
  76649. * Set a before render callback in the texture.
  76650. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76651. */
  76652. onBeforeRender: (faceIndex: number) => void;
  76653. /**
  76654. * An event triggered after rendering the texture
  76655. */
  76656. onAfterRenderObservable: Observable<number>;
  76657. private _onAfterRenderObserver;
  76658. /**
  76659. * Set a after render callback in the texture.
  76660. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76661. */
  76662. onAfterRender: (faceIndex: number) => void;
  76663. /**
  76664. * An event triggered after the texture clear
  76665. */
  76666. onClearObservable: Observable<Engine>;
  76667. private _onClearObserver;
  76668. /**
  76669. * Set a clear callback in the texture.
  76670. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76671. */
  76672. onClear: (Engine: Engine) => void;
  76673. /**
  76674. * Define the clear color of the Render Target if it should be different from the scene.
  76675. */
  76676. clearColor: Color4;
  76677. protected _size: number | {
  76678. width: number;
  76679. height: number;
  76680. };
  76681. protected _initialSizeParameter: number | {
  76682. width: number;
  76683. height: number;
  76684. } | {
  76685. ratio: number;
  76686. };
  76687. protected _sizeRatio: Nullable<number>;
  76688. /** @hidden */
  76689. _generateMipMaps: boolean;
  76690. protected _renderingManager: RenderingManager;
  76691. /** @hidden */
  76692. _waitingRenderList: string[];
  76693. protected _doNotChangeAspectRatio: boolean;
  76694. protected _currentRefreshId: number;
  76695. protected _refreshRate: number;
  76696. protected _textureMatrix: Matrix;
  76697. protected _samples: number;
  76698. protected _renderTargetOptions: RenderTargetCreationOptions;
  76699. /**
  76700. * Gets render target creation options that were used.
  76701. */
  76702. readonly renderTargetOptions: RenderTargetCreationOptions;
  76703. protected _engine: Engine;
  76704. protected _onRatioRescale(): void;
  76705. /**
  76706. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76707. * It must define where the camera used to render the texture is set
  76708. */
  76709. boundingBoxPosition: Vector3;
  76710. private _boundingBoxSize;
  76711. /**
  76712. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76713. * When defined, the cubemap will switch to local mode
  76714. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76715. * @example https://www.babylonjs-playground.com/#RNASML
  76716. */
  76717. boundingBoxSize: Vector3;
  76718. /**
  76719. * In case the RTT has been created with a depth texture, get the associated
  76720. * depth texture.
  76721. * Otherwise, return null.
  76722. */
  76723. depthStencilTexture: Nullable<InternalTexture>;
  76724. /**
  76725. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76726. * or used a shadow, depth texture...
  76727. * @param name The friendly name of the texture
  76728. * @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)
  76729. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76730. * @param generateMipMaps True if mip maps need to be generated after render.
  76731. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76732. * @param type The type of the buffer in the RTT (int, half float, float...)
  76733. * @param isCube True if a cube texture needs to be created
  76734. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76735. * @param generateDepthBuffer True to generate a depth buffer
  76736. * @param generateStencilBuffer True to generate a stencil buffer
  76737. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76738. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76739. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76740. */
  76741. constructor(name: string, size: number | {
  76742. width: number;
  76743. height: number;
  76744. } | {
  76745. ratio: number;
  76746. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76747. /**
  76748. * Creates a depth stencil texture.
  76749. * This is only available in WebGL 2 or with the depth texture extension available.
  76750. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76751. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76752. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76753. */
  76754. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76755. private _processSizeParameter;
  76756. /**
  76757. * Define the number of samples to use in case of MSAA.
  76758. * It defaults to one meaning no MSAA has been enabled.
  76759. */
  76760. samples: number;
  76761. /**
  76762. * Resets the refresh counter of the texture and start bak from scratch.
  76763. * Could be useful to regenerate the texture if it is setup to render only once.
  76764. */
  76765. resetRefreshCounter(): void;
  76766. /**
  76767. * Define the refresh rate of the texture or the rendering frequency.
  76768. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76769. */
  76770. refreshRate: number;
  76771. /**
  76772. * Adds a post process to the render target rendering passes.
  76773. * @param postProcess define the post process to add
  76774. */
  76775. addPostProcess(postProcess: PostProcess): void;
  76776. /**
  76777. * Clear all the post processes attached to the render target
  76778. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76779. */
  76780. clearPostProcesses(dispose?: boolean): void;
  76781. /**
  76782. * Remove one of the post process from the list of attached post processes to the texture
  76783. * @param postProcess define the post process to remove from the list
  76784. */
  76785. removePostProcess(postProcess: PostProcess): void;
  76786. /** @hidden */
  76787. _shouldRender(): boolean;
  76788. /**
  76789. * Gets the actual render size of the texture.
  76790. * @returns the width of the render size
  76791. */
  76792. getRenderSize(): number;
  76793. /**
  76794. * Gets the actual render width of the texture.
  76795. * @returns the width of the render size
  76796. */
  76797. getRenderWidth(): number;
  76798. /**
  76799. * Gets the actual render height of the texture.
  76800. * @returns the height of the render size
  76801. */
  76802. getRenderHeight(): number;
  76803. /**
  76804. * Get if the texture can be rescaled or not.
  76805. */
  76806. readonly canRescale: boolean;
  76807. /**
  76808. * Resize the texture using a ratio.
  76809. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76810. */
  76811. scale(ratio: number): void;
  76812. /**
  76813. * Get the texture reflection matrix used to rotate/transform the reflection.
  76814. * @returns the reflection matrix
  76815. */
  76816. getReflectionTextureMatrix(): Matrix;
  76817. /**
  76818. * Resize the texture to a new desired size.
  76819. * Be carrefull as it will recreate all the data in the new texture.
  76820. * @param size Define the new size. It can be:
  76821. * - a number for squared texture,
  76822. * - an object containing { width: number, height: number }
  76823. * - or an object containing a ratio { ratio: number }
  76824. */
  76825. resize(size: number | {
  76826. width: number;
  76827. height: number;
  76828. } | {
  76829. ratio: number;
  76830. }): void;
  76831. /**
  76832. * Renders all the objects from the render list into the texture.
  76833. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76834. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76835. */
  76836. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76837. private _bestReflectionRenderTargetDimension;
  76838. /**
  76839. * @hidden
  76840. * @param faceIndex face index to bind to if this is a cubetexture
  76841. */
  76842. _bindFrameBuffer(faceIndex?: number): void;
  76843. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76844. private renderToTarget;
  76845. /**
  76846. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76847. * This allowed control for front to back rendering or reversly depending of the special needs.
  76848. *
  76849. * @param renderingGroupId The rendering group id corresponding to its index
  76850. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76851. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76852. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76853. */
  76854. 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;
  76855. /**
  76856. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76857. *
  76858. * @param renderingGroupId The rendering group id corresponding to its index
  76859. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76860. */
  76861. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76862. /**
  76863. * Clones the texture.
  76864. * @returns the cloned texture
  76865. */
  76866. clone(): RenderTargetTexture;
  76867. /**
  76868. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76869. * @returns The JSON representation of the texture
  76870. */
  76871. serialize(): any;
  76872. /**
  76873. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76874. */
  76875. disposeFramebufferObjects(): void;
  76876. /**
  76877. * Dispose the texture and release its associated resources.
  76878. */
  76879. dispose(): void;
  76880. /** @hidden */
  76881. _rebuild(): void;
  76882. /**
  76883. * Clear the info related to rendering groups preventing retention point in material dispose.
  76884. */
  76885. freeRenderingGroups(): void;
  76886. /**
  76887. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  76888. * @returns the view count
  76889. */
  76890. getViewCount(): number;
  76891. }
  76892. }
  76893. declare module BABYLON {
  76894. /**
  76895. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76896. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76897. * You can then easily use it as a reflectionTexture on a flat surface.
  76898. * In case the surface is not a plane, please consider relying on reflection probes.
  76899. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76900. */
  76901. export class MirrorTexture extends RenderTargetTexture {
  76902. private scene;
  76903. /**
  76904. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76905. * 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.
  76906. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76907. */
  76908. mirrorPlane: Plane;
  76909. /**
  76910. * Define the blur ratio used to blur the reflection if needed.
  76911. */
  76912. blurRatio: number;
  76913. /**
  76914. * Define the adaptive blur kernel used to blur the reflection if needed.
  76915. * This will autocompute the closest best match for the `blurKernel`
  76916. */
  76917. adaptiveBlurKernel: number;
  76918. /**
  76919. * Define the blur kernel used to blur the reflection if needed.
  76920. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76921. */
  76922. blurKernel: number;
  76923. /**
  76924. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76925. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76926. */
  76927. blurKernelX: number;
  76928. /**
  76929. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76930. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76931. */
  76932. blurKernelY: number;
  76933. private _autoComputeBlurKernel;
  76934. protected _onRatioRescale(): void;
  76935. private _updateGammaSpace;
  76936. private _imageProcessingConfigChangeObserver;
  76937. private _transformMatrix;
  76938. private _mirrorMatrix;
  76939. private _savedViewMatrix;
  76940. private _blurX;
  76941. private _blurY;
  76942. private _adaptiveBlurKernel;
  76943. private _blurKernelX;
  76944. private _blurKernelY;
  76945. private _blurRatio;
  76946. /**
  76947. * Instantiates a Mirror Texture.
  76948. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76949. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76950. * You can then easily use it as a reflectionTexture on a flat surface.
  76951. * In case the surface is not a plane, please consider relying on reflection probes.
  76952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76953. * @param name
  76954. * @param size
  76955. * @param scene
  76956. * @param generateMipMaps
  76957. * @param type
  76958. * @param samplingMode
  76959. * @param generateDepthBuffer
  76960. */
  76961. constructor(name: string, size: number | {
  76962. width: number;
  76963. height: number;
  76964. } | {
  76965. ratio: number;
  76966. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76967. private _preparePostProcesses;
  76968. /**
  76969. * Clone the mirror texture.
  76970. * @returns the cloned texture
  76971. */
  76972. clone(): MirrorTexture;
  76973. /**
  76974. * Serialize the texture to a JSON representation you could use in Parse later on
  76975. * @returns the serialized JSON representation
  76976. */
  76977. serialize(): any;
  76978. /**
  76979. * Dispose the texture and release its associated resources.
  76980. */
  76981. dispose(): void;
  76982. }
  76983. }
  76984. declare module BABYLON {
  76985. /**
  76986. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76987. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76988. */
  76989. export class Texture extends BaseTexture {
  76990. /** @hidden */
  76991. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76992. /** @hidden */
  76993. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76994. /** @hidden */
  76995. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76996. /** nearest is mag = nearest and min = nearest and mip = linear */
  76997. static readonly NEAREST_SAMPLINGMODE: number;
  76998. /** nearest is mag = nearest and min = nearest and mip = linear */
  76999. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77000. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77001. static readonly BILINEAR_SAMPLINGMODE: number;
  77002. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77003. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77004. /** Trilinear is mag = linear and min = linear and mip = linear */
  77005. static readonly TRILINEAR_SAMPLINGMODE: number;
  77006. /** Trilinear is mag = linear and min = linear and mip = linear */
  77007. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77008. /** mag = nearest and min = nearest and mip = nearest */
  77009. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77010. /** mag = nearest and min = linear and mip = nearest */
  77011. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77012. /** mag = nearest and min = linear and mip = linear */
  77013. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77014. /** mag = nearest and min = linear and mip = none */
  77015. static readonly NEAREST_LINEAR: number;
  77016. /** mag = nearest and min = nearest and mip = none */
  77017. static readonly NEAREST_NEAREST: number;
  77018. /** mag = linear and min = nearest and mip = nearest */
  77019. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77020. /** mag = linear and min = nearest and mip = linear */
  77021. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77022. /** mag = linear and min = linear and mip = none */
  77023. static readonly LINEAR_LINEAR: number;
  77024. /** mag = linear and min = nearest and mip = none */
  77025. static readonly LINEAR_NEAREST: number;
  77026. /** Explicit coordinates mode */
  77027. static readonly EXPLICIT_MODE: number;
  77028. /** Spherical coordinates mode */
  77029. static readonly SPHERICAL_MODE: number;
  77030. /** Planar coordinates mode */
  77031. static readonly PLANAR_MODE: number;
  77032. /** Cubic coordinates mode */
  77033. static readonly CUBIC_MODE: number;
  77034. /** Projection coordinates mode */
  77035. static readonly PROJECTION_MODE: number;
  77036. /** Inverse Cubic coordinates mode */
  77037. static readonly SKYBOX_MODE: number;
  77038. /** Inverse Cubic coordinates mode */
  77039. static readonly INVCUBIC_MODE: number;
  77040. /** Equirectangular coordinates mode */
  77041. static readonly EQUIRECTANGULAR_MODE: number;
  77042. /** Equirectangular Fixed coordinates mode */
  77043. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77044. /** Equirectangular Fixed Mirrored coordinates mode */
  77045. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77046. /** Texture is not repeating outside of 0..1 UVs */
  77047. static readonly CLAMP_ADDRESSMODE: number;
  77048. /** Texture is repeating outside of 0..1 UVs */
  77049. static readonly WRAP_ADDRESSMODE: number;
  77050. /** Texture is repeating and mirrored */
  77051. static readonly MIRROR_ADDRESSMODE: number;
  77052. /**
  77053. * 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
  77054. */
  77055. static UseSerializedUrlIfAny: boolean;
  77056. /**
  77057. * Define the url of the texture.
  77058. */
  77059. url: Nullable<string>;
  77060. /**
  77061. * Define an offset on the texture to offset the u coordinates of the UVs
  77062. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77063. */
  77064. uOffset: number;
  77065. /**
  77066. * Define an offset on the texture to offset the v coordinates of the UVs
  77067. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77068. */
  77069. vOffset: number;
  77070. /**
  77071. * Define an offset on the texture to scale the u coordinates of the UVs
  77072. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77073. */
  77074. uScale: number;
  77075. /**
  77076. * Define an offset on the texture to scale the v coordinates of the UVs
  77077. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77078. */
  77079. vScale: number;
  77080. /**
  77081. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77082. * @see http://doc.babylonjs.com/how_to/more_materials
  77083. */
  77084. uAng: number;
  77085. /**
  77086. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77087. * @see http://doc.babylonjs.com/how_to/more_materials
  77088. */
  77089. vAng: number;
  77090. /**
  77091. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77092. * @see http://doc.babylonjs.com/how_to/more_materials
  77093. */
  77094. wAng: number;
  77095. /**
  77096. * Defines the center of rotation (U)
  77097. */
  77098. uRotationCenter: number;
  77099. /**
  77100. * Defines the center of rotation (V)
  77101. */
  77102. vRotationCenter: number;
  77103. /**
  77104. * Defines the center of rotation (W)
  77105. */
  77106. wRotationCenter: number;
  77107. /**
  77108. * Are mip maps generated for this texture or not.
  77109. */
  77110. readonly noMipmap: boolean;
  77111. /**
  77112. * List of inspectable custom properties (used by the Inspector)
  77113. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77114. */
  77115. inspectableCustomProperties: IInspectable[];
  77116. private _noMipmap;
  77117. /** @hidden */
  77118. _invertY: boolean;
  77119. private _rowGenerationMatrix;
  77120. private _cachedTextureMatrix;
  77121. private _projectionModeMatrix;
  77122. private _t0;
  77123. private _t1;
  77124. private _t2;
  77125. private _cachedUOffset;
  77126. private _cachedVOffset;
  77127. private _cachedUScale;
  77128. private _cachedVScale;
  77129. private _cachedUAng;
  77130. private _cachedVAng;
  77131. private _cachedWAng;
  77132. private _cachedProjectionMatrixId;
  77133. private _cachedCoordinatesMode;
  77134. /** @hidden */
  77135. protected _initialSamplingMode: number;
  77136. /** @hidden */
  77137. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77138. private _deleteBuffer;
  77139. protected _format: Nullable<number>;
  77140. private _delayedOnLoad;
  77141. private _delayedOnError;
  77142. /**
  77143. * Observable triggered once the texture has been loaded.
  77144. */
  77145. onLoadObservable: Observable<Texture>;
  77146. protected _isBlocking: boolean;
  77147. /**
  77148. * Is the texture preventing material to render while loading.
  77149. * If false, a default texture will be used instead of the loading one during the preparation step.
  77150. */
  77151. isBlocking: boolean;
  77152. /**
  77153. * Get the current sampling mode associated with the texture.
  77154. */
  77155. readonly samplingMode: number;
  77156. /**
  77157. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77158. */
  77159. readonly invertY: boolean;
  77160. /**
  77161. * Instantiates a new texture.
  77162. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77163. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77164. * @param url define the url of the picture to load as a texture
  77165. * @param scene define the scene the texture will belong to
  77166. * @param noMipmap define if the texture will require mip maps or not
  77167. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77168. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77169. * @param onLoad define a callback triggered when the texture has been loaded
  77170. * @param onError define a callback triggered when an error occurred during the loading session
  77171. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77172. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77173. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77174. */
  77175. 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);
  77176. /**
  77177. * Update the url (and optional buffer) of this texture if url was null during construction.
  77178. * @param url the url of the texture
  77179. * @param buffer the buffer of the texture (defaults to null)
  77180. * @param onLoad callback called when the texture is loaded (defaults to null)
  77181. */
  77182. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77183. /**
  77184. * Finish the loading sequence of a texture flagged as delayed load.
  77185. * @hidden
  77186. */
  77187. delayLoad(): void;
  77188. private _prepareRowForTextureGeneration;
  77189. /**
  77190. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77191. * @returns the transform matrix of the texture.
  77192. */
  77193. getTextureMatrix(): Matrix;
  77194. /**
  77195. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77196. * @returns The reflection texture transform
  77197. */
  77198. getReflectionTextureMatrix(): Matrix;
  77199. /**
  77200. * Clones the texture.
  77201. * @returns the cloned texture
  77202. */
  77203. clone(): Texture;
  77204. /**
  77205. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77206. * @returns The JSON representation of the texture
  77207. */
  77208. serialize(): any;
  77209. /**
  77210. * Get the current class name of the texture useful for serialization or dynamic coding.
  77211. * @returns "Texture"
  77212. */
  77213. getClassName(): string;
  77214. /**
  77215. * Dispose the texture and release its associated resources.
  77216. */
  77217. dispose(): void;
  77218. /**
  77219. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77220. * @param parsedTexture Define the JSON representation of the texture
  77221. * @param scene Define the scene the parsed texture should be instantiated in
  77222. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77223. * @returns The parsed texture if successful
  77224. */
  77225. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77226. /**
  77227. * Creates a texture from its base 64 representation.
  77228. * @param data Define the base64 payload without the data: prefix
  77229. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77230. * @param scene Define the scene the texture should belong to
  77231. * @param noMipmap Forces the texture to not create mip map information if true
  77232. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77233. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77234. * @param onLoad define a callback triggered when the texture has been loaded
  77235. * @param onError define a callback triggered when an error occurred during the loading session
  77236. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77237. * @returns the created texture
  77238. */
  77239. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77240. /**
  77241. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77242. * @param data Define the base64 payload without the data: prefix
  77243. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77244. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77245. * @param scene Define the scene the texture should belong to
  77246. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77247. * @param noMipmap Forces the texture to not create mip map information if true
  77248. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77249. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77250. * @param onLoad define a callback triggered when the texture has been loaded
  77251. * @param onError define a callback triggered when an error occurred during the loading session
  77252. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77253. * @returns the created texture
  77254. */
  77255. 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;
  77256. }
  77257. }
  77258. declare module BABYLON {
  77259. /**
  77260. * Raw texture can help creating a texture directly from an array of data.
  77261. * This can be super useful if you either get the data from an uncompressed source or
  77262. * if you wish to create your texture pixel by pixel.
  77263. */
  77264. export class RawTexture extends Texture {
  77265. /**
  77266. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77267. */
  77268. format: number;
  77269. private _engine;
  77270. /**
  77271. * Instantiates a new RawTexture.
  77272. * Raw texture can help creating a texture directly from an array of data.
  77273. * This can be super useful if you either get the data from an uncompressed source or
  77274. * if you wish to create your texture pixel by pixel.
  77275. * @param data define the array of data to use to create the texture
  77276. * @param width define the width of the texture
  77277. * @param height define the height of the texture
  77278. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77279. * @param scene define the scene the texture belongs to
  77280. * @param generateMipMaps define whether mip maps should be generated or not
  77281. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77282. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77283. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77284. */
  77285. constructor(data: ArrayBufferView, width: number, height: number,
  77286. /**
  77287. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77288. */
  77289. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77290. /**
  77291. * Updates the texture underlying data.
  77292. * @param data Define the new data of the texture
  77293. */
  77294. update(data: ArrayBufferView): void;
  77295. /**
  77296. * Creates a luminance texture from some data.
  77297. * @param data Define the texture data
  77298. * @param width Define the width of the texture
  77299. * @param height Define the height of the texture
  77300. * @param scene Define the scene the texture belongs to
  77301. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77302. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77303. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77304. * @returns the luminance texture
  77305. */
  77306. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77307. /**
  77308. * Creates a luminance alpha texture from some data.
  77309. * @param data Define the texture data
  77310. * @param width Define the width of the texture
  77311. * @param height Define the height of the texture
  77312. * @param scene Define the scene the texture belongs to
  77313. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77316. * @returns the luminance alpha texture
  77317. */
  77318. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77319. /**
  77320. * Creates an alpha texture from some data.
  77321. * @param data Define the texture data
  77322. * @param width Define the width of the texture
  77323. * @param height Define the height of the texture
  77324. * @param scene Define the scene the texture belongs to
  77325. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77326. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77327. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77328. * @returns the alpha texture
  77329. */
  77330. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77331. /**
  77332. * Creates a RGB texture from some data.
  77333. * @param data Define the texture data
  77334. * @param width Define the width of the texture
  77335. * @param height Define the height of the texture
  77336. * @param scene Define the scene the texture belongs to
  77337. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77338. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77339. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77340. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77341. * @returns the RGB alpha texture
  77342. */
  77343. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77344. /**
  77345. * Creates a RGBA texture from some data.
  77346. * @param data Define the texture data
  77347. * @param width Define the width of the texture
  77348. * @param height Define the height of the texture
  77349. * @param scene Define the scene the texture belongs to
  77350. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77351. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77352. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77353. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77354. * @returns the RGBA texture
  77355. */
  77356. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77357. /**
  77358. * Creates a R texture from some data.
  77359. * @param data Define the texture data
  77360. * @param width Define the width of the texture
  77361. * @param height Define the height of the texture
  77362. * @param scene Define the scene the texture belongs to
  77363. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77364. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77365. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77366. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77367. * @returns the R texture
  77368. */
  77369. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77370. }
  77371. }
  77372. declare module BABYLON {
  77373. /**
  77374. * Defines a runtime animation
  77375. */
  77376. export class RuntimeAnimation {
  77377. private _events;
  77378. /**
  77379. * The current frame of the runtime animation
  77380. */
  77381. private _currentFrame;
  77382. /**
  77383. * The animation used by the runtime animation
  77384. */
  77385. private _animation;
  77386. /**
  77387. * The target of the runtime animation
  77388. */
  77389. private _target;
  77390. /**
  77391. * The initiating animatable
  77392. */
  77393. private _host;
  77394. /**
  77395. * The original value of the runtime animation
  77396. */
  77397. private _originalValue;
  77398. /**
  77399. * The original blend value of the runtime animation
  77400. */
  77401. private _originalBlendValue;
  77402. /**
  77403. * The offsets cache of the runtime animation
  77404. */
  77405. private _offsetsCache;
  77406. /**
  77407. * The high limits cache of the runtime animation
  77408. */
  77409. private _highLimitsCache;
  77410. /**
  77411. * Specifies if the runtime animation has been stopped
  77412. */
  77413. private _stopped;
  77414. /**
  77415. * The blending factor of the runtime animation
  77416. */
  77417. private _blendingFactor;
  77418. /**
  77419. * The BabylonJS scene
  77420. */
  77421. private _scene;
  77422. /**
  77423. * The current value of the runtime animation
  77424. */
  77425. private _currentValue;
  77426. /** @hidden */
  77427. _workValue: any;
  77428. /**
  77429. * The active target of the runtime animation
  77430. */
  77431. private _activeTarget;
  77432. /**
  77433. * The target path of the runtime animation
  77434. */
  77435. private _targetPath;
  77436. /**
  77437. * The weight of the runtime animation
  77438. */
  77439. private _weight;
  77440. /**
  77441. * The ratio offset of the runtime animation
  77442. */
  77443. private _ratioOffset;
  77444. /**
  77445. * The previous delay of the runtime animation
  77446. */
  77447. private _previousDelay;
  77448. /**
  77449. * The previous ratio of the runtime animation
  77450. */
  77451. private _previousRatio;
  77452. /**
  77453. * Gets the current frame of the runtime animation
  77454. */
  77455. readonly currentFrame: number;
  77456. /**
  77457. * Gets the weight of the runtime animation
  77458. */
  77459. readonly weight: number;
  77460. /**
  77461. * Gets the current value of the runtime animation
  77462. */
  77463. readonly currentValue: any;
  77464. /**
  77465. * Gets the target path of the runtime animation
  77466. */
  77467. readonly targetPath: string;
  77468. /**
  77469. * Gets the actual target of the runtime animation
  77470. */
  77471. readonly target: any;
  77472. /**
  77473. * Create a new RuntimeAnimation object
  77474. * @param target defines the target of the animation
  77475. * @param animation defines the source animation object
  77476. * @param scene defines the hosting scene
  77477. * @param host defines the initiating Animatable
  77478. */
  77479. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77480. /**
  77481. * Gets the animation from the runtime animation
  77482. */
  77483. readonly animation: Animation;
  77484. /**
  77485. * Resets the runtime animation to the beginning
  77486. * @param restoreOriginal defines whether to restore the target property to the original value
  77487. */
  77488. reset(restoreOriginal?: boolean): void;
  77489. /**
  77490. * Specifies if the runtime animation is stopped
  77491. * @returns Boolean specifying if the runtime animation is stopped
  77492. */
  77493. isStopped(): boolean;
  77494. /**
  77495. * Disposes of the runtime animation
  77496. */
  77497. dispose(): void;
  77498. /**
  77499. * Interpolates the animation from the current frame
  77500. * @param currentFrame The frame to interpolate the animation to
  77501. * @param repeatCount The number of times that the animation should loop
  77502. * @param loopMode The type of looping mode to use
  77503. * @param offsetValue Animation offset value
  77504. * @param highLimitValue The high limit value
  77505. * @returns The interpolated value
  77506. */
  77507. private _interpolate;
  77508. /**
  77509. * Apply the interpolated value to the target
  77510. * @param currentValue defines the value computed by the animation
  77511. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77512. */
  77513. setValue(currentValue: any, weight?: number): void;
  77514. private _setValue;
  77515. /**
  77516. * Gets the loop pmode of the runtime animation
  77517. * @returns Loop Mode
  77518. */
  77519. private _getCorrectLoopMode;
  77520. /**
  77521. * Move the current animation to a given frame
  77522. * @param frame defines the frame to move to
  77523. */
  77524. goToFrame(frame: number): void;
  77525. /**
  77526. * @hidden Internal use only
  77527. */
  77528. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77529. /**
  77530. * Execute the current animation
  77531. * @param delay defines the delay to add to the current frame
  77532. * @param from defines the lower bound of the animation range
  77533. * @param to defines the upper bound of the animation range
  77534. * @param loop defines if the current animation must loop
  77535. * @param speedRatio defines the current speed ratio
  77536. * @param weight defines the weight of the animation (default is -1 so no weight)
  77537. * @param onLoop optional callback called when animation loops
  77538. * @returns a boolean indicating if the animation is running
  77539. */
  77540. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77541. }
  77542. }
  77543. declare module BABYLON {
  77544. /**
  77545. * Class used to store an actual running animation
  77546. */
  77547. export class Animatable {
  77548. /** defines the target object */
  77549. target: any;
  77550. /** defines the starting frame number (default is 0) */
  77551. fromFrame: number;
  77552. /** defines the ending frame number (default is 100) */
  77553. toFrame: number;
  77554. /** defines if the animation must loop (default is false) */
  77555. loopAnimation: boolean;
  77556. /** defines a callback to call when animation ends if it is not looping */
  77557. onAnimationEnd?: (() => void) | null | undefined;
  77558. /** defines a callback to call when animation loops */
  77559. onAnimationLoop?: (() => void) | null | undefined;
  77560. private _localDelayOffset;
  77561. private _pausedDelay;
  77562. private _runtimeAnimations;
  77563. private _paused;
  77564. private _scene;
  77565. private _speedRatio;
  77566. private _weight;
  77567. private _syncRoot;
  77568. /**
  77569. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77570. * This will only apply for non looping animation (default is true)
  77571. */
  77572. disposeOnEnd: boolean;
  77573. /**
  77574. * Gets a boolean indicating if the animation has started
  77575. */
  77576. animationStarted: boolean;
  77577. /**
  77578. * Observer raised when the animation ends
  77579. */
  77580. onAnimationEndObservable: Observable<Animatable>;
  77581. /**
  77582. * Observer raised when the animation loops
  77583. */
  77584. onAnimationLoopObservable: Observable<Animatable>;
  77585. /**
  77586. * Gets the root Animatable used to synchronize and normalize animations
  77587. */
  77588. readonly syncRoot: Animatable;
  77589. /**
  77590. * Gets the current frame of the first RuntimeAnimation
  77591. * Used to synchronize Animatables
  77592. */
  77593. readonly masterFrame: number;
  77594. /**
  77595. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77596. */
  77597. weight: number;
  77598. /**
  77599. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77600. */
  77601. speedRatio: number;
  77602. /**
  77603. * Creates a new Animatable
  77604. * @param scene defines the hosting scene
  77605. * @param target defines the target object
  77606. * @param fromFrame defines the starting frame number (default is 0)
  77607. * @param toFrame defines the ending frame number (default is 100)
  77608. * @param loopAnimation defines if the animation must loop (default is false)
  77609. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77610. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77611. * @param animations defines a group of animation to add to the new Animatable
  77612. * @param onAnimationLoop defines a callback to call when animation loops
  77613. */
  77614. constructor(scene: Scene,
  77615. /** defines the target object */
  77616. target: any,
  77617. /** defines the starting frame number (default is 0) */
  77618. fromFrame?: number,
  77619. /** defines the ending frame number (default is 100) */
  77620. toFrame?: number,
  77621. /** defines if the animation must loop (default is false) */
  77622. loopAnimation?: boolean, speedRatio?: number,
  77623. /** defines a callback to call when animation ends if it is not looping */
  77624. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77625. /** defines a callback to call when animation loops */
  77626. onAnimationLoop?: (() => void) | null | undefined);
  77627. /**
  77628. * Synchronize and normalize current Animatable with a source Animatable
  77629. * This is useful when using animation weights and when animations are not of the same length
  77630. * @param root defines the root Animatable to synchronize with
  77631. * @returns the current Animatable
  77632. */
  77633. syncWith(root: Animatable): Animatable;
  77634. /**
  77635. * Gets the list of runtime animations
  77636. * @returns an array of RuntimeAnimation
  77637. */
  77638. getAnimations(): RuntimeAnimation[];
  77639. /**
  77640. * Adds more animations to the current animatable
  77641. * @param target defines the target of the animations
  77642. * @param animations defines the new animations to add
  77643. */
  77644. appendAnimations(target: any, animations: Animation[]): void;
  77645. /**
  77646. * Gets the source animation for a specific property
  77647. * @param property defines the propertyu to look for
  77648. * @returns null or the source animation for the given property
  77649. */
  77650. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77651. /**
  77652. * Gets the runtime animation for a specific property
  77653. * @param property defines the propertyu to look for
  77654. * @returns null or the runtime animation for the given property
  77655. */
  77656. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77657. /**
  77658. * Resets the animatable to its original state
  77659. */
  77660. reset(): void;
  77661. /**
  77662. * Allows the animatable to blend with current running animations
  77663. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77664. * @param blendingSpeed defines the blending speed to use
  77665. */
  77666. enableBlending(blendingSpeed: number): void;
  77667. /**
  77668. * Disable animation blending
  77669. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77670. */
  77671. disableBlending(): void;
  77672. /**
  77673. * Jump directly to a given frame
  77674. * @param frame defines the frame to jump to
  77675. */
  77676. goToFrame(frame: number): void;
  77677. /**
  77678. * Pause the animation
  77679. */
  77680. pause(): void;
  77681. /**
  77682. * Restart the animation
  77683. */
  77684. restart(): void;
  77685. private _raiseOnAnimationEnd;
  77686. /**
  77687. * Stop and delete the current animation
  77688. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77689. * @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)
  77690. */
  77691. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77692. /**
  77693. * Wait asynchronously for the animation to end
  77694. * @returns a promise which will be fullfilled when the animation ends
  77695. */
  77696. waitAsync(): Promise<Animatable>;
  77697. /** @hidden */
  77698. _animate(delay: number): boolean;
  77699. }
  77700. interface Scene {
  77701. /** @hidden */
  77702. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77703. /** @hidden */
  77704. _processLateAnimationBindingsForMatrices(holder: {
  77705. totalWeight: number;
  77706. animations: RuntimeAnimation[];
  77707. originalValue: Matrix;
  77708. }): any;
  77709. /** @hidden */
  77710. _processLateAnimationBindingsForQuaternions(holder: {
  77711. totalWeight: number;
  77712. animations: RuntimeAnimation[];
  77713. originalValue: Quaternion;
  77714. }, refQuaternion: Quaternion): Quaternion;
  77715. /** @hidden */
  77716. _processLateAnimationBindings(): void;
  77717. /**
  77718. * Will start the animation sequence of a given target
  77719. * @param target defines the target
  77720. * @param from defines from which frame should animation start
  77721. * @param to defines until which frame should animation run.
  77722. * @param weight defines the weight to apply to the animation (1.0 by default)
  77723. * @param loop defines if the animation loops
  77724. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77725. * @param onAnimationEnd defines the function to be executed when the animation ends
  77726. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77727. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77728. * @param onAnimationLoop defines the callback to call when an animation loops
  77729. * @returns the animatable object created for this animation
  77730. */
  77731. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77732. /**
  77733. * Will start the animation sequence of a given target
  77734. * @param target defines the target
  77735. * @param from defines from which frame should animation start
  77736. * @param to defines until which frame should animation run.
  77737. * @param loop defines if the animation loops
  77738. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77739. * @param onAnimationEnd defines the function to be executed when the animation ends
  77740. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77741. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77742. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77743. * @param onAnimationLoop defines the callback to call when an animation loops
  77744. * @returns the animatable object created for this animation
  77745. */
  77746. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77747. /**
  77748. * Will start the animation sequence of a given target and its hierarchy
  77749. * @param target defines the target
  77750. * @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.
  77751. * @param from defines from which frame should animation start
  77752. * @param to defines until which frame should animation run.
  77753. * @param loop defines if the animation loops
  77754. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77755. * @param onAnimationEnd defines the function to be executed when the animation ends
  77756. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77757. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77758. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77759. * @param onAnimationLoop defines the callback to call when an animation loops
  77760. * @returns the list of created animatables
  77761. */
  77762. 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[];
  77763. /**
  77764. * Begin a new animation on a given node
  77765. * @param target defines the target where the animation will take place
  77766. * @param animations defines the list of animations to start
  77767. * @param from defines the initial value
  77768. * @param to defines the final value
  77769. * @param loop defines if you want animation to loop (off by default)
  77770. * @param speedRatio defines the speed ratio to apply to all animations
  77771. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77772. * @param onAnimationLoop defines the callback to call when an animation loops
  77773. * @returns the list of created animatables
  77774. */
  77775. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77776. /**
  77777. * Begin a new animation on a given node and its hierarchy
  77778. * @param target defines the root node where the animation will take place
  77779. * @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.
  77780. * @param animations defines the list of animations to start
  77781. * @param from defines the initial value
  77782. * @param to defines the final value
  77783. * @param loop defines if you want animation to loop (off by default)
  77784. * @param speedRatio defines the speed ratio to apply to all animations
  77785. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77786. * @param onAnimationLoop defines the callback to call when an animation loops
  77787. * @returns the list of animatables created for all nodes
  77788. */
  77789. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77790. /**
  77791. * Gets the animatable associated with a specific target
  77792. * @param target defines the target of the animatable
  77793. * @returns the required animatable if found
  77794. */
  77795. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77796. /**
  77797. * Gets all animatables associated with a given target
  77798. * @param target defines the target to look animatables for
  77799. * @returns an array of Animatables
  77800. */
  77801. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77802. /**
  77803. * Will stop the animation of the given target
  77804. * @param target - the target
  77805. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77806. * @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)
  77807. */
  77808. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77809. /**
  77810. * Stops and removes all animations that have been applied to the scene
  77811. */
  77812. stopAllAnimations(): void;
  77813. }
  77814. interface Bone {
  77815. /**
  77816. * Copy an animation range from another bone
  77817. * @param source defines the source bone
  77818. * @param rangeName defines the range name to copy
  77819. * @param frameOffset defines the frame offset
  77820. * @param rescaleAsRequired defines if rescaling must be applied if required
  77821. * @param skelDimensionsRatio defines the scaling ratio
  77822. * @returns true if operation was successful
  77823. */
  77824. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77825. }
  77826. }
  77827. declare module BABYLON {
  77828. /**
  77829. * Class used to handle skinning animations
  77830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77831. */
  77832. export class Skeleton implements IAnimatable {
  77833. /** defines the skeleton name */
  77834. name: string;
  77835. /** defines the skeleton Id */
  77836. id: string;
  77837. /**
  77838. * Defines the list of child bones
  77839. */
  77840. bones: Bone[];
  77841. /**
  77842. * Defines an estimate of the dimension of the skeleton at rest
  77843. */
  77844. dimensionsAtRest: Vector3;
  77845. /**
  77846. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77847. */
  77848. needInitialSkinMatrix: boolean;
  77849. /**
  77850. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77851. */
  77852. overrideMesh: Nullable<AbstractMesh>;
  77853. /**
  77854. * Gets the list of animations attached to this skeleton
  77855. */
  77856. animations: Array<Animation>;
  77857. private _scene;
  77858. private _isDirty;
  77859. private _transformMatrices;
  77860. private _transformMatrixTexture;
  77861. private _meshesWithPoseMatrix;
  77862. private _animatables;
  77863. private _identity;
  77864. private _synchronizedWithMesh;
  77865. private _ranges;
  77866. private _lastAbsoluteTransformsUpdateId;
  77867. private _canUseTextureForBones;
  77868. private _uniqueId;
  77869. /** @hidden */
  77870. _numBonesWithLinkedTransformNode: number;
  77871. /**
  77872. * Specifies if the skeleton should be serialized
  77873. */
  77874. doNotSerialize: boolean;
  77875. private _useTextureToStoreBoneMatrices;
  77876. /**
  77877. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77878. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77879. */
  77880. useTextureToStoreBoneMatrices: boolean;
  77881. private _animationPropertiesOverride;
  77882. /**
  77883. * Gets or sets the animation properties override
  77884. */
  77885. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77886. /**
  77887. * List of inspectable custom properties (used by the Inspector)
  77888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77889. */
  77890. inspectableCustomProperties: IInspectable[];
  77891. /**
  77892. * An observable triggered before computing the skeleton's matrices
  77893. */
  77894. onBeforeComputeObservable: Observable<Skeleton>;
  77895. /**
  77896. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77897. */
  77898. readonly isUsingTextureForMatrices: boolean;
  77899. /**
  77900. * Gets the unique ID of this skeleton
  77901. */
  77902. readonly uniqueId: number;
  77903. /**
  77904. * Creates a new skeleton
  77905. * @param name defines the skeleton name
  77906. * @param id defines the skeleton Id
  77907. * @param scene defines the hosting scene
  77908. */
  77909. constructor(
  77910. /** defines the skeleton name */
  77911. name: string,
  77912. /** defines the skeleton Id */
  77913. id: string, scene: Scene);
  77914. /**
  77915. * Gets the current object class name.
  77916. * @return the class name
  77917. */
  77918. getClassName(): string;
  77919. /**
  77920. * Returns an array containing the root bones
  77921. * @returns an array containing the root bones
  77922. */
  77923. getChildren(): Array<Bone>;
  77924. /**
  77925. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77926. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77927. * @returns a Float32Array containing matrices data
  77928. */
  77929. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77930. /**
  77931. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77932. * @returns a raw texture containing the data
  77933. */
  77934. getTransformMatrixTexture(): Nullable<RawTexture>;
  77935. /**
  77936. * Gets the current hosting scene
  77937. * @returns a scene object
  77938. */
  77939. getScene(): Scene;
  77940. /**
  77941. * Gets a string representing the current skeleton data
  77942. * @param fullDetails defines a boolean indicating if we want a verbose version
  77943. * @returns a string representing the current skeleton data
  77944. */
  77945. toString(fullDetails?: boolean): string;
  77946. /**
  77947. * Get bone's index searching by name
  77948. * @param name defines bone's name to search for
  77949. * @return the indice of the bone. Returns -1 if not found
  77950. */
  77951. getBoneIndexByName(name: string): number;
  77952. /**
  77953. * Creater a new animation range
  77954. * @param name defines the name of the range
  77955. * @param from defines the start key
  77956. * @param to defines the end key
  77957. */
  77958. createAnimationRange(name: string, from: number, to: number): void;
  77959. /**
  77960. * Delete a specific animation range
  77961. * @param name defines the name of the range
  77962. * @param deleteFrames defines if frames must be removed as well
  77963. */
  77964. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77965. /**
  77966. * Gets a specific animation range
  77967. * @param name defines the name of the range to look for
  77968. * @returns the requested animation range or null if not found
  77969. */
  77970. getAnimationRange(name: string): Nullable<AnimationRange>;
  77971. /**
  77972. * Gets the list of all animation ranges defined on this skeleton
  77973. * @returns an array
  77974. */
  77975. getAnimationRanges(): Nullable<AnimationRange>[];
  77976. /**
  77977. * Copy animation range from a source skeleton.
  77978. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77979. * @param source defines the source skeleton
  77980. * @param name defines the name of the range to copy
  77981. * @param rescaleAsRequired defines if rescaling must be applied if required
  77982. * @returns true if operation was successful
  77983. */
  77984. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77985. /**
  77986. * Forces the skeleton to go to rest pose
  77987. */
  77988. returnToRest(): void;
  77989. private _getHighestAnimationFrame;
  77990. /**
  77991. * Begin a specific animation range
  77992. * @param name defines the name of the range to start
  77993. * @param loop defines if looping must be turned on (false by default)
  77994. * @param speedRatio defines the speed ratio to apply (1 by default)
  77995. * @param onAnimationEnd defines a callback which will be called when animation will end
  77996. * @returns a new animatable
  77997. */
  77998. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77999. /** @hidden */
  78000. _markAsDirty(): void;
  78001. /** @hidden */
  78002. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78003. /** @hidden */
  78004. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78005. private _computeTransformMatrices;
  78006. /**
  78007. * Build all resources required to render a skeleton
  78008. */
  78009. prepare(): void;
  78010. /**
  78011. * Gets the list of animatables currently running for this skeleton
  78012. * @returns an array of animatables
  78013. */
  78014. getAnimatables(): IAnimatable[];
  78015. /**
  78016. * Clone the current skeleton
  78017. * @param name defines the name of the new skeleton
  78018. * @param id defines the id of the enw skeleton
  78019. * @returns the new skeleton
  78020. */
  78021. clone(name: string, id: string): Skeleton;
  78022. /**
  78023. * Enable animation blending for this skeleton
  78024. * @param blendingSpeed defines the blending speed to apply
  78025. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78026. */
  78027. enableBlending(blendingSpeed?: number): void;
  78028. /**
  78029. * Releases all resources associated with the current skeleton
  78030. */
  78031. dispose(): void;
  78032. /**
  78033. * Serialize the skeleton in a JSON object
  78034. * @returns a JSON object
  78035. */
  78036. serialize(): any;
  78037. /**
  78038. * Creates a new skeleton from serialized data
  78039. * @param parsedSkeleton defines the serialized data
  78040. * @param scene defines the hosting scene
  78041. * @returns a new skeleton
  78042. */
  78043. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78044. /**
  78045. * Compute all node absolute transforms
  78046. * @param forceUpdate defines if computation must be done even if cache is up to date
  78047. */
  78048. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78049. /**
  78050. * Gets the root pose matrix
  78051. * @returns a matrix
  78052. */
  78053. getPoseMatrix(): Nullable<Matrix>;
  78054. /**
  78055. * Sorts bones per internal index
  78056. */
  78057. sortBones(): void;
  78058. private _sortBones;
  78059. }
  78060. }
  78061. declare module BABYLON {
  78062. /**
  78063. * Defines a target to use with MorphTargetManager
  78064. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78065. */
  78066. export class MorphTarget implements IAnimatable {
  78067. /** defines the name of the target */
  78068. name: string;
  78069. /**
  78070. * Gets or sets the list of animations
  78071. */
  78072. animations: Animation[];
  78073. private _scene;
  78074. private _positions;
  78075. private _normals;
  78076. private _tangents;
  78077. private _influence;
  78078. /**
  78079. * Observable raised when the influence changes
  78080. */
  78081. onInfluenceChanged: Observable<boolean>;
  78082. /** @hidden */
  78083. _onDataLayoutChanged: Observable<void>;
  78084. /**
  78085. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78086. */
  78087. influence: number;
  78088. /**
  78089. * Gets or sets the id of the morph Target
  78090. */
  78091. id: string;
  78092. private _animationPropertiesOverride;
  78093. /**
  78094. * Gets or sets the animation properties override
  78095. */
  78096. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78097. /**
  78098. * Creates a new MorphTarget
  78099. * @param name defines the name of the target
  78100. * @param influence defines the influence to use
  78101. * @param scene defines the scene the morphtarget belongs to
  78102. */
  78103. constructor(
  78104. /** defines the name of the target */
  78105. name: string, influence?: number, scene?: Nullable<Scene>);
  78106. /**
  78107. * Gets a boolean defining if the target contains position data
  78108. */
  78109. readonly hasPositions: boolean;
  78110. /**
  78111. * Gets a boolean defining if the target contains normal data
  78112. */
  78113. readonly hasNormals: boolean;
  78114. /**
  78115. * Gets a boolean defining if the target contains tangent data
  78116. */
  78117. readonly hasTangents: boolean;
  78118. /**
  78119. * Affects position data to this target
  78120. * @param data defines the position data to use
  78121. */
  78122. setPositions(data: Nullable<FloatArray>): void;
  78123. /**
  78124. * Gets the position data stored in this target
  78125. * @returns a FloatArray containing the position data (or null if not present)
  78126. */
  78127. getPositions(): Nullable<FloatArray>;
  78128. /**
  78129. * Affects normal data to this target
  78130. * @param data defines the normal data to use
  78131. */
  78132. setNormals(data: Nullable<FloatArray>): void;
  78133. /**
  78134. * Gets the normal data stored in this target
  78135. * @returns a FloatArray containing the normal data (or null if not present)
  78136. */
  78137. getNormals(): Nullable<FloatArray>;
  78138. /**
  78139. * Affects tangent data to this target
  78140. * @param data defines the tangent data to use
  78141. */
  78142. setTangents(data: Nullable<FloatArray>): void;
  78143. /**
  78144. * Gets the tangent data stored in this target
  78145. * @returns a FloatArray containing the tangent data (or null if not present)
  78146. */
  78147. getTangents(): Nullable<FloatArray>;
  78148. /**
  78149. * Serializes the current target into a Serialization object
  78150. * @returns the serialized object
  78151. */
  78152. serialize(): any;
  78153. /**
  78154. * Returns the string "MorphTarget"
  78155. * @returns "MorphTarget"
  78156. */
  78157. getClassName(): string;
  78158. /**
  78159. * Creates a new target from serialized data
  78160. * @param serializationObject defines the serialized data to use
  78161. * @returns a new MorphTarget
  78162. */
  78163. static Parse(serializationObject: any): MorphTarget;
  78164. /**
  78165. * Creates a MorphTarget from mesh data
  78166. * @param mesh defines the source mesh
  78167. * @param name defines the name to use for the new target
  78168. * @param influence defines the influence to attach to the target
  78169. * @returns a new MorphTarget
  78170. */
  78171. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78172. }
  78173. }
  78174. declare module BABYLON {
  78175. /**
  78176. * This class is used to deform meshes using morphing between different targets
  78177. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78178. */
  78179. export class MorphTargetManager {
  78180. private _targets;
  78181. private _targetInfluenceChangedObservers;
  78182. private _targetDataLayoutChangedObservers;
  78183. private _activeTargets;
  78184. private _scene;
  78185. private _influences;
  78186. private _supportsNormals;
  78187. private _supportsTangents;
  78188. private _vertexCount;
  78189. private _uniqueId;
  78190. private _tempInfluences;
  78191. /**
  78192. * Creates a new MorphTargetManager
  78193. * @param scene defines the current scene
  78194. */
  78195. constructor(scene?: Nullable<Scene>);
  78196. /**
  78197. * Gets the unique ID of this manager
  78198. */
  78199. readonly uniqueId: number;
  78200. /**
  78201. * Gets the number of vertices handled by this manager
  78202. */
  78203. readonly vertexCount: number;
  78204. /**
  78205. * Gets a boolean indicating if this manager supports morphing of normals
  78206. */
  78207. readonly supportsNormals: boolean;
  78208. /**
  78209. * Gets a boolean indicating if this manager supports morphing of tangents
  78210. */
  78211. readonly supportsTangents: boolean;
  78212. /**
  78213. * Gets the number of targets stored in this manager
  78214. */
  78215. readonly numTargets: number;
  78216. /**
  78217. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78218. */
  78219. readonly numInfluencers: number;
  78220. /**
  78221. * Gets the list of influences (one per target)
  78222. */
  78223. readonly influences: Float32Array;
  78224. /**
  78225. * Gets the active target at specified index. An active target is a target with an influence > 0
  78226. * @param index defines the index to check
  78227. * @returns the requested target
  78228. */
  78229. getActiveTarget(index: number): MorphTarget;
  78230. /**
  78231. * Gets the target at specified index
  78232. * @param index defines the index to check
  78233. * @returns the requested target
  78234. */
  78235. getTarget(index: number): MorphTarget;
  78236. /**
  78237. * Add a new target to this manager
  78238. * @param target defines the target to add
  78239. */
  78240. addTarget(target: MorphTarget): void;
  78241. /**
  78242. * Removes a target from the manager
  78243. * @param target defines the target to remove
  78244. */
  78245. removeTarget(target: MorphTarget): void;
  78246. /**
  78247. * Serializes the current manager into a Serialization object
  78248. * @returns the serialized object
  78249. */
  78250. serialize(): any;
  78251. private _syncActiveTargets;
  78252. /**
  78253. * Syncrhonize the targets with all the meshes using this morph target manager
  78254. */
  78255. synchronize(): void;
  78256. /**
  78257. * Creates a new MorphTargetManager from serialized data
  78258. * @param serializationObject defines the serialized data
  78259. * @param scene defines the hosting scene
  78260. * @returns the new MorphTargetManager
  78261. */
  78262. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78263. }
  78264. }
  78265. declare module BABYLON {
  78266. /**
  78267. * Mesh representing the gorund
  78268. */
  78269. export class GroundMesh extends Mesh {
  78270. /** If octree should be generated */
  78271. generateOctree: boolean;
  78272. private _heightQuads;
  78273. /** @hidden */
  78274. _subdivisionsX: number;
  78275. /** @hidden */
  78276. _subdivisionsY: number;
  78277. /** @hidden */
  78278. _width: number;
  78279. /** @hidden */
  78280. _height: number;
  78281. /** @hidden */
  78282. _minX: number;
  78283. /** @hidden */
  78284. _maxX: number;
  78285. /** @hidden */
  78286. _minZ: number;
  78287. /** @hidden */
  78288. _maxZ: number;
  78289. constructor(name: string, scene: Scene);
  78290. /**
  78291. * "GroundMesh"
  78292. * @returns "GroundMesh"
  78293. */
  78294. getClassName(): string;
  78295. /**
  78296. * The minimum of x and y subdivisions
  78297. */
  78298. readonly subdivisions: number;
  78299. /**
  78300. * X subdivisions
  78301. */
  78302. readonly subdivisionsX: number;
  78303. /**
  78304. * Y subdivisions
  78305. */
  78306. readonly subdivisionsY: number;
  78307. /**
  78308. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78309. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78310. * @param chunksCount the number of subdivisions for x and y
  78311. * @param octreeBlocksSize (Default: 32)
  78312. */
  78313. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78314. /**
  78315. * Returns a height (y) value in the Worl system :
  78316. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78317. * @param x x coordinate
  78318. * @param z z coordinate
  78319. * @returns the ground y position if (x, z) are outside the ground surface.
  78320. */
  78321. getHeightAtCoordinates(x: number, z: number): number;
  78322. /**
  78323. * Returns a normalized vector (Vector3) orthogonal to the ground
  78324. * at the ground coordinates (x, z) expressed in the World system.
  78325. * @param x x coordinate
  78326. * @param z z coordinate
  78327. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78328. */
  78329. getNormalAtCoordinates(x: number, z: number): Vector3;
  78330. /**
  78331. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78332. * at the ground coordinates (x, z) expressed in the World system.
  78333. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78334. * @param x x coordinate
  78335. * @param z z coordinate
  78336. * @param ref vector to store the result
  78337. * @returns the GroundMesh.
  78338. */
  78339. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78340. /**
  78341. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78342. * if the ground has been updated.
  78343. * This can be used in the render loop.
  78344. * @returns the GroundMesh.
  78345. */
  78346. updateCoordinateHeights(): GroundMesh;
  78347. private _getFacetAt;
  78348. private _initHeightQuads;
  78349. private _computeHeightQuads;
  78350. /**
  78351. * Serializes this ground mesh
  78352. * @param serializationObject object to write serialization to
  78353. */
  78354. serialize(serializationObject: any): void;
  78355. /**
  78356. * Parses a serialized ground mesh
  78357. * @param parsedMesh the serialized mesh
  78358. * @param scene the scene to create the ground mesh in
  78359. * @returns the created ground mesh
  78360. */
  78361. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78362. }
  78363. }
  78364. declare module BABYLON {
  78365. /**
  78366. * Interface for Physics-Joint data
  78367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78368. */
  78369. export interface PhysicsJointData {
  78370. /**
  78371. * The main pivot of the joint
  78372. */
  78373. mainPivot?: Vector3;
  78374. /**
  78375. * The connected pivot of the joint
  78376. */
  78377. connectedPivot?: Vector3;
  78378. /**
  78379. * The main axis of the joint
  78380. */
  78381. mainAxis?: Vector3;
  78382. /**
  78383. * The connected axis of the joint
  78384. */
  78385. connectedAxis?: Vector3;
  78386. /**
  78387. * The collision of the joint
  78388. */
  78389. collision?: boolean;
  78390. /**
  78391. * Native Oimo/Cannon/Energy data
  78392. */
  78393. nativeParams?: any;
  78394. }
  78395. /**
  78396. * This is a holder class for the physics joint created by the physics plugin
  78397. * It holds a set of functions to control the underlying joint
  78398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78399. */
  78400. export class PhysicsJoint {
  78401. /**
  78402. * The type of the physics joint
  78403. */
  78404. type: number;
  78405. /**
  78406. * The data for the physics joint
  78407. */
  78408. jointData: PhysicsJointData;
  78409. private _physicsJoint;
  78410. protected _physicsPlugin: IPhysicsEnginePlugin;
  78411. /**
  78412. * Initializes the physics joint
  78413. * @param type The type of the physics joint
  78414. * @param jointData The data for the physics joint
  78415. */
  78416. constructor(
  78417. /**
  78418. * The type of the physics joint
  78419. */
  78420. type: number,
  78421. /**
  78422. * The data for the physics joint
  78423. */
  78424. jointData: PhysicsJointData);
  78425. /**
  78426. * Gets the physics joint
  78427. */
  78428. /**
  78429. * Sets the physics joint
  78430. */
  78431. physicsJoint: any;
  78432. /**
  78433. * Sets the physics plugin
  78434. */
  78435. physicsPlugin: IPhysicsEnginePlugin;
  78436. /**
  78437. * Execute a function that is physics-plugin specific.
  78438. * @param {Function} func the function that will be executed.
  78439. * It accepts two parameters: the physics world and the physics joint
  78440. */
  78441. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78442. /**
  78443. * Distance-Joint type
  78444. */
  78445. static DistanceJoint: number;
  78446. /**
  78447. * Hinge-Joint type
  78448. */
  78449. static HingeJoint: number;
  78450. /**
  78451. * Ball-and-Socket joint type
  78452. */
  78453. static BallAndSocketJoint: number;
  78454. /**
  78455. * Wheel-Joint type
  78456. */
  78457. static WheelJoint: number;
  78458. /**
  78459. * Slider-Joint type
  78460. */
  78461. static SliderJoint: number;
  78462. /**
  78463. * Prismatic-Joint type
  78464. */
  78465. static PrismaticJoint: number;
  78466. /**
  78467. * Universal-Joint type
  78468. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78469. */
  78470. static UniversalJoint: number;
  78471. /**
  78472. * Hinge-Joint 2 type
  78473. */
  78474. static Hinge2Joint: number;
  78475. /**
  78476. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78477. */
  78478. static PointToPointJoint: number;
  78479. /**
  78480. * Spring-Joint type
  78481. */
  78482. static SpringJoint: number;
  78483. /**
  78484. * Lock-Joint type
  78485. */
  78486. static LockJoint: number;
  78487. }
  78488. /**
  78489. * A class representing a physics distance joint
  78490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78491. */
  78492. export class DistanceJoint extends PhysicsJoint {
  78493. /**
  78494. *
  78495. * @param jointData The data for the Distance-Joint
  78496. */
  78497. constructor(jointData: DistanceJointData);
  78498. /**
  78499. * Update the predefined distance.
  78500. * @param maxDistance The maximum preferred distance
  78501. * @param minDistance The minimum preferred distance
  78502. */
  78503. updateDistance(maxDistance: number, minDistance?: number): void;
  78504. }
  78505. /**
  78506. * Represents a Motor-Enabled Joint
  78507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78508. */
  78509. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78510. /**
  78511. * Initializes the Motor-Enabled Joint
  78512. * @param type The type of the joint
  78513. * @param jointData The physica joint data for the joint
  78514. */
  78515. constructor(type: number, jointData: PhysicsJointData);
  78516. /**
  78517. * Set the motor values.
  78518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78519. * @param force the force to apply
  78520. * @param maxForce max force for this motor.
  78521. */
  78522. setMotor(force?: number, maxForce?: number): void;
  78523. /**
  78524. * Set the motor's limits.
  78525. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78526. * @param upperLimit The upper limit of the motor
  78527. * @param lowerLimit The lower limit of the motor
  78528. */
  78529. setLimit(upperLimit: number, lowerLimit?: number): void;
  78530. }
  78531. /**
  78532. * This class represents a single physics Hinge-Joint
  78533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78534. */
  78535. export class HingeJoint extends MotorEnabledJoint {
  78536. /**
  78537. * Initializes the Hinge-Joint
  78538. * @param jointData The joint data for the Hinge-Joint
  78539. */
  78540. constructor(jointData: PhysicsJointData);
  78541. /**
  78542. * Set the motor values.
  78543. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78544. * @param {number} force the force to apply
  78545. * @param {number} maxForce max force for this motor.
  78546. */
  78547. setMotor(force?: number, maxForce?: number): void;
  78548. /**
  78549. * Set the motor's limits.
  78550. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78551. * @param upperLimit The upper limit of the motor
  78552. * @param lowerLimit The lower limit of the motor
  78553. */
  78554. setLimit(upperLimit: number, lowerLimit?: number): void;
  78555. }
  78556. /**
  78557. * This class represents a dual hinge physics joint (same as wheel joint)
  78558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78559. */
  78560. export class Hinge2Joint extends MotorEnabledJoint {
  78561. /**
  78562. * Initializes the Hinge2-Joint
  78563. * @param jointData The joint data for the Hinge2-Joint
  78564. */
  78565. constructor(jointData: PhysicsJointData);
  78566. /**
  78567. * Set the motor values.
  78568. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78569. * @param {number} targetSpeed the speed the motor is to reach
  78570. * @param {number} maxForce max force for this motor.
  78571. * @param {motorIndex} the motor's index, 0 or 1.
  78572. */
  78573. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78574. /**
  78575. * Set the motor limits.
  78576. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78577. * @param {number} upperLimit the upper limit
  78578. * @param {number} lowerLimit lower limit
  78579. * @param {motorIndex} the motor's index, 0 or 1.
  78580. */
  78581. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78582. }
  78583. /**
  78584. * Interface for a motor enabled joint
  78585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78586. */
  78587. export interface IMotorEnabledJoint {
  78588. /**
  78589. * Physics joint
  78590. */
  78591. physicsJoint: any;
  78592. /**
  78593. * Sets the motor of the motor-enabled joint
  78594. * @param force The force of the motor
  78595. * @param maxForce The maximum force of the motor
  78596. * @param motorIndex The index of the motor
  78597. */
  78598. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78599. /**
  78600. * Sets the limit of the motor
  78601. * @param upperLimit The upper limit of the motor
  78602. * @param lowerLimit The lower limit of the motor
  78603. * @param motorIndex The index of the motor
  78604. */
  78605. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78606. }
  78607. /**
  78608. * Joint data for a Distance-Joint
  78609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78610. */
  78611. export interface DistanceJointData extends PhysicsJointData {
  78612. /**
  78613. * Max distance the 2 joint objects can be apart
  78614. */
  78615. maxDistance: number;
  78616. }
  78617. /**
  78618. * Joint data from a spring joint
  78619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78620. */
  78621. export interface SpringJointData extends PhysicsJointData {
  78622. /**
  78623. * Length of the spring
  78624. */
  78625. length: number;
  78626. /**
  78627. * Stiffness of the spring
  78628. */
  78629. stiffness: number;
  78630. /**
  78631. * Damping of the spring
  78632. */
  78633. damping: number;
  78634. /** this callback will be called when applying the force to the impostors. */
  78635. forceApplicationCallback: () => void;
  78636. }
  78637. }
  78638. declare module BABYLON {
  78639. /**
  78640. * Holds the data for the raycast result
  78641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78642. */
  78643. export class PhysicsRaycastResult {
  78644. private _hasHit;
  78645. private _hitDistance;
  78646. private _hitNormalWorld;
  78647. private _hitPointWorld;
  78648. private _rayFromWorld;
  78649. private _rayToWorld;
  78650. /**
  78651. * Gets if there was a hit
  78652. */
  78653. readonly hasHit: boolean;
  78654. /**
  78655. * Gets the distance from the hit
  78656. */
  78657. readonly hitDistance: number;
  78658. /**
  78659. * Gets the hit normal/direction in the world
  78660. */
  78661. readonly hitNormalWorld: Vector3;
  78662. /**
  78663. * Gets the hit point in the world
  78664. */
  78665. readonly hitPointWorld: Vector3;
  78666. /**
  78667. * Gets the ray "start point" of the ray in the world
  78668. */
  78669. readonly rayFromWorld: Vector3;
  78670. /**
  78671. * Gets the ray "end point" of the ray in the world
  78672. */
  78673. readonly rayToWorld: Vector3;
  78674. /**
  78675. * Sets the hit data (normal & point in world space)
  78676. * @param hitNormalWorld defines the normal in world space
  78677. * @param hitPointWorld defines the point in world space
  78678. */
  78679. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78680. /**
  78681. * Sets the distance from the start point to the hit point
  78682. * @param distance
  78683. */
  78684. setHitDistance(distance: number): void;
  78685. /**
  78686. * Calculates the distance manually
  78687. */
  78688. calculateHitDistance(): void;
  78689. /**
  78690. * Resets all the values to default
  78691. * @param from The from point on world space
  78692. * @param to The to point on world space
  78693. */
  78694. reset(from?: Vector3, to?: Vector3): void;
  78695. }
  78696. /**
  78697. * Interface for the size containing width and height
  78698. */
  78699. interface IXYZ {
  78700. /**
  78701. * X
  78702. */
  78703. x: number;
  78704. /**
  78705. * Y
  78706. */
  78707. y: number;
  78708. /**
  78709. * Z
  78710. */
  78711. z: number;
  78712. }
  78713. }
  78714. declare module BABYLON {
  78715. /**
  78716. * Interface used to describe a physics joint
  78717. */
  78718. export interface PhysicsImpostorJoint {
  78719. /** Defines the main impostor to which the joint is linked */
  78720. mainImpostor: PhysicsImpostor;
  78721. /** Defines the impostor that is connected to the main impostor using this joint */
  78722. connectedImpostor: PhysicsImpostor;
  78723. /** Defines the joint itself */
  78724. joint: PhysicsJoint;
  78725. }
  78726. /** @hidden */
  78727. export interface IPhysicsEnginePlugin {
  78728. world: any;
  78729. name: string;
  78730. setGravity(gravity: Vector3): void;
  78731. setTimeStep(timeStep: number): void;
  78732. getTimeStep(): number;
  78733. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78734. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78735. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78737. removePhysicsBody(impostor: PhysicsImpostor): void;
  78738. generateJoint(joint: PhysicsImpostorJoint): void;
  78739. removeJoint(joint: PhysicsImpostorJoint): void;
  78740. isSupported(): boolean;
  78741. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78742. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78743. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78744. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78745. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78746. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78747. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78748. getBodyMass(impostor: PhysicsImpostor): number;
  78749. getBodyFriction(impostor: PhysicsImpostor): number;
  78750. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78751. getBodyRestitution(impostor: PhysicsImpostor): number;
  78752. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  78753. getBodyPressure?(impostor: PhysicsImpostor): number;
  78754. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  78755. getBodyStiffness?(impostor: PhysicsImpostor): number;
  78756. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78757. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78758. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78759. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78760. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78761. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78762. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78763. sleepBody(impostor: PhysicsImpostor): void;
  78764. wakeUpBody(impostor: PhysicsImpostor): void;
  78765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78766. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78767. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78768. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78769. getRadius(impostor: PhysicsImpostor): number;
  78770. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78771. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78772. dispose(): void;
  78773. }
  78774. /**
  78775. * Interface used to define a physics engine
  78776. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78777. */
  78778. export interface IPhysicsEngine {
  78779. /**
  78780. * Gets the gravity vector used by the simulation
  78781. */
  78782. gravity: Vector3;
  78783. /**
  78784. * Sets the gravity vector used by the simulation
  78785. * @param gravity defines the gravity vector to use
  78786. */
  78787. setGravity(gravity: Vector3): void;
  78788. /**
  78789. * Set the time step of the physics engine.
  78790. * Default is 1/60.
  78791. * To slow it down, enter 1/600 for example.
  78792. * To speed it up, 1/30
  78793. * @param newTimeStep the new timestep to apply to this world.
  78794. */
  78795. setTimeStep(newTimeStep: number): void;
  78796. /**
  78797. * Get the time step of the physics engine.
  78798. * @returns the current time step
  78799. */
  78800. getTimeStep(): number;
  78801. /**
  78802. * Release all resources
  78803. */
  78804. dispose(): void;
  78805. /**
  78806. * Gets the name of the current physics plugin
  78807. * @returns the name of the plugin
  78808. */
  78809. getPhysicsPluginName(): string;
  78810. /**
  78811. * Adding a new impostor for the impostor tracking.
  78812. * This will be done by the impostor itself.
  78813. * @param impostor the impostor to add
  78814. */
  78815. addImpostor(impostor: PhysicsImpostor): void;
  78816. /**
  78817. * Remove an impostor from the engine.
  78818. * This impostor and its mesh will not longer be updated by the physics engine.
  78819. * @param impostor the impostor to remove
  78820. */
  78821. removeImpostor(impostor: PhysicsImpostor): void;
  78822. /**
  78823. * Add a joint to the physics engine
  78824. * @param mainImpostor defines the main impostor to which the joint is added.
  78825. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78826. * @param joint defines the joint that will connect both impostors.
  78827. */
  78828. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78829. /**
  78830. * Removes a joint from the simulation
  78831. * @param mainImpostor defines the impostor used with the joint
  78832. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78833. * @param joint defines the joint to remove
  78834. */
  78835. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78836. /**
  78837. * Gets the current plugin used to run the simulation
  78838. * @returns current plugin
  78839. */
  78840. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78841. /**
  78842. * Gets the list of physic impostors
  78843. * @returns an array of PhysicsImpostor
  78844. */
  78845. getImpostors(): Array<PhysicsImpostor>;
  78846. /**
  78847. * Gets the impostor for a physics enabled object
  78848. * @param object defines the object impersonated by the impostor
  78849. * @returns the PhysicsImpostor or null if not found
  78850. */
  78851. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78852. /**
  78853. * Gets the impostor for a physics body object
  78854. * @param body defines physics body used by the impostor
  78855. * @returns the PhysicsImpostor or null if not found
  78856. */
  78857. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78858. /**
  78859. * Does a raycast in the physics world
  78860. * @param from when should the ray start?
  78861. * @param to when should the ray end?
  78862. * @returns PhysicsRaycastResult
  78863. */
  78864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78865. /**
  78866. * Called by the scene. No need to call it.
  78867. * @param delta defines the timespam between frames
  78868. */
  78869. _step(delta: number): void;
  78870. }
  78871. }
  78872. declare module BABYLON {
  78873. /**
  78874. * The interface for the physics imposter parameters
  78875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78876. */
  78877. export interface PhysicsImpostorParameters {
  78878. /**
  78879. * The mass of the physics imposter
  78880. */
  78881. mass: number;
  78882. /**
  78883. * The friction of the physics imposter
  78884. */
  78885. friction?: number;
  78886. /**
  78887. * The coefficient of restitution of the physics imposter
  78888. */
  78889. restitution?: number;
  78890. /**
  78891. * The native options of the physics imposter
  78892. */
  78893. nativeOptions?: any;
  78894. /**
  78895. * Specifies if the parent should be ignored
  78896. */
  78897. ignoreParent?: boolean;
  78898. /**
  78899. * Specifies if bi-directional transformations should be disabled
  78900. */
  78901. disableBidirectionalTransformation?: boolean;
  78902. /**
  78903. * The pressure inside the physics imposter, soft object only
  78904. */
  78905. pressure?: number;
  78906. /**
  78907. * The stiffness the physics imposter, soft object only
  78908. */
  78909. stiffness?: number;
  78910. /**
  78911. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78912. */
  78913. velocityIterations?: number;
  78914. /**
  78915. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78916. */
  78917. positionIterations?: number;
  78918. /**
  78919. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78920. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78921. * Add to fix multiple points
  78922. */
  78923. fixedPoints?: number;
  78924. /**
  78925. * The collision margin around a soft object
  78926. */
  78927. margin?: number;
  78928. /**
  78929. * The collision margin around a soft object
  78930. */
  78931. damping?: number;
  78932. /**
  78933. * The path for a rope based on an extrusion
  78934. */
  78935. path?: any;
  78936. /**
  78937. * The shape of an extrusion used for a rope based on an extrusion
  78938. */
  78939. shape?: any;
  78940. }
  78941. /**
  78942. * Interface for a physics-enabled object
  78943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78944. */
  78945. export interface IPhysicsEnabledObject {
  78946. /**
  78947. * The position of the physics-enabled object
  78948. */
  78949. position: Vector3;
  78950. /**
  78951. * The rotation of the physics-enabled object
  78952. */
  78953. rotationQuaternion: Nullable<Quaternion>;
  78954. /**
  78955. * The scale of the physics-enabled object
  78956. */
  78957. scaling: Vector3;
  78958. /**
  78959. * The rotation of the physics-enabled object
  78960. */
  78961. rotation?: Vector3;
  78962. /**
  78963. * The parent of the physics-enabled object
  78964. */
  78965. parent?: any;
  78966. /**
  78967. * The bounding info of the physics-enabled object
  78968. * @returns The bounding info of the physics-enabled object
  78969. */
  78970. getBoundingInfo(): BoundingInfo;
  78971. /**
  78972. * Computes the world matrix
  78973. * @param force Specifies if the world matrix should be computed by force
  78974. * @returns A world matrix
  78975. */
  78976. computeWorldMatrix(force: boolean): Matrix;
  78977. /**
  78978. * Gets the world matrix
  78979. * @returns A world matrix
  78980. */
  78981. getWorldMatrix?(): Matrix;
  78982. /**
  78983. * Gets the child meshes
  78984. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78985. * @returns An array of abstract meshes
  78986. */
  78987. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78988. /**
  78989. * Gets the vertex data
  78990. * @param kind The type of vertex data
  78991. * @returns A nullable array of numbers, or a float32 array
  78992. */
  78993. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78994. /**
  78995. * Gets the indices from the mesh
  78996. * @returns A nullable array of index arrays
  78997. */
  78998. getIndices?(): Nullable<IndicesArray>;
  78999. /**
  79000. * Gets the scene from the mesh
  79001. * @returns the indices array or null
  79002. */
  79003. getScene?(): Scene;
  79004. /**
  79005. * Gets the absolute position from the mesh
  79006. * @returns the absolute position
  79007. */
  79008. getAbsolutePosition(): Vector3;
  79009. /**
  79010. * Gets the absolute pivot point from the mesh
  79011. * @returns the absolute pivot point
  79012. */
  79013. getAbsolutePivotPoint(): Vector3;
  79014. /**
  79015. * Rotates the mesh
  79016. * @param axis The axis of rotation
  79017. * @param amount The amount of rotation
  79018. * @param space The space of the rotation
  79019. * @returns The rotation transform node
  79020. */
  79021. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79022. /**
  79023. * Translates the mesh
  79024. * @param axis The axis of translation
  79025. * @param distance The distance of translation
  79026. * @param space The space of the translation
  79027. * @returns The transform node
  79028. */
  79029. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79030. /**
  79031. * Sets the absolute position of the mesh
  79032. * @param absolutePosition The absolute position of the mesh
  79033. * @returns The transform node
  79034. */
  79035. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79036. /**
  79037. * Gets the class name of the mesh
  79038. * @returns The class name
  79039. */
  79040. getClassName(): string;
  79041. }
  79042. /**
  79043. * Represents a physics imposter
  79044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79045. */
  79046. export class PhysicsImpostor {
  79047. /**
  79048. * The physics-enabled object used as the physics imposter
  79049. */
  79050. object: IPhysicsEnabledObject;
  79051. /**
  79052. * The type of the physics imposter
  79053. */
  79054. type: number;
  79055. private _options;
  79056. private _scene?;
  79057. /**
  79058. * The default object size of the imposter
  79059. */
  79060. static DEFAULT_OBJECT_SIZE: Vector3;
  79061. /**
  79062. * The identity quaternion of the imposter
  79063. */
  79064. static IDENTITY_QUATERNION: Quaternion;
  79065. /** @hidden */
  79066. _pluginData: any;
  79067. private _physicsEngine;
  79068. private _physicsBody;
  79069. private _bodyUpdateRequired;
  79070. private _onBeforePhysicsStepCallbacks;
  79071. private _onAfterPhysicsStepCallbacks;
  79072. /** @hidden */
  79073. _onPhysicsCollideCallbacks: Array<{
  79074. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79075. otherImpostors: Array<PhysicsImpostor>;
  79076. }>;
  79077. private _deltaPosition;
  79078. private _deltaRotation;
  79079. private _deltaRotationConjugated;
  79080. /** hidden */
  79081. _isFromLine: boolean;
  79082. private _parent;
  79083. private _isDisposed;
  79084. private static _tmpVecs;
  79085. private static _tmpQuat;
  79086. /**
  79087. * Specifies if the physics imposter is disposed
  79088. */
  79089. readonly isDisposed: boolean;
  79090. /**
  79091. * Gets the mass of the physics imposter
  79092. */
  79093. mass: number;
  79094. /**
  79095. * Gets the coefficient of friction
  79096. */
  79097. /**
  79098. * Sets the coefficient of friction
  79099. */
  79100. friction: number;
  79101. /**
  79102. * Gets the coefficient of restitution
  79103. */
  79104. /**
  79105. * Sets the coefficient of restitution
  79106. */
  79107. restitution: number;
  79108. /**
  79109. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79110. */
  79111. /**
  79112. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79113. */
  79114. pressure: number;
  79115. /**
  79116. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79117. */
  79118. /**
  79119. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79120. */
  79121. stiffness: number;
  79122. /**
  79123. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79124. */
  79125. /**
  79126. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79127. */
  79128. velocityIterations: number;
  79129. /**
  79130. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79131. */
  79132. /**
  79133. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79134. */
  79135. positionIterations: number;
  79136. /**
  79137. * The unique id of the physics imposter
  79138. * set by the physics engine when adding this impostor to the array
  79139. */
  79140. uniqueId: number;
  79141. /**
  79142. * @hidden
  79143. */
  79144. soft: boolean;
  79145. /**
  79146. * @hidden
  79147. */
  79148. segments: number;
  79149. private _joints;
  79150. /**
  79151. * Initializes the physics imposter
  79152. * @param object The physics-enabled object used as the physics imposter
  79153. * @param type The type of the physics imposter
  79154. * @param _options The options for the physics imposter
  79155. * @param _scene The Babylon scene
  79156. */
  79157. constructor(
  79158. /**
  79159. * The physics-enabled object used as the physics imposter
  79160. */
  79161. object: IPhysicsEnabledObject,
  79162. /**
  79163. * The type of the physics imposter
  79164. */
  79165. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79166. /**
  79167. * This function will completly initialize this impostor.
  79168. * It will create a new body - but only if this mesh has no parent.
  79169. * If it has, this impostor will not be used other than to define the impostor
  79170. * of the child mesh.
  79171. * @hidden
  79172. */
  79173. _init(): void;
  79174. private _getPhysicsParent;
  79175. /**
  79176. * Should a new body be generated.
  79177. * @returns boolean specifying if body initialization is required
  79178. */
  79179. isBodyInitRequired(): boolean;
  79180. /**
  79181. * Sets the updated scaling
  79182. * @param updated Specifies if the scaling is updated
  79183. */
  79184. setScalingUpdated(): void;
  79185. /**
  79186. * Force a regeneration of this or the parent's impostor's body.
  79187. * Use under cautious - This will remove all joints already implemented.
  79188. */
  79189. forceUpdate(): void;
  79190. /**
  79191. * Gets the body that holds this impostor. Either its own, or its parent.
  79192. */
  79193. /**
  79194. * Set the physics body. Used mainly by the physics engine/plugin
  79195. */
  79196. physicsBody: any;
  79197. /**
  79198. * Get the parent of the physics imposter
  79199. * @returns Physics imposter or null
  79200. */
  79201. /**
  79202. * Sets the parent of the physics imposter
  79203. */
  79204. parent: Nullable<PhysicsImpostor>;
  79205. /**
  79206. * Resets the update flags
  79207. */
  79208. resetUpdateFlags(): void;
  79209. /**
  79210. * Gets the object extend size
  79211. * @returns the object extend size
  79212. */
  79213. getObjectExtendSize(): Vector3;
  79214. /**
  79215. * Gets the object center
  79216. * @returns The object center
  79217. */
  79218. getObjectCenter(): Vector3;
  79219. /**
  79220. * Get a specific parametes from the options parameter
  79221. * @param paramName The object parameter name
  79222. * @returns The object parameter
  79223. */
  79224. getParam(paramName: string): any;
  79225. /**
  79226. * Sets a specific parameter in the options given to the physics plugin
  79227. * @param paramName The parameter name
  79228. * @param value The value of the parameter
  79229. */
  79230. setParam(paramName: string, value: number): void;
  79231. /**
  79232. * Specifically change the body's mass option. Won't recreate the physics body object
  79233. * @param mass The mass of the physics imposter
  79234. */
  79235. setMass(mass: number): void;
  79236. /**
  79237. * Gets the linear velocity
  79238. * @returns linear velocity or null
  79239. */
  79240. getLinearVelocity(): Nullable<Vector3>;
  79241. /**
  79242. * Sets the linear velocity
  79243. * @param velocity linear velocity or null
  79244. */
  79245. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79246. /**
  79247. * Gets the angular velocity
  79248. * @returns angular velocity or null
  79249. */
  79250. getAngularVelocity(): Nullable<Vector3>;
  79251. /**
  79252. * Sets the angular velocity
  79253. * @param velocity The velocity or null
  79254. */
  79255. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79256. /**
  79257. * Execute a function with the physics plugin native code
  79258. * Provide a function the will have two variables - the world object and the physics body object
  79259. * @param func The function to execute with the physics plugin native code
  79260. */
  79261. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79262. /**
  79263. * Register a function that will be executed before the physics world is stepping forward
  79264. * @param func The function to execute before the physics world is stepped forward
  79265. */
  79266. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79267. /**
  79268. * Unregister a function that will be executed before the physics world is stepping forward
  79269. * @param func The function to execute before the physics world is stepped forward
  79270. */
  79271. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79272. /**
  79273. * Register a function that will be executed after the physics step
  79274. * @param func The function to execute after physics step
  79275. */
  79276. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79277. /**
  79278. * Unregisters a function that will be executed after the physics step
  79279. * @param func The function to execute after physics step
  79280. */
  79281. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79282. /**
  79283. * register a function that will be executed when this impostor collides against a different body
  79284. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79285. * @param func Callback that is executed on collision
  79286. */
  79287. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79288. /**
  79289. * Unregisters the physics imposter on contact
  79290. * @param collideAgainst The physics object to collide against
  79291. * @param func Callback to execute on collision
  79292. */
  79293. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79294. private _tmpQuat;
  79295. private _tmpQuat2;
  79296. /**
  79297. * Get the parent rotation
  79298. * @returns The parent rotation
  79299. */
  79300. getParentsRotation(): Quaternion;
  79301. /**
  79302. * this function is executed by the physics engine.
  79303. */
  79304. beforeStep: () => void;
  79305. /**
  79306. * this function is executed by the physics engine
  79307. */
  79308. afterStep: () => void;
  79309. /**
  79310. * Legacy collision detection event support
  79311. */
  79312. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79313. /**
  79314. * event and body object due to cannon's event-based architecture.
  79315. */
  79316. onCollide: (e: {
  79317. body: any;
  79318. }) => void;
  79319. /**
  79320. * Apply a force
  79321. * @param force The force to apply
  79322. * @param contactPoint The contact point for the force
  79323. * @returns The physics imposter
  79324. */
  79325. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79326. /**
  79327. * Apply an impulse
  79328. * @param force The impulse force
  79329. * @param contactPoint The contact point for the impulse force
  79330. * @returns The physics imposter
  79331. */
  79332. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79333. /**
  79334. * A help function to create a joint
  79335. * @param otherImpostor A physics imposter used to create a joint
  79336. * @param jointType The type of joint
  79337. * @param jointData The data for the joint
  79338. * @returns The physics imposter
  79339. */
  79340. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79341. /**
  79342. * Add a joint to this impostor with a different impostor
  79343. * @param otherImpostor A physics imposter used to add a joint
  79344. * @param joint The joint to add
  79345. * @returns The physics imposter
  79346. */
  79347. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79348. /**
  79349. * Add an anchor to a cloth impostor
  79350. * @param otherImpostor rigid impostor to anchor to
  79351. * @param width ratio across width from 0 to 1
  79352. * @param height ratio up height from 0 to 1
  79353. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79354. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79355. * @returns impostor the soft imposter
  79356. */
  79357. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79358. /**
  79359. * Add a hook to a rope impostor
  79360. * @param otherImpostor rigid impostor to anchor to
  79361. * @param length ratio across rope from 0 to 1
  79362. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79363. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79364. * @returns impostor the rope imposter
  79365. */
  79366. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79367. /**
  79368. * Will keep this body still, in a sleep mode.
  79369. * @returns the physics imposter
  79370. */
  79371. sleep(): PhysicsImpostor;
  79372. /**
  79373. * Wake the body up.
  79374. * @returns The physics imposter
  79375. */
  79376. wakeUp(): PhysicsImpostor;
  79377. /**
  79378. * Clones the physics imposter
  79379. * @param newObject The physics imposter clones to this physics-enabled object
  79380. * @returns A nullable physics imposter
  79381. */
  79382. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79383. /**
  79384. * Disposes the physics imposter
  79385. */
  79386. dispose(): void;
  79387. /**
  79388. * Sets the delta position
  79389. * @param position The delta position amount
  79390. */
  79391. setDeltaPosition(position: Vector3): void;
  79392. /**
  79393. * Sets the delta rotation
  79394. * @param rotation The delta rotation amount
  79395. */
  79396. setDeltaRotation(rotation: Quaternion): void;
  79397. /**
  79398. * Gets the box size of the physics imposter and stores the result in the input parameter
  79399. * @param result Stores the box size
  79400. * @returns The physics imposter
  79401. */
  79402. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79403. /**
  79404. * Gets the radius of the physics imposter
  79405. * @returns Radius of the physics imposter
  79406. */
  79407. getRadius(): number;
  79408. /**
  79409. * Sync a bone with this impostor
  79410. * @param bone The bone to sync to the impostor.
  79411. * @param boneMesh The mesh that the bone is influencing.
  79412. * @param jointPivot The pivot of the joint / bone in local space.
  79413. * @param distToJoint Optional distance from the impostor to the joint.
  79414. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79415. */
  79416. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79417. /**
  79418. * Sync impostor to a bone
  79419. * @param bone The bone that the impostor will be synced to.
  79420. * @param boneMesh The mesh that the bone is influencing.
  79421. * @param jointPivot The pivot of the joint / bone in local space.
  79422. * @param distToJoint Optional distance from the impostor to the joint.
  79423. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79424. * @param boneAxis Optional vector3 axis the bone is aligned with
  79425. */
  79426. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79427. /**
  79428. * No-Imposter type
  79429. */
  79430. static NoImpostor: number;
  79431. /**
  79432. * Sphere-Imposter type
  79433. */
  79434. static SphereImpostor: number;
  79435. /**
  79436. * Box-Imposter type
  79437. */
  79438. static BoxImpostor: number;
  79439. /**
  79440. * Plane-Imposter type
  79441. */
  79442. static PlaneImpostor: number;
  79443. /**
  79444. * Mesh-imposter type
  79445. */
  79446. static MeshImpostor: number;
  79447. /**
  79448. * Cylinder-Imposter type
  79449. */
  79450. static CylinderImpostor: number;
  79451. /**
  79452. * Particle-Imposter type
  79453. */
  79454. static ParticleImpostor: number;
  79455. /**
  79456. * Heightmap-Imposter type
  79457. */
  79458. static HeightmapImpostor: number;
  79459. /**
  79460. * ConvexHull-Impostor type (Ammo.js plugin only)
  79461. */
  79462. static ConvexHullImpostor: number;
  79463. /**
  79464. * Rope-Imposter type
  79465. */
  79466. static RopeImpostor: number;
  79467. /**
  79468. * Cloth-Imposter type
  79469. */
  79470. static ClothImpostor: number;
  79471. /**
  79472. * Softbody-Imposter type
  79473. */
  79474. static SoftbodyImpostor: number;
  79475. }
  79476. }
  79477. declare module BABYLON {
  79478. /**
  79479. * Class used to represent a specific level of detail of a mesh
  79480. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79481. */
  79482. export class MeshLODLevel {
  79483. /** Defines the distance where this level should star being displayed */
  79484. distance: number;
  79485. /** Defines the mesh to use to render this level */
  79486. mesh: Nullable<Mesh>;
  79487. /**
  79488. * Creates a new LOD level
  79489. * @param distance defines the distance where this level should star being displayed
  79490. * @param mesh defines the mesh to use to render this level
  79491. */
  79492. constructor(
  79493. /** Defines the distance where this level should star being displayed */
  79494. distance: number,
  79495. /** Defines the mesh to use to render this level */
  79496. mesh: Nullable<Mesh>);
  79497. }
  79498. /**
  79499. * @hidden
  79500. **/
  79501. export class _CreationDataStorage {
  79502. closePath?: boolean;
  79503. closeArray?: boolean;
  79504. idx: number[];
  79505. dashSize: number;
  79506. gapSize: number;
  79507. path3D: Path3D;
  79508. pathArray: Vector3[][];
  79509. arc: number;
  79510. radius: number;
  79511. cap: number;
  79512. tessellation: number;
  79513. }
  79514. /**
  79515. * @hidden
  79516. **/
  79517. class _InstanceDataStorage {
  79518. visibleInstances: any;
  79519. renderIdForInstances: number[];
  79520. batchCache: _InstancesBatch;
  79521. instancesBufferSize: number;
  79522. instancesBuffer: Nullable<Buffer>;
  79523. instancesData: Float32Array;
  79524. overridenInstanceCount: number;
  79525. }
  79526. /**
  79527. * @hidden
  79528. **/
  79529. export class _InstancesBatch {
  79530. mustReturn: boolean;
  79531. visibleInstances: Nullable<InstancedMesh[]>[];
  79532. renderSelf: boolean[];
  79533. }
  79534. /**
  79535. * Class used to represent renderable models
  79536. */
  79537. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79538. /**
  79539. * Mesh side orientation : usually the external or front surface
  79540. */
  79541. static readonly FRONTSIDE: number;
  79542. /**
  79543. * Mesh side orientation : usually the internal or back surface
  79544. */
  79545. static readonly BACKSIDE: number;
  79546. /**
  79547. * Mesh side orientation : both internal and external or front and back surfaces
  79548. */
  79549. static readonly DOUBLESIDE: number;
  79550. /**
  79551. * Mesh side orientation : by default, `FRONTSIDE`
  79552. */
  79553. static readonly DEFAULTSIDE: number;
  79554. /**
  79555. * Mesh cap setting : no cap
  79556. */
  79557. static readonly NO_CAP: number;
  79558. /**
  79559. * Mesh cap setting : one cap at the beginning of the mesh
  79560. */
  79561. static readonly CAP_START: number;
  79562. /**
  79563. * Mesh cap setting : one cap at the end of the mesh
  79564. */
  79565. static readonly CAP_END: number;
  79566. /**
  79567. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79568. */
  79569. static readonly CAP_ALL: number;
  79570. /**
  79571. * Gets the default side orientation.
  79572. * @param orientation the orientation to value to attempt to get
  79573. * @returns the default orientation
  79574. * @hidden
  79575. */
  79576. static _GetDefaultSideOrientation(orientation?: number): number;
  79577. private _onBeforeRenderObservable;
  79578. private _onBeforeBindObservable;
  79579. private _onAfterRenderObservable;
  79580. private _onBeforeDrawObservable;
  79581. /**
  79582. * An event triggered before rendering the mesh
  79583. */
  79584. readonly onBeforeRenderObservable: Observable<Mesh>;
  79585. /**
  79586. * An event triggered before binding the mesh
  79587. */
  79588. readonly onBeforeBindObservable: Observable<Mesh>;
  79589. /**
  79590. * An event triggered after rendering the mesh
  79591. */
  79592. readonly onAfterRenderObservable: Observable<Mesh>;
  79593. /**
  79594. * An event triggered before drawing the mesh
  79595. */
  79596. readonly onBeforeDrawObservable: Observable<Mesh>;
  79597. private _onBeforeDrawObserver;
  79598. /**
  79599. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79600. */
  79601. onBeforeDraw: () => void;
  79602. /**
  79603. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79604. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79605. */
  79606. delayLoadState: number;
  79607. /**
  79608. * Gets the list of instances created from this mesh
  79609. * it is not supposed to be modified manually.
  79610. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79611. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79612. */
  79613. instances: InstancedMesh[];
  79614. /**
  79615. * Gets the file containing delay loading data for this mesh
  79616. */
  79617. delayLoadingFile: string;
  79618. /** @hidden */
  79619. _binaryInfo: any;
  79620. private _LODLevels;
  79621. /**
  79622. * User defined function used to change how LOD level selection is done
  79623. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79624. */
  79625. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79626. private _morphTargetManager;
  79627. /**
  79628. * Gets or sets the morph target manager
  79629. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79630. */
  79631. morphTargetManager: Nullable<MorphTargetManager>;
  79632. /** @hidden */
  79633. _creationDataStorage: Nullable<_CreationDataStorage>;
  79634. /** @hidden */
  79635. _geometry: Nullable<Geometry>;
  79636. /** @hidden */
  79637. _delayInfo: Array<string>;
  79638. /** @hidden */
  79639. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79640. /** @hidden */
  79641. _instanceDataStorage: _InstanceDataStorage;
  79642. private _effectiveMaterial;
  79643. /** @hidden */
  79644. _shouldGenerateFlatShading: boolean;
  79645. private _preActivateId;
  79646. /** @hidden */
  79647. _originalBuilderSideOrientation: number;
  79648. /**
  79649. * Use this property to change the original side orientation defined at construction time
  79650. */
  79651. overrideMaterialSideOrientation: Nullable<number>;
  79652. private _areNormalsFrozen;
  79653. private _sourcePositions;
  79654. private _sourceNormals;
  79655. private _source;
  79656. private meshMap;
  79657. /**
  79658. * Gets the source mesh (the one used to clone this one from)
  79659. */
  79660. readonly source: Nullable<Mesh>;
  79661. /**
  79662. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79663. */
  79664. isUnIndexed: boolean;
  79665. /**
  79666. * @constructor
  79667. * @param name The value used by scene.getMeshByName() to do a lookup.
  79668. * @param scene The scene to add this mesh to.
  79669. * @param parent The parent of this mesh, if it has one
  79670. * @param source An optional Mesh from which geometry is shared, cloned.
  79671. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79672. * When false, achieved by calling a clone(), also passing False.
  79673. * This will make creation of children, recursive.
  79674. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79675. */
  79676. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79677. /**
  79678. * Gets the class name
  79679. * @returns the string "Mesh".
  79680. */
  79681. getClassName(): string;
  79682. /** @hidden */
  79683. readonly _isMesh: boolean;
  79684. /**
  79685. * Returns a description of this mesh
  79686. * @param fullDetails define if full details about this mesh must be used
  79687. * @returns a descriptive string representing this mesh
  79688. */
  79689. toString(fullDetails?: boolean): string;
  79690. /** @hidden */
  79691. _unBindEffect(): void;
  79692. /**
  79693. * Gets a boolean indicating if this mesh has LOD
  79694. */
  79695. readonly hasLODLevels: boolean;
  79696. /**
  79697. * Gets the list of MeshLODLevel associated with the current mesh
  79698. * @returns an array of MeshLODLevel
  79699. */
  79700. getLODLevels(): MeshLODLevel[];
  79701. private _sortLODLevels;
  79702. /**
  79703. * Add a mesh as LOD level triggered at the given distance.
  79704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79705. * @param distance The distance from the center of the object to show this level
  79706. * @param mesh The mesh to be added as LOD level (can be null)
  79707. * @return This mesh (for chaining)
  79708. */
  79709. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79710. /**
  79711. * Returns the LOD level mesh at the passed distance or null if not found.
  79712. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79713. * @param distance The distance from the center of the object to show this level
  79714. * @returns a Mesh or `null`
  79715. */
  79716. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79717. /**
  79718. * Remove a mesh from the LOD array
  79719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79720. * @param mesh defines the mesh to be removed
  79721. * @return This mesh (for chaining)
  79722. */
  79723. removeLODLevel(mesh: Mesh): Mesh;
  79724. /**
  79725. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79727. * @param camera defines the camera to use to compute distance
  79728. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79729. * @return This mesh (for chaining)
  79730. */
  79731. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79732. /**
  79733. * Gets the mesh internal Geometry object
  79734. */
  79735. readonly geometry: Nullable<Geometry>;
  79736. /**
  79737. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79738. * @returns the total number of vertices
  79739. */
  79740. getTotalVertices(): number;
  79741. /**
  79742. * Returns the content of an associated vertex buffer
  79743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79744. * - VertexBuffer.PositionKind
  79745. * - VertexBuffer.UVKind
  79746. * - VertexBuffer.UV2Kind
  79747. * - VertexBuffer.UV3Kind
  79748. * - VertexBuffer.UV4Kind
  79749. * - VertexBuffer.UV5Kind
  79750. * - VertexBuffer.UV6Kind
  79751. * - VertexBuffer.ColorKind
  79752. * - VertexBuffer.MatricesIndicesKind
  79753. * - VertexBuffer.MatricesIndicesExtraKind
  79754. * - VertexBuffer.MatricesWeightsKind
  79755. * - VertexBuffer.MatricesWeightsExtraKind
  79756. * @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
  79757. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79758. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79759. */
  79760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79761. /**
  79762. * Returns the mesh VertexBuffer object from the requested `kind`
  79763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79764. * - VertexBuffer.PositionKind
  79765. * - VertexBuffer.UVKind
  79766. * - VertexBuffer.UV2Kind
  79767. * - VertexBuffer.UV3Kind
  79768. * - VertexBuffer.UV4Kind
  79769. * - VertexBuffer.UV5Kind
  79770. * - VertexBuffer.UV6Kind
  79771. * - VertexBuffer.ColorKind
  79772. * - VertexBuffer.MatricesIndicesKind
  79773. * - VertexBuffer.MatricesIndicesExtraKind
  79774. * - VertexBuffer.MatricesWeightsKind
  79775. * - VertexBuffer.MatricesWeightsExtraKind
  79776. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79777. */
  79778. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79779. /**
  79780. * Tests if a specific vertex buffer is associated with this mesh
  79781. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79782. * - VertexBuffer.PositionKind
  79783. * - VertexBuffer.UVKind
  79784. * - VertexBuffer.UV2Kind
  79785. * - VertexBuffer.UV3Kind
  79786. * - VertexBuffer.UV4Kind
  79787. * - VertexBuffer.UV5Kind
  79788. * - VertexBuffer.UV6Kind
  79789. * - VertexBuffer.ColorKind
  79790. * - VertexBuffer.MatricesIndicesKind
  79791. * - VertexBuffer.MatricesIndicesExtraKind
  79792. * - VertexBuffer.MatricesWeightsKind
  79793. * - VertexBuffer.MatricesWeightsExtraKind
  79794. * @returns a boolean
  79795. */
  79796. isVerticesDataPresent(kind: string): boolean;
  79797. /**
  79798. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79799. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79800. * - VertexBuffer.PositionKind
  79801. * - VertexBuffer.UVKind
  79802. * - VertexBuffer.UV2Kind
  79803. * - VertexBuffer.UV3Kind
  79804. * - VertexBuffer.UV4Kind
  79805. * - VertexBuffer.UV5Kind
  79806. * - VertexBuffer.UV6Kind
  79807. * - VertexBuffer.ColorKind
  79808. * - VertexBuffer.MatricesIndicesKind
  79809. * - VertexBuffer.MatricesIndicesExtraKind
  79810. * - VertexBuffer.MatricesWeightsKind
  79811. * - VertexBuffer.MatricesWeightsExtraKind
  79812. * @returns a boolean
  79813. */
  79814. isVertexBufferUpdatable(kind: string): boolean;
  79815. /**
  79816. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79817. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79818. * - VertexBuffer.PositionKind
  79819. * - VertexBuffer.UVKind
  79820. * - VertexBuffer.UV2Kind
  79821. * - VertexBuffer.UV3Kind
  79822. * - VertexBuffer.UV4Kind
  79823. * - VertexBuffer.UV5Kind
  79824. * - VertexBuffer.UV6Kind
  79825. * - VertexBuffer.ColorKind
  79826. * - VertexBuffer.MatricesIndicesKind
  79827. * - VertexBuffer.MatricesIndicesExtraKind
  79828. * - VertexBuffer.MatricesWeightsKind
  79829. * - VertexBuffer.MatricesWeightsExtraKind
  79830. * @returns an array of strings
  79831. */
  79832. getVerticesDataKinds(): string[];
  79833. /**
  79834. * Returns a positive integer : the total number of indices in this mesh geometry.
  79835. * @returns the numner of indices or zero if the mesh has no geometry.
  79836. */
  79837. getTotalIndices(): number;
  79838. /**
  79839. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79840. * @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.
  79841. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79842. * @returns the indices array or an empty array if the mesh has no geometry
  79843. */
  79844. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79845. readonly isBlocked: boolean;
  79846. /**
  79847. * Determine if the current mesh is ready to be rendered
  79848. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79849. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79850. * @returns true if all associated assets are ready (material, textures, shaders)
  79851. */
  79852. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79853. /**
  79854. * 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.
  79855. */
  79856. readonly areNormalsFrozen: boolean;
  79857. /**
  79858. * 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.
  79859. * @returns the current mesh
  79860. */
  79861. freezeNormals(): Mesh;
  79862. /**
  79863. * 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
  79864. * @returns the current mesh
  79865. */
  79866. unfreezeNormals(): Mesh;
  79867. /**
  79868. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79869. */
  79870. overridenInstanceCount: number;
  79871. /** @hidden */
  79872. _preActivate(): Mesh;
  79873. /** @hidden */
  79874. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79875. /** @hidden */
  79876. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79877. /**
  79878. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79879. * This means the mesh underlying bounding box and sphere are recomputed.
  79880. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79881. * @returns the current mesh
  79882. */
  79883. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79884. /** @hidden */
  79885. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79886. /**
  79887. * This function will subdivide the mesh into multiple submeshes
  79888. * @param count defines the expected number of submeshes
  79889. */
  79890. subdivide(count: number): void;
  79891. /**
  79892. * Copy a FloatArray into a specific associated vertex buffer
  79893. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79894. * - VertexBuffer.PositionKind
  79895. * - VertexBuffer.UVKind
  79896. * - VertexBuffer.UV2Kind
  79897. * - VertexBuffer.UV3Kind
  79898. * - VertexBuffer.UV4Kind
  79899. * - VertexBuffer.UV5Kind
  79900. * - VertexBuffer.UV6Kind
  79901. * - VertexBuffer.ColorKind
  79902. * - VertexBuffer.MatricesIndicesKind
  79903. * - VertexBuffer.MatricesIndicesExtraKind
  79904. * - VertexBuffer.MatricesWeightsKind
  79905. * - VertexBuffer.MatricesWeightsExtraKind
  79906. * @param data defines the data source
  79907. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79908. * @param stride defines the data stride size (can be null)
  79909. * @returns the current mesh
  79910. */
  79911. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79912. /**
  79913. * Flags an associated vertex buffer as updatable
  79914. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79915. * - VertexBuffer.PositionKind
  79916. * - VertexBuffer.UVKind
  79917. * - VertexBuffer.UV2Kind
  79918. * - VertexBuffer.UV3Kind
  79919. * - VertexBuffer.UV4Kind
  79920. * - VertexBuffer.UV5Kind
  79921. * - VertexBuffer.UV6Kind
  79922. * - VertexBuffer.ColorKind
  79923. * - VertexBuffer.MatricesIndicesKind
  79924. * - VertexBuffer.MatricesIndicesExtraKind
  79925. * - VertexBuffer.MatricesWeightsKind
  79926. * - VertexBuffer.MatricesWeightsExtraKind
  79927. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79928. */
  79929. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79930. /**
  79931. * Sets the mesh global Vertex Buffer
  79932. * @param buffer defines the buffer to use
  79933. * @returns the current mesh
  79934. */
  79935. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79936. /**
  79937. * Update a specific associated vertex buffer
  79938. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79939. * - VertexBuffer.PositionKind
  79940. * - VertexBuffer.UVKind
  79941. * - VertexBuffer.UV2Kind
  79942. * - VertexBuffer.UV3Kind
  79943. * - VertexBuffer.UV4Kind
  79944. * - VertexBuffer.UV5Kind
  79945. * - VertexBuffer.UV6Kind
  79946. * - VertexBuffer.ColorKind
  79947. * - VertexBuffer.MatricesIndicesKind
  79948. * - VertexBuffer.MatricesIndicesExtraKind
  79949. * - VertexBuffer.MatricesWeightsKind
  79950. * - VertexBuffer.MatricesWeightsExtraKind
  79951. * @param data defines the data source
  79952. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79953. * @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)
  79954. * @returns the current mesh
  79955. */
  79956. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79957. /**
  79958. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79959. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79960. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79961. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79962. * @returns the current mesh
  79963. */
  79964. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79965. /**
  79966. * Creates a un-shared specific occurence of the geometry for the mesh.
  79967. * @returns the current mesh
  79968. */
  79969. makeGeometryUnique(): Mesh;
  79970. /**
  79971. * Set the index buffer of this mesh
  79972. * @param indices defines the source data
  79973. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79974. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79975. * @returns the current mesh
  79976. */
  79977. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79978. /**
  79979. * Update the current index buffer
  79980. * @param indices defines the source data
  79981. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79982. * @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)
  79983. * @returns the current mesh
  79984. */
  79985. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79986. /**
  79987. * Invert the geometry to move from a right handed system to a left handed one.
  79988. * @returns the current mesh
  79989. */
  79990. toLeftHanded(): Mesh;
  79991. /** @hidden */
  79992. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79993. /** @hidden */
  79994. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  79995. /**
  79996. * Registers for this mesh a javascript function called just before the rendering process
  79997. * @param func defines the function to call before rendering this mesh
  79998. * @returns the current mesh
  79999. */
  80000. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80001. /**
  80002. * Disposes a previously registered javascript function called before the rendering
  80003. * @param func defines the function to remove
  80004. * @returns the current mesh
  80005. */
  80006. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80007. /**
  80008. * Registers for this mesh a javascript function called just after the rendering is complete
  80009. * @param func defines the function to call after rendering this mesh
  80010. * @returns the current mesh
  80011. */
  80012. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80013. /**
  80014. * Disposes a previously registered javascript function called after the rendering.
  80015. * @param func defines the function to remove
  80016. * @returns the current mesh
  80017. */
  80018. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80019. /** @hidden */
  80020. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80021. /** @hidden */
  80022. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80023. /** @hidden */
  80024. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80025. /**
  80026. * 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
  80027. * @param subMesh defines the subMesh to render
  80028. * @param enableAlphaMode defines if alpha mode can be changed
  80029. * @returns the current mesh
  80030. */
  80031. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80032. private _onBeforeDraw;
  80033. /**
  80034. * Renormalize the mesh and patch it up if there are no weights
  80035. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80036. * However in the case of zero weights then we set just a single influence to 1.
  80037. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80038. */
  80039. cleanMatrixWeights(): void;
  80040. private normalizeSkinFourWeights;
  80041. private normalizeSkinWeightsAndExtra;
  80042. /**
  80043. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80044. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80045. * the user know there was an issue with importing the mesh
  80046. * @returns a validation object with skinned, valid and report string
  80047. */
  80048. validateSkinning(): {
  80049. skinned: boolean;
  80050. valid: boolean;
  80051. report: string;
  80052. };
  80053. /** @hidden */
  80054. _checkDelayState(): Mesh;
  80055. private _queueLoad;
  80056. /**
  80057. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80058. * A mesh is in the frustum if its bounding box intersects the frustum
  80059. * @param frustumPlanes defines the frustum to test
  80060. * @returns true if the mesh is in the frustum planes
  80061. */
  80062. isInFrustum(frustumPlanes: Plane[]): boolean;
  80063. /**
  80064. * Sets the mesh material by the material or multiMaterial `id` property
  80065. * @param id is a string identifying the material or the multiMaterial
  80066. * @returns the current mesh
  80067. */
  80068. setMaterialByID(id: string): Mesh;
  80069. /**
  80070. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80071. * @returns an array of IAnimatable
  80072. */
  80073. getAnimatables(): IAnimatable[];
  80074. /**
  80075. * Modifies the mesh geometry according to the passed transformation matrix.
  80076. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80077. * The mesh normals are modified using the same transformation.
  80078. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80079. * @param transform defines the transform matrix to use
  80080. * @see http://doc.babylonjs.com/resources/baking_transformations
  80081. * @returns the current mesh
  80082. */
  80083. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80084. /**
  80085. * Modifies the mesh geometry according to its own current World Matrix.
  80086. * The mesh World Matrix is then reset.
  80087. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80088. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80089. * @see http://doc.babylonjs.com/resources/baking_transformations
  80090. * @returns the current mesh
  80091. */
  80092. bakeCurrentTransformIntoVertices(): Mesh;
  80093. /** @hidden */
  80094. readonly _positions: Nullable<Vector3[]>;
  80095. /** @hidden */
  80096. _resetPointsArrayCache(): Mesh;
  80097. /** @hidden */
  80098. _generatePointsArray(): boolean;
  80099. /**
  80100. * Returns a new Mesh object generated from the current mesh properties.
  80101. * This method must not get confused with createInstance()
  80102. * @param name is a string, the name given to the new mesh
  80103. * @param newParent can be any Node object (default `null`)
  80104. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80105. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80106. * @returns a new mesh
  80107. */
  80108. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80109. /**
  80110. * Releases resources associated with this mesh.
  80111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80113. */
  80114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80115. /**
  80116. * Modifies the mesh geometry according to a displacement map.
  80117. * 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.
  80118. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80119. * @param url is a string, the URL from the image file is to be downloaded.
  80120. * @param minHeight is the lower limit of the displacement.
  80121. * @param maxHeight is the upper limit of the displacement.
  80122. * @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.
  80123. * @param uvOffset is an optional vector2 used to offset UV.
  80124. * @param uvScale is an optional vector2 used to scale UV.
  80125. * @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.
  80126. * @returns the Mesh.
  80127. */
  80128. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80129. /**
  80130. * Modifies the mesh geometry according to a displacementMap buffer.
  80131. * 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.
  80132. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80133. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80134. * @param heightMapWidth is the width of the buffer image.
  80135. * @param heightMapHeight is the height of the buffer image.
  80136. * @param minHeight is the lower limit of the displacement.
  80137. * @param maxHeight is the upper limit of the displacement.
  80138. * @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.
  80139. * @param uvOffset is an optional vector2 used to offset UV.
  80140. * @param uvScale is an optional vector2 used to scale UV.
  80141. * @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.
  80142. * @returns the Mesh.
  80143. */
  80144. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80145. /**
  80146. * Modify the mesh to get a flat shading rendering.
  80147. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80148. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80149. * @returns current mesh
  80150. */
  80151. convertToFlatShadedMesh(): Mesh;
  80152. /**
  80153. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80154. * In other words, more vertices, no more indices and a single bigger VBO.
  80155. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80156. * @returns current mesh
  80157. */
  80158. convertToUnIndexedMesh(): Mesh;
  80159. /**
  80160. * Inverses facet orientations.
  80161. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80162. * @param flipNormals will also inverts the normals
  80163. * @returns current mesh
  80164. */
  80165. flipFaces(flipNormals?: boolean): Mesh;
  80166. /**
  80167. * Increase the number of facets and hence vertices in a mesh
  80168. * Vertex normals are interpolated from existing vertex normals
  80169. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80170. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80171. */
  80172. increaseVertices(numberPerEdge: number): void;
  80173. /**
  80174. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80175. * This will undo any application of covertToFlatShadedMesh
  80176. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80177. */
  80178. forceSharedVertices(): void;
  80179. /** @hidden */
  80180. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80181. /** @hidden */
  80182. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80183. /**
  80184. * Creates a new InstancedMesh object from the mesh model.
  80185. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80186. * @param name defines the name of the new instance
  80187. * @returns a new InstancedMesh
  80188. */
  80189. createInstance(name: string): InstancedMesh;
  80190. /**
  80191. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80192. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80193. * @returns the current mesh
  80194. */
  80195. synchronizeInstances(): Mesh;
  80196. /**
  80197. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80198. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80199. * This should be used together with the simplification to avoid disappearing triangles.
  80200. * @param successCallback an optional success callback to be called after the optimization finished.
  80201. * @returns the current mesh
  80202. */
  80203. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80204. /**
  80205. * Serialize current mesh
  80206. * @param serializationObject defines the object which will receive the serialization data
  80207. */
  80208. serialize(serializationObject: any): void;
  80209. /** @hidden */
  80210. _syncGeometryWithMorphTargetManager(): void;
  80211. /** @hidden */
  80212. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80213. /**
  80214. * Returns a new Mesh object parsed from the source provided.
  80215. * @param parsedMesh is the source
  80216. * @param scene defines the hosting scene
  80217. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80218. * @returns a new Mesh
  80219. */
  80220. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80221. /**
  80222. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80223. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80224. * @param name defines the name of the mesh to create
  80225. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80226. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80227. * @param closePath creates a seam between the first and the last points of each path of the path array
  80228. * @param offset is taken in account only if the `pathArray` is containing a single path
  80229. * @param scene defines the hosting scene
  80230. * @param updatable defines if the mesh must be flagged as updatable
  80231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80232. * @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)
  80233. * @returns a new Mesh
  80234. */
  80235. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80236. /**
  80237. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80238. * @param name defines the name of the mesh to create
  80239. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80240. * @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
  80241. * @param scene defines the hosting scene
  80242. * @param updatable defines if the mesh must be flagged as updatable
  80243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80244. * @returns a new Mesh
  80245. */
  80246. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80247. /**
  80248. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80249. * @param name defines the name of the mesh to create
  80250. * @param size sets the size (float) of each box side (default 1)
  80251. * @param scene defines the hosting scene
  80252. * @param updatable defines if the mesh must be flagged as updatable
  80253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80254. * @returns a new Mesh
  80255. */
  80256. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80257. /**
  80258. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80259. * @param name defines the name of the mesh to create
  80260. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80261. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80262. * @param scene defines the hosting scene
  80263. * @param updatable defines if the mesh must be flagged as updatable
  80264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80265. * @returns a new Mesh
  80266. */
  80267. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80268. /**
  80269. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80270. * @param name defines the name of the mesh to create
  80271. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80272. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80273. * @param scene defines the hosting scene
  80274. * @returns a new Mesh
  80275. */
  80276. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80277. /**
  80278. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80279. * @param name defines the name of the mesh to create
  80280. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80281. * @param diameterTop set the top cap diameter (floats, default 1)
  80282. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80283. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80284. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80285. * @param scene defines the hosting scene
  80286. * @param updatable defines if the mesh must be flagged as updatable
  80287. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80288. * @returns a new Mesh
  80289. */
  80290. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80291. /**
  80292. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80293. * @param name defines the name of the mesh to create
  80294. * @param diameter sets the diameter size (float) of the torus (default 1)
  80295. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80296. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80297. * @param scene defines the hosting scene
  80298. * @param updatable defines if the mesh must be flagged as updatable
  80299. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80300. * @returns a new Mesh
  80301. */
  80302. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80303. /**
  80304. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80305. * @param name defines the name of the mesh to create
  80306. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80307. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80308. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80309. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80310. * @param p the number of windings on X axis (positive integers, default 2)
  80311. * @param q the number of windings on Y axis (positive integers, default 3)
  80312. * @param scene defines the hosting scene
  80313. * @param updatable defines if the mesh must be flagged as updatable
  80314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80315. * @returns a new Mesh
  80316. */
  80317. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80318. /**
  80319. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80320. * @param name defines the name of the mesh to create
  80321. * @param points is an array successive Vector3
  80322. * @param scene defines the hosting scene
  80323. * @param updatable defines if the mesh must be flagged as updatable
  80324. * @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).
  80325. * @returns a new Mesh
  80326. */
  80327. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80328. /**
  80329. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80330. * @param name defines the name of the mesh to create
  80331. * @param points is an array successive Vector3
  80332. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80333. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80334. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80335. * @param scene defines the hosting scene
  80336. * @param updatable defines if the mesh must be flagged as updatable
  80337. * @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)
  80338. * @returns a new Mesh
  80339. */
  80340. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80341. /**
  80342. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80343. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80344. * 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.
  80345. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80346. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80347. * Remember you can only change the shape positions, not their number when updating a polygon.
  80348. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80349. * @param name defines the name of the mesh to create
  80350. * @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
  80351. * @param scene defines the hosting scene
  80352. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80353. * @param updatable defines if the mesh must be flagged as updatable
  80354. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80355. * @param earcutInjection can be used to inject your own earcut reference
  80356. * @returns a new Mesh
  80357. */
  80358. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80359. /**
  80360. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80362. * @param name defines the name of the mesh to create
  80363. * @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
  80364. * @param depth defines the height of extrusion
  80365. * @param scene defines the hosting scene
  80366. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80367. * @param updatable defines if the mesh must be flagged as updatable
  80368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80369. * @param earcutInjection can be used to inject your own earcut reference
  80370. * @returns a new Mesh
  80371. */
  80372. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80373. /**
  80374. * Creates an extruded shape mesh.
  80375. * 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
  80376. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80377. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80378. * @param name defines the name of the mesh to create
  80379. * @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
  80380. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80381. * @param scale is the value to scale the shape
  80382. * @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
  80383. * @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
  80384. * @param scene defines the hosting scene
  80385. * @param updatable defines if the mesh must be flagged as updatable
  80386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80387. * @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)
  80388. * @returns a new Mesh
  80389. */
  80390. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80391. /**
  80392. * Creates an custom extruded shape mesh.
  80393. * The custom extrusion is a parametric shape.
  80394. * It has no predefined shape. Its final shape will depend on the input parameters.
  80395. * Please consider using the same method from the MeshBuilder class instead
  80396. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80397. * @param name defines the name of the mesh to create
  80398. * @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
  80399. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80400. * @param scaleFunction is a custom Javascript function called on each path point
  80401. * @param rotationFunction is a custom Javascript function called on each path point
  80402. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80403. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80404. * @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
  80405. * @param scene defines the hosting scene
  80406. * @param updatable defines if the mesh must be flagged as updatable
  80407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80408. * @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)
  80409. * @returns a new Mesh
  80410. */
  80411. 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;
  80412. /**
  80413. * Creates lathe mesh.
  80414. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80415. * Please consider using the same method from the MeshBuilder class instead
  80416. * @param name defines the name of the mesh to create
  80417. * @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
  80418. * @param radius is the radius value of the lathe
  80419. * @param tessellation is the side number of the lathe.
  80420. * @param scene defines the hosting scene
  80421. * @param updatable defines if the mesh must be flagged as updatable
  80422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80423. * @returns a new Mesh
  80424. */
  80425. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80426. /**
  80427. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80428. * @param name defines the name of the mesh to create
  80429. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80430. * @param scene defines the hosting scene
  80431. * @param updatable defines if the mesh must be flagged as updatable
  80432. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80433. * @returns a new Mesh
  80434. */
  80435. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80436. /**
  80437. * Creates a ground mesh.
  80438. * Please consider using the same method from the MeshBuilder class instead
  80439. * @param name defines the name of the mesh to create
  80440. * @param width set the width of the ground
  80441. * @param height set the height of the ground
  80442. * @param subdivisions sets the number of subdivisions per side
  80443. * @param scene defines the hosting scene
  80444. * @param updatable defines if the mesh must be flagged as updatable
  80445. * @returns a new Mesh
  80446. */
  80447. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80448. /**
  80449. * Creates a tiled ground mesh.
  80450. * Please consider using the same method from the MeshBuilder class instead
  80451. * @param name defines the name of the mesh to create
  80452. * @param xmin set the ground minimum X coordinate
  80453. * @param zmin set the ground minimum Y coordinate
  80454. * @param xmax set the ground maximum X coordinate
  80455. * @param zmax set the ground maximum Z coordinate
  80456. * @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
  80457. * @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
  80458. * @param scene defines the hosting scene
  80459. * @param updatable defines if the mesh must be flagged as updatable
  80460. * @returns a new Mesh
  80461. */
  80462. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80463. w: number;
  80464. h: number;
  80465. }, precision: {
  80466. w: number;
  80467. h: number;
  80468. }, scene: Scene, updatable?: boolean): Mesh;
  80469. /**
  80470. * Creates a ground mesh from a height map.
  80471. * Please consider using the same method from the MeshBuilder class instead
  80472. * @see http://doc.babylonjs.com/babylon101/height_map
  80473. * @param name defines the name of the mesh to create
  80474. * @param url sets the URL of the height map image resource
  80475. * @param width set the ground width size
  80476. * @param height set the ground height size
  80477. * @param subdivisions sets the number of subdivision per side
  80478. * @param minHeight is the minimum altitude on the ground
  80479. * @param maxHeight is the maximum altitude on the ground
  80480. * @param scene defines the hosting scene
  80481. * @param updatable defines if the mesh must be flagged as updatable
  80482. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80483. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80484. * @returns a new Mesh
  80485. */
  80486. 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;
  80487. /**
  80488. * Creates a tube mesh.
  80489. * The tube is a parametric shape.
  80490. * It has no predefined shape. Its final shape will depend on the input parameters.
  80491. * Please consider using the same method from the MeshBuilder class instead
  80492. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80493. * @param name defines the name of the mesh to create
  80494. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80495. * @param radius sets the tube radius size
  80496. * @param tessellation is the number of sides on the tubular surface
  80497. * @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
  80498. * @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
  80499. * @param scene defines the hosting scene
  80500. * @param updatable defines if the mesh must be flagged as updatable
  80501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80502. * @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)
  80503. * @returns a new Mesh
  80504. */
  80505. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80506. (i: number, distance: number): number;
  80507. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80508. /**
  80509. * Creates a polyhedron mesh.
  80510. * Please consider using the same method from the MeshBuilder class instead.
  80511. * * 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
  80512. * * The parameter `size` (positive float, default 1) sets the polygon size
  80513. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80514. * * 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`
  80515. * * 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
  80516. * * 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)`)
  80517. * * 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
  80518. * * 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
  80519. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80520. * * If you create a double-sided mesh, you can choose what parts of 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
  80521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80522. * @param name defines the name of the mesh to create
  80523. * @param options defines the options used to create the mesh
  80524. * @param scene defines the hosting scene
  80525. * @returns a new Mesh
  80526. */
  80527. static CreatePolyhedron(name: string, options: {
  80528. type?: number;
  80529. size?: number;
  80530. sizeX?: number;
  80531. sizeY?: number;
  80532. sizeZ?: number;
  80533. custom?: any;
  80534. faceUV?: Vector4[];
  80535. faceColors?: Color4[];
  80536. updatable?: boolean;
  80537. sideOrientation?: number;
  80538. }, scene: Scene): Mesh;
  80539. /**
  80540. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80541. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80542. * * 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`)
  80543. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80544. * * 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
  80545. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80546. * * If you create a double-sided mesh, you can choose what parts of 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
  80547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80548. * @param name defines the name of the mesh
  80549. * @param options defines the options used to create the mesh
  80550. * @param scene defines the hosting scene
  80551. * @returns a new Mesh
  80552. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80553. */
  80554. static CreateIcoSphere(name: string, options: {
  80555. radius?: number;
  80556. flat?: boolean;
  80557. subdivisions?: number;
  80558. sideOrientation?: number;
  80559. updatable?: boolean;
  80560. }, scene: Scene): Mesh;
  80561. /**
  80562. * Creates a decal mesh.
  80563. * Please consider using the same method from the MeshBuilder class instead.
  80564. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80565. * @param name defines the name of the mesh
  80566. * @param sourceMesh defines the mesh receiving the decal
  80567. * @param position sets the position of the decal in world coordinates
  80568. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80569. * @param size sets the decal scaling
  80570. * @param angle sets the angle to rotate the decal
  80571. * @returns a new Mesh
  80572. */
  80573. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80574. /**
  80575. * Prepare internal position array for software CPU skinning
  80576. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80577. */
  80578. setPositionsForCPUSkinning(): Float32Array;
  80579. /**
  80580. * Prepare internal normal array for software CPU skinning
  80581. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80582. */
  80583. setNormalsForCPUSkinning(): Float32Array;
  80584. /**
  80585. * Updates the vertex buffer by applying transformation from the bones
  80586. * @param skeleton defines the skeleton to apply to current mesh
  80587. * @returns the current mesh
  80588. */
  80589. applySkeleton(skeleton: Skeleton): Mesh;
  80590. /**
  80591. * 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
  80592. * @param meshes defines the list of meshes to scan
  80593. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80594. */
  80595. static MinMax(meshes: AbstractMesh[]): {
  80596. min: Vector3;
  80597. max: Vector3;
  80598. };
  80599. /**
  80600. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80601. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80602. * @returns a vector3
  80603. */
  80604. static Center(meshesOrMinMaxVector: {
  80605. min: Vector3;
  80606. max: Vector3;
  80607. } | AbstractMesh[]): Vector3;
  80608. /**
  80609. * Merge the array of meshes into a single mesh for performance reasons.
  80610. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80611. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80612. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80613. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80614. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80615. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80616. * @returns a new mesh
  80617. */
  80618. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80619. /** @hidden */
  80620. addInstance(instance: InstancedMesh): void;
  80621. /** @hidden */
  80622. removeInstance(instance: InstancedMesh): void;
  80623. }
  80624. }
  80625. declare module BABYLON {
  80626. /**
  80627. * Base class for the main features of a material in Babylon.js
  80628. */
  80629. export class Material implements IAnimatable {
  80630. /**
  80631. * Returns the triangle fill mode
  80632. */
  80633. static readonly TriangleFillMode: number;
  80634. /**
  80635. * Returns the wireframe mode
  80636. */
  80637. static readonly WireFrameFillMode: number;
  80638. /**
  80639. * Returns the point fill mode
  80640. */
  80641. static readonly PointFillMode: number;
  80642. /**
  80643. * Returns the point list draw mode
  80644. */
  80645. static readonly PointListDrawMode: number;
  80646. /**
  80647. * Returns the line list draw mode
  80648. */
  80649. static readonly LineListDrawMode: number;
  80650. /**
  80651. * Returns the line loop draw mode
  80652. */
  80653. static readonly LineLoopDrawMode: number;
  80654. /**
  80655. * Returns the line strip draw mode
  80656. */
  80657. static readonly LineStripDrawMode: number;
  80658. /**
  80659. * Returns the triangle strip draw mode
  80660. */
  80661. static readonly TriangleStripDrawMode: number;
  80662. /**
  80663. * Returns the triangle fan draw mode
  80664. */
  80665. static readonly TriangleFanDrawMode: number;
  80666. /**
  80667. * Stores the clock-wise side orientation
  80668. */
  80669. static readonly ClockWiseSideOrientation: number;
  80670. /**
  80671. * Stores the counter clock-wise side orientation
  80672. */
  80673. static readonly CounterClockWiseSideOrientation: number;
  80674. /**
  80675. * The dirty texture flag value
  80676. */
  80677. static readonly TextureDirtyFlag: number;
  80678. /**
  80679. * The dirty light flag value
  80680. */
  80681. static readonly LightDirtyFlag: number;
  80682. /**
  80683. * The dirty fresnel flag value
  80684. */
  80685. static readonly FresnelDirtyFlag: number;
  80686. /**
  80687. * The dirty attribute flag value
  80688. */
  80689. static readonly AttributesDirtyFlag: number;
  80690. /**
  80691. * The dirty misc flag value
  80692. */
  80693. static readonly MiscDirtyFlag: number;
  80694. /**
  80695. * The all dirty flag value
  80696. */
  80697. static readonly AllDirtyFlag: number;
  80698. /**
  80699. * The ID of the material
  80700. */
  80701. id: string;
  80702. /**
  80703. * Gets or sets the unique id of the material
  80704. */
  80705. uniqueId: number;
  80706. /**
  80707. * The name of the material
  80708. */
  80709. name: string;
  80710. /**
  80711. * Gets or sets user defined metadata
  80712. */
  80713. metadata: any;
  80714. /**
  80715. * For internal use only. Please do not use.
  80716. */
  80717. reservedDataStore: any;
  80718. /**
  80719. * Specifies if the ready state should be checked on each call
  80720. */
  80721. checkReadyOnEveryCall: boolean;
  80722. /**
  80723. * Specifies if the ready state should be checked once
  80724. */
  80725. checkReadyOnlyOnce: boolean;
  80726. /**
  80727. * The state of the material
  80728. */
  80729. state: string;
  80730. /**
  80731. * The alpha value of the material
  80732. */
  80733. protected _alpha: number;
  80734. /**
  80735. * List of inspectable custom properties (used by the Inspector)
  80736. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80737. */
  80738. inspectableCustomProperties: IInspectable[];
  80739. /**
  80740. * Sets the alpha value of the material
  80741. */
  80742. /**
  80743. * Gets the alpha value of the material
  80744. */
  80745. alpha: number;
  80746. /**
  80747. * Specifies if back face culling is enabled
  80748. */
  80749. protected _backFaceCulling: boolean;
  80750. /**
  80751. * Sets the back-face culling state
  80752. */
  80753. /**
  80754. * Gets the back-face culling state
  80755. */
  80756. backFaceCulling: boolean;
  80757. /**
  80758. * Stores the value for side orientation
  80759. */
  80760. sideOrientation: number;
  80761. /**
  80762. * Callback triggered when the material is compiled
  80763. */
  80764. onCompiled: (effect: Effect) => void;
  80765. /**
  80766. * Callback triggered when an error occurs
  80767. */
  80768. onError: (effect: Effect, errors: string) => void;
  80769. /**
  80770. * Callback triggered to get the render target textures
  80771. */
  80772. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80773. /**
  80774. * Gets a boolean indicating that current material needs to register RTT
  80775. */
  80776. readonly hasRenderTargetTextures: boolean;
  80777. /**
  80778. * Specifies if the material should be serialized
  80779. */
  80780. doNotSerialize: boolean;
  80781. /**
  80782. * @hidden
  80783. */
  80784. _storeEffectOnSubMeshes: boolean;
  80785. /**
  80786. * Stores the animations for the material
  80787. */
  80788. animations: Array<Animation>;
  80789. /**
  80790. * An event triggered when the material is disposed
  80791. */
  80792. onDisposeObservable: Observable<Material>;
  80793. /**
  80794. * An observer which watches for dispose events
  80795. */
  80796. private _onDisposeObserver;
  80797. private _onUnBindObservable;
  80798. /**
  80799. * Called during a dispose event
  80800. */
  80801. onDispose: () => void;
  80802. private _onBindObservable;
  80803. /**
  80804. * An event triggered when the material is bound
  80805. */
  80806. readonly onBindObservable: Observable<AbstractMesh>;
  80807. /**
  80808. * An observer which watches for bind events
  80809. */
  80810. private _onBindObserver;
  80811. /**
  80812. * Called during a bind event
  80813. */
  80814. onBind: (Mesh: AbstractMesh) => void;
  80815. /**
  80816. * An event triggered when the material is unbound
  80817. */
  80818. readonly onUnBindObservable: Observable<Material>;
  80819. /**
  80820. * Stores the value of the alpha mode
  80821. */
  80822. private _alphaMode;
  80823. /**
  80824. * Sets the value of the alpha mode.
  80825. *
  80826. * | Value | Type | Description |
  80827. * | --- | --- | --- |
  80828. * | 0 | ALPHA_DISABLE | |
  80829. * | 1 | ALPHA_ADD | |
  80830. * | 2 | ALPHA_COMBINE | |
  80831. * | 3 | ALPHA_SUBTRACT | |
  80832. * | 4 | ALPHA_MULTIPLY | |
  80833. * | 5 | ALPHA_MAXIMIZED | |
  80834. * | 6 | ALPHA_ONEONE | |
  80835. * | 7 | ALPHA_PREMULTIPLIED | |
  80836. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80837. * | 9 | ALPHA_INTERPOLATE | |
  80838. * | 10 | ALPHA_SCREENMODE | |
  80839. *
  80840. */
  80841. /**
  80842. * Gets the value of the alpha mode
  80843. */
  80844. alphaMode: number;
  80845. /**
  80846. * Stores the state of the need depth pre-pass value
  80847. */
  80848. private _needDepthPrePass;
  80849. /**
  80850. * Sets the need depth pre-pass value
  80851. */
  80852. /**
  80853. * Gets the depth pre-pass value
  80854. */
  80855. needDepthPrePass: boolean;
  80856. /**
  80857. * Specifies if depth writing should be disabled
  80858. */
  80859. disableDepthWrite: boolean;
  80860. /**
  80861. * Specifies if depth writing should be forced
  80862. */
  80863. forceDepthWrite: boolean;
  80864. /**
  80865. * Specifies if there should be a separate pass for culling
  80866. */
  80867. separateCullingPass: boolean;
  80868. /**
  80869. * Stores the state specifing if fog should be enabled
  80870. */
  80871. private _fogEnabled;
  80872. /**
  80873. * Sets the state for enabling fog
  80874. */
  80875. /**
  80876. * Gets the value of the fog enabled state
  80877. */
  80878. fogEnabled: boolean;
  80879. /**
  80880. * Stores the size of points
  80881. */
  80882. pointSize: number;
  80883. /**
  80884. * Stores the z offset value
  80885. */
  80886. zOffset: number;
  80887. /**
  80888. * Gets a value specifying if wireframe mode is enabled
  80889. */
  80890. /**
  80891. * Sets the state of wireframe mode
  80892. */
  80893. wireframe: boolean;
  80894. /**
  80895. * Gets the value specifying if point clouds are enabled
  80896. */
  80897. /**
  80898. * Sets the state of point cloud mode
  80899. */
  80900. pointsCloud: boolean;
  80901. /**
  80902. * Gets the material fill mode
  80903. */
  80904. /**
  80905. * Sets the material fill mode
  80906. */
  80907. fillMode: number;
  80908. /**
  80909. * @hidden
  80910. * Stores the effects for the material
  80911. */
  80912. _effect: Nullable<Effect>;
  80913. /**
  80914. * @hidden
  80915. * Specifies if the material was previously ready
  80916. */
  80917. _wasPreviouslyReady: boolean;
  80918. /**
  80919. * Specifies if uniform buffers should be used
  80920. */
  80921. private _useUBO;
  80922. /**
  80923. * Stores a reference to the scene
  80924. */
  80925. private _scene;
  80926. /**
  80927. * Stores the fill mode state
  80928. */
  80929. private _fillMode;
  80930. /**
  80931. * Specifies if the depth write state should be cached
  80932. */
  80933. private _cachedDepthWriteState;
  80934. /**
  80935. * Stores the uniform buffer
  80936. */
  80937. protected _uniformBuffer: UniformBuffer;
  80938. /** @hidden */
  80939. _indexInSceneMaterialArray: number;
  80940. /** @hidden */
  80941. meshMap: Nullable<{
  80942. [id: string]: AbstractMesh | undefined;
  80943. }>;
  80944. /**
  80945. * Creates a material instance
  80946. * @param name defines the name of the material
  80947. * @param scene defines the scene to reference
  80948. * @param doNotAdd specifies if the material should be added to the scene
  80949. */
  80950. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80951. /**
  80952. * Returns a string representation of the current material
  80953. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80954. * @returns a string with material information
  80955. */
  80956. toString(fullDetails?: boolean): string;
  80957. /**
  80958. * Gets the class name of the material
  80959. * @returns a string with the class name of the material
  80960. */
  80961. getClassName(): string;
  80962. /**
  80963. * Specifies if updates for the material been locked
  80964. */
  80965. readonly isFrozen: boolean;
  80966. /**
  80967. * Locks updates for the material
  80968. */
  80969. freeze(): void;
  80970. /**
  80971. * Unlocks updates for the material
  80972. */
  80973. unfreeze(): void;
  80974. /**
  80975. * Specifies if the material is ready to be used
  80976. * @param mesh defines the mesh to check
  80977. * @param useInstances specifies if instances should be used
  80978. * @returns a boolean indicating if the material is ready to be used
  80979. */
  80980. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80981. /**
  80982. * Specifies that the submesh is ready to be used
  80983. * @param mesh defines the mesh to check
  80984. * @param subMesh defines which submesh to check
  80985. * @param useInstances specifies that instances should be used
  80986. * @returns a boolean indicating that the submesh is ready or not
  80987. */
  80988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80989. /**
  80990. * Returns the material effect
  80991. * @returns the effect associated with the material
  80992. */
  80993. getEffect(): Nullable<Effect>;
  80994. /**
  80995. * Returns the current scene
  80996. * @returns a Scene
  80997. */
  80998. getScene(): Scene;
  80999. /**
  81000. * Specifies if the material will require alpha blending
  81001. * @returns a boolean specifying if alpha blending is needed
  81002. */
  81003. needAlphaBlending(): boolean;
  81004. /**
  81005. * Specifies if the mesh will require alpha blending
  81006. * @param mesh defines the mesh to check
  81007. * @returns a boolean specifying if alpha blending is needed for the mesh
  81008. */
  81009. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81010. /**
  81011. * Specifies if this material should be rendered in alpha test mode
  81012. * @returns a boolean specifying if an alpha test is needed.
  81013. */
  81014. needAlphaTesting(): boolean;
  81015. /**
  81016. * Gets the texture used for the alpha test
  81017. * @returns the texture to use for alpha testing
  81018. */
  81019. getAlphaTestTexture(): Nullable<BaseTexture>;
  81020. /**
  81021. * Marks the material to indicate that it needs to be re-calculated
  81022. */
  81023. markDirty(): void;
  81024. /** @hidden */
  81025. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81026. /**
  81027. * Binds the material to the mesh
  81028. * @param world defines the world transformation matrix
  81029. * @param mesh defines the mesh to bind the material to
  81030. */
  81031. bind(world: Matrix, mesh?: Mesh): void;
  81032. /**
  81033. * Binds the submesh to the material
  81034. * @param world defines the world transformation matrix
  81035. * @param mesh defines the mesh containing the submesh
  81036. * @param subMesh defines the submesh to bind the material to
  81037. */
  81038. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81039. /**
  81040. * Binds the world matrix to the material
  81041. * @param world defines the world transformation matrix
  81042. */
  81043. bindOnlyWorldMatrix(world: Matrix): void;
  81044. /**
  81045. * Binds the scene's uniform buffer to the effect.
  81046. * @param effect defines the effect to bind to the scene uniform buffer
  81047. * @param sceneUbo defines the uniform buffer storing scene data
  81048. */
  81049. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81050. /**
  81051. * Binds the view matrix to the effect
  81052. * @param effect defines the effect to bind the view matrix to
  81053. */
  81054. bindView(effect: Effect): void;
  81055. /**
  81056. * Binds the view projection matrix to the effect
  81057. * @param effect defines the effect to bind the view projection matrix to
  81058. */
  81059. bindViewProjection(effect: Effect): void;
  81060. /**
  81061. * Specifies if material alpha testing should be turned on for the mesh
  81062. * @param mesh defines the mesh to check
  81063. */
  81064. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81065. /**
  81066. * Processes to execute after binding the material to a mesh
  81067. * @param mesh defines the rendered mesh
  81068. */
  81069. protected _afterBind(mesh?: Mesh): void;
  81070. /**
  81071. * Unbinds the material from the mesh
  81072. */
  81073. unbind(): void;
  81074. /**
  81075. * Gets the active textures from the material
  81076. * @returns an array of textures
  81077. */
  81078. getActiveTextures(): BaseTexture[];
  81079. /**
  81080. * Specifies if the material uses a texture
  81081. * @param texture defines the texture to check against the material
  81082. * @returns a boolean specifying if the material uses the texture
  81083. */
  81084. hasTexture(texture: BaseTexture): boolean;
  81085. /**
  81086. * Makes a duplicate of the material, and gives it a new name
  81087. * @param name defines the new name for the duplicated material
  81088. * @returns the cloned material
  81089. */
  81090. clone(name: string): Nullable<Material>;
  81091. /**
  81092. * Gets the meshes bound to the material
  81093. * @returns an array of meshes bound to the material
  81094. */
  81095. getBindedMeshes(): AbstractMesh[];
  81096. /**
  81097. * Force shader compilation
  81098. * @param mesh defines the mesh associated with this material
  81099. * @param onCompiled defines a function to execute once the material is compiled
  81100. * @param options defines the options to configure the compilation
  81101. */
  81102. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81103. clipPlane: boolean;
  81104. }>): void;
  81105. /**
  81106. * Force shader compilation
  81107. * @param mesh defines the mesh that will use this material
  81108. * @param options defines additional options for compiling the shaders
  81109. * @returns a promise that resolves when the compilation completes
  81110. */
  81111. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81112. clipPlane: boolean;
  81113. }>): Promise<void>;
  81114. private static readonly _ImageProcessingDirtyCallBack;
  81115. private static readonly _TextureDirtyCallBack;
  81116. private static readonly _FresnelDirtyCallBack;
  81117. private static readonly _MiscDirtyCallBack;
  81118. private static readonly _LightsDirtyCallBack;
  81119. private static readonly _AttributeDirtyCallBack;
  81120. private static _FresnelAndMiscDirtyCallBack;
  81121. private static _TextureAndMiscDirtyCallBack;
  81122. private static readonly _DirtyCallbackArray;
  81123. private static readonly _RunDirtyCallBacks;
  81124. /**
  81125. * Marks a define in the material to indicate that it needs to be re-computed
  81126. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81127. */
  81128. markAsDirty(flag: number): void;
  81129. /**
  81130. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81131. * @param func defines a function which checks material defines against the submeshes
  81132. */
  81133. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81134. /**
  81135. * Indicates that image processing needs to be re-calculated for all submeshes
  81136. */
  81137. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81138. /**
  81139. * Indicates that textures need to be re-calculated for all submeshes
  81140. */
  81141. protected _markAllSubMeshesAsTexturesDirty(): void;
  81142. /**
  81143. * Indicates that fresnel needs to be re-calculated for all submeshes
  81144. */
  81145. protected _markAllSubMeshesAsFresnelDirty(): void;
  81146. /**
  81147. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81148. */
  81149. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81150. /**
  81151. * Indicates that lights need to be re-calculated for all submeshes
  81152. */
  81153. protected _markAllSubMeshesAsLightsDirty(): void;
  81154. /**
  81155. * Indicates that attributes need to be re-calculated for all submeshes
  81156. */
  81157. protected _markAllSubMeshesAsAttributesDirty(): void;
  81158. /**
  81159. * Indicates that misc needs to be re-calculated for all submeshes
  81160. */
  81161. protected _markAllSubMeshesAsMiscDirty(): void;
  81162. /**
  81163. * Indicates that textures and misc need to be re-calculated for all submeshes
  81164. */
  81165. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81166. /**
  81167. * Disposes the material
  81168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81171. */
  81172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81173. /** @hidden */
  81174. private releaseVertexArrayObject;
  81175. /**
  81176. * Serializes this material
  81177. * @returns the serialized material object
  81178. */
  81179. serialize(): any;
  81180. /**
  81181. * Creates a material from parsed material data
  81182. * @param parsedMaterial defines parsed material data
  81183. * @param scene defines the hosting scene
  81184. * @param rootUrl defines the root URL to use to load textures
  81185. * @returns a new material
  81186. */
  81187. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  81188. }
  81189. }
  81190. declare module BABYLON {
  81191. /**
  81192. * Base class for submeshes
  81193. */
  81194. export class BaseSubMesh {
  81195. /** @hidden */
  81196. _materialDefines: Nullable<MaterialDefines>;
  81197. /** @hidden */
  81198. _materialEffect: Nullable<Effect>;
  81199. /**
  81200. * Gets associated effect
  81201. */
  81202. readonly effect: Nullable<Effect>;
  81203. /**
  81204. * Sets associated effect (effect used to render this submesh)
  81205. * @param effect defines the effect to associate with
  81206. * @param defines defines the set of defines used to compile this effect
  81207. */
  81208. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81209. }
  81210. /**
  81211. * Defines a subdivision inside a mesh
  81212. */
  81213. export class SubMesh extends BaseSubMesh implements ICullable {
  81214. /** the material index to use */
  81215. materialIndex: number;
  81216. /** vertex index start */
  81217. verticesStart: number;
  81218. /** vertices count */
  81219. verticesCount: number;
  81220. /** index start */
  81221. indexStart: number;
  81222. /** indices count */
  81223. indexCount: number;
  81224. /** @hidden */
  81225. _linesIndexCount: number;
  81226. private _mesh;
  81227. private _renderingMesh;
  81228. private _boundingInfo;
  81229. private _linesIndexBuffer;
  81230. /** @hidden */
  81231. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81232. /** @hidden */
  81233. _trianglePlanes: Plane[];
  81234. /** @hidden */
  81235. _lastColliderTransformMatrix: Matrix;
  81236. /** @hidden */
  81237. _renderId: number;
  81238. /** @hidden */
  81239. _alphaIndex: number;
  81240. /** @hidden */
  81241. _distanceToCamera: number;
  81242. /** @hidden */
  81243. _id: number;
  81244. private _currentMaterial;
  81245. /**
  81246. * Add a new submesh to a mesh
  81247. * @param materialIndex defines the material index to use
  81248. * @param verticesStart defines vertex index start
  81249. * @param verticesCount defines vertices count
  81250. * @param indexStart defines index start
  81251. * @param indexCount defines indices count
  81252. * @param mesh defines the parent mesh
  81253. * @param renderingMesh defines an optional rendering mesh
  81254. * @param createBoundingBox defines if bounding box should be created for this submesh
  81255. * @returns the new submesh
  81256. */
  81257. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81258. /**
  81259. * Creates a new submesh
  81260. * @param materialIndex defines the material index to use
  81261. * @param verticesStart defines vertex index start
  81262. * @param verticesCount defines vertices count
  81263. * @param indexStart defines index start
  81264. * @param indexCount defines indices count
  81265. * @param mesh defines the parent mesh
  81266. * @param renderingMesh defines an optional rendering mesh
  81267. * @param createBoundingBox defines if bounding box should be created for this submesh
  81268. */
  81269. constructor(
  81270. /** the material index to use */
  81271. materialIndex: number,
  81272. /** vertex index start */
  81273. verticesStart: number,
  81274. /** vertices count */
  81275. verticesCount: number,
  81276. /** index start */
  81277. indexStart: number,
  81278. /** indices count */
  81279. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81280. /**
  81281. * Returns true if this submesh covers the entire parent mesh
  81282. * @ignorenaming
  81283. */
  81284. readonly IsGlobal: boolean;
  81285. /**
  81286. * Returns the submesh BoudingInfo object
  81287. * @returns current bounding info (or mesh's one if the submesh is global)
  81288. */
  81289. getBoundingInfo(): BoundingInfo;
  81290. /**
  81291. * Sets the submesh BoundingInfo
  81292. * @param boundingInfo defines the new bounding info to use
  81293. * @returns the SubMesh
  81294. */
  81295. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81296. /**
  81297. * Returns the mesh of the current submesh
  81298. * @return the parent mesh
  81299. */
  81300. getMesh(): AbstractMesh;
  81301. /**
  81302. * Returns the rendering mesh of the submesh
  81303. * @returns the rendering mesh (could be different from parent mesh)
  81304. */
  81305. getRenderingMesh(): Mesh;
  81306. /**
  81307. * Returns the submesh material
  81308. * @returns null or the current material
  81309. */
  81310. getMaterial(): Nullable<Material>;
  81311. /**
  81312. * Sets a new updated BoundingInfo object to the submesh
  81313. * @returns the SubMesh
  81314. */
  81315. refreshBoundingInfo(): SubMesh;
  81316. /** @hidden */
  81317. _checkCollision(collider: Collider): boolean;
  81318. /**
  81319. * Updates the submesh BoundingInfo
  81320. * @param world defines the world matrix to use to update the bounding info
  81321. * @returns the submesh
  81322. */
  81323. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81324. /**
  81325. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81326. * @param frustumPlanes defines the frustum planes
  81327. * @returns true if the submesh is intersecting with the frustum
  81328. */
  81329. isInFrustum(frustumPlanes: Plane[]): boolean;
  81330. /**
  81331. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81332. * @param frustumPlanes defines the frustum planes
  81333. * @returns true if the submesh is inside the frustum
  81334. */
  81335. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81336. /**
  81337. * Renders the submesh
  81338. * @param enableAlphaMode defines if alpha needs to be used
  81339. * @returns the submesh
  81340. */
  81341. render(enableAlphaMode: boolean): SubMesh;
  81342. /**
  81343. * @hidden
  81344. */
  81345. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81346. /**
  81347. * Checks if the submesh intersects with a ray
  81348. * @param ray defines the ray to test
  81349. * @returns true is the passed ray intersects the submesh bounding box
  81350. */
  81351. canIntersects(ray: Ray): boolean;
  81352. /**
  81353. * Intersects current submesh with a ray
  81354. * @param ray defines the ray to test
  81355. * @param positions defines mesh's positions array
  81356. * @param indices defines mesh's indices array
  81357. * @param fastCheck defines if only bounding info should be used
  81358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81359. * @returns intersection info or null if no intersection
  81360. */
  81361. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81362. /** @hidden */
  81363. private _intersectLines;
  81364. /** @hidden */
  81365. private _intersectTriangles;
  81366. /** @hidden */
  81367. _rebuild(): void;
  81368. /**
  81369. * Creates a new submesh from the passed mesh
  81370. * @param newMesh defines the new hosting mesh
  81371. * @param newRenderingMesh defines an optional rendering mesh
  81372. * @returns the new submesh
  81373. */
  81374. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81375. /**
  81376. * Release associated resources
  81377. */
  81378. dispose(): void;
  81379. /**
  81380. * Gets the class name
  81381. * @returns the string "SubMesh".
  81382. */
  81383. getClassName(): string;
  81384. /**
  81385. * Creates a new submesh from indices data
  81386. * @param materialIndex the index of the main mesh material
  81387. * @param startIndex the index where to start the copy in the mesh indices array
  81388. * @param indexCount the number of indices to copy then from the startIndex
  81389. * @param mesh the main mesh to create the submesh from
  81390. * @param renderingMesh the optional rendering mesh
  81391. * @returns a new submesh
  81392. */
  81393. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81394. }
  81395. }
  81396. declare module BABYLON {
  81397. /**
  81398. * Class used to store geometry data (vertex buffers + index buffer)
  81399. */
  81400. export class Geometry implements IGetSetVerticesData {
  81401. /**
  81402. * Gets or sets the ID of the geometry
  81403. */
  81404. id: string;
  81405. /**
  81406. * Gets or sets the unique ID of the geometry
  81407. */
  81408. uniqueId: number;
  81409. /**
  81410. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81411. */
  81412. delayLoadState: number;
  81413. /**
  81414. * Gets the file containing the data to load when running in delay load state
  81415. */
  81416. delayLoadingFile: Nullable<string>;
  81417. /**
  81418. * Callback called when the geometry is updated
  81419. */
  81420. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81421. private _scene;
  81422. private _engine;
  81423. private _meshes;
  81424. private _totalVertices;
  81425. /** @hidden */
  81426. _indices: IndicesArray;
  81427. /** @hidden */
  81428. _vertexBuffers: {
  81429. [key: string]: VertexBuffer;
  81430. };
  81431. private _isDisposed;
  81432. private _extend;
  81433. private _boundingBias;
  81434. /** @hidden */
  81435. _delayInfo: Array<string>;
  81436. private _indexBuffer;
  81437. private _indexBufferIsUpdatable;
  81438. /** @hidden */
  81439. _boundingInfo: Nullable<BoundingInfo>;
  81440. /** @hidden */
  81441. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81442. /** @hidden */
  81443. _softwareSkinningFrameId: number;
  81444. private _vertexArrayObjects;
  81445. private _updatable;
  81446. /** @hidden */
  81447. _positions: Nullable<Vector3[]>;
  81448. /**
  81449. * 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
  81450. */
  81451. /**
  81452. * 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
  81453. */
  81454. boundingBias: Vector2;
  81455. /**
  81456. * Static function used to attach a new empty geometry to a mesh
  81457. * @param mesh defines the mesh to attach the geometry to
  81458. * @returns the new Geometry
  81459. */
  81460. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81461. /**
  81462. * Creates a new geometry
  81463. * @param id defines the unique ID
  81464. * @param scene defines the hosting scene
  81465. * @param vertexData defines the VertexData used to get geometry data
  81466. * @param updatable defines if geometry must be updatable (false by default)
  81467. * @param mesh defines the mesh that will be associated with the geometry
  81468. */
  81469. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81470. /**
  81471. * Gets the current extend of the geometry
  81472. */
  81473. readonly extend: {
  81474. minimum: Vector3;
  81475. maximum: Vector3;
  81476. };
  81477. /**
  81478. * Gets the hosting scene
  81479. * @returns the hosting Scene
  81480. */
  81481. getScene(): Scene;
  81482. /**
  81483. * Gets the hosting engine
  81484. * @returns the hosting Engine
  81485. */
  81486. getEngine(): Engine;
  81487. /**
  81488. * Defines if the geometry is ready to use
  81489. * @returns true if the geometry is ready to be used
  81490. */
  81491. isReady(): boolean;
  81492. /**
  81493. * Gets a value indicating that the geometry should not be serialized
  81494. */
  81495. readonly doNotSerialize: boolean;
  81496. /** @hidden */
  81497. _rebuild(): void;
  81498. /**
  81499. * Affects all geometry data in one call
  81500. * @param vertexData defines the geometry data
  81501. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81502. */
  81503. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81504. /**
  81505. * Set specific vertex data
  81506. * @param kind defines the data kind (Position, normal, etc...)
  81507. * @param data defines the vertex data to use
  81508. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81509. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81510. */
  81511. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81512. /**
  81513. * Removes a specific vertex data
  81514. * @param kind defines the data kind (Position, normal, etc...)
  81515. */
  81516. removeVerticesData(kind: string): void;
  81517. /**
  81518. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81519. * @param buffer defines the vertex buffer to use
  81520. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81521. */
  81522. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81523. /**
  81524. * Update a specific vertex buffer
  81525. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81526. * It will do nothing if the buffer is not updatable
  81527. * @param kind defines the data kind (Position, normal, etc...)
  81528. * @param data defines the data to use
  81529. * @param offset defines the offset in the target buffer where to store the data
  81530. * @param useBytes set to true if the offset is in bytes
  81531. */
  81532. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81533. /**
  81534. * Update a specific vertex buffer
  81535. * This function will create a new buffer if the current one is not updatable
  81536. * @param kind defines the data kind (Position, normal, etc...)
  81537. * @param data defines the data to use
  81538. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81539. */
  81540. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81541. private _updateBoundingInfo;
  81542. /** @hidden */
  81543. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81544. /**
  81545. * Gets total number of vertices
  81546. * @returns the total number of vertices
  81547. */
  81548. getTotalVertices(): number;
  81549. /**
  81550. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81551. * @param kind defines the data kind (Position, normal, etc...)
  81552. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81554. * @returns a float array containing vertex data
  81555. */
  81556. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81557. /**
  81558. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81559. * @param kind defines the data kind (Position, normal, etc...)
  81560. * @returns true if the vertex buffer with the specified kind is updatable
  81561. */
  81562. isVertexBufferUpdatable(kind: string): boolean;
  81563. /**
  81564. * Gets a specific vertex buffer
  81565. * @param kind defines the data kind (Position, normal, etc...)
  81566. * @returns a VertexBuffer
  81567. */
  81568. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81569. /**
  81570. * Returns all vertex buffers
  81571. * @return an object holding all vertex buffers indexed by kind
  81572. */
  81573. getVertexBuffers(): Nullable<{
  81574. [key: string]: VertexBuffer;
  81575. }>;
  81576. /**
  81577. * Gets a boolean indicating if specific vertex buffer is present
  81578. * @param kind defines the data kind (Position, normal, etc...)
  81579. * @returns true if data is present
  81580. */
  81581. isVerticesDataPresent(kind: string): boolean;
  81582. /**
  81583. * Gets a list of all attached data kinds (Position, normal, etc...)
  81584. * @returns a list of string containing all kinds
  81585. */
  81586. getVerticesDataKinds(): string[];
  81587. /**
  81588. * Update index buffer
  81589. * @param indices defines the indices to store in the index buffer
  81590. * @param offset defines the offset in the target buffer where to store the data
  81591. * @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)
  81592. */
  81593. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81594. /**
  81595. * Creates a new index buffer
  81596. * @param indices defines the indices to store in the index buffer
  81597. * @param totalVertices defines the total number of vertices (could be null)
  81598. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81599. */
  81600. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81601. /**
  81602. * Return the total number of indices
  81603. * @returns the total number of indices
  81604. */
  81605. getTotalIndices(): number;
  81606. /**
  81607. * Gets the index buffer array
  81608. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81609. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81610. * @returns the index buffer array
  81611. */
  81612. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81613. /**
  81614. * Gets the index buffer
  81615. * @return the index buffer
  81616. */
  81617. getIndexBuffer(): Nullable<WebGLBuffer>;
  81618. /** @hidden */
  81619. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81620. /**
  81621. * Release the associated resources for a specific mesh
  81622. * @param mesh defines the source mesh
  81623. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81624. */
  81625. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81626. /**
  81627. * Apply current geometry to a given mesh
  81628. * @param mesh defines the mesh to apply geometry to
  81629. */
  81630. applyToMesh(mesh: Mesh): void;
  81631. private _updateExtend;
  81632. private _applyToMesh;
  81633. private notifyUpdate;
  81634. /**
  81635. * Load the geometry if it was flagged as delay loaded
  81636. * @param scene defines the hosting scene
  81637. * @param onLoaded defines a callback called when the geometry is loaded
  81638. */
  81639. load(scene: Scene, onLoaded?: () => void): void;
  81640. private _queueLoad;
  81641. /**
  81642. * Invert the geometry to move from a right handed system to a left handed one.
  81643. */
  81644. toLeftHanded(): void;
  81645. /** @hidden */
  81646. _resetPointsArrayCache(): void;
  81647. /** @hidden */
  81648. _generatePointsArray(): boolean;
  81649. /**
  81650. * Gets a value indicating if the geometry is disposed
  81651. * @returns true if the geometry was disposed
  81652. */
  81653. isDisposed(): boolean;
  81654. private _disposeVertexArrayObjects;
  81655. /**
  81656. * Free all associated resources
  81657. */
  81658. dispose(): void;
  81659. /**
  81660. * Clone the current geometry into a new geometry
  81661. * @param id defines the unique ID of the new geometry
  81662. * @returns a new geometry object
  81663. */
  81664. copy(id: string): Geometry;
  81665. /**
  81666. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81667. * @return a JSON representation of the current geometry data (without the vertices data)
  81668. */
  81669. serialize(): any;
  81670. private toNumberArray;
  81671. /**
  81672. * Serialize all vertices data into a JSON oject
  81673. * @returns a JSON representation of the current geometry data
  81674. */
  81675. serializeVerticeData(): any;
  81676. /**
  81677. * Extracts a clone of a mesh geometry
  81678. * @param mesh defines the source mesh
  81679. * @param id defines the unique ID of the new geometry object
  81680. * @returns the new geometry object
  81681. */
  81682. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81683. /**
  81684. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81685. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81686. * Be aware Math.random() could cause collisions, but:
  81687. * "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"
  81688. * @returns a string containing a new GUID
  81689. */
  81690. static RandomId(): string;
  81691. /** @hidden */
  81692. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81693. private static _CleanMatricesWeights;
  81694. /**
  81695. * Create a new geometry from persisted data (Using .babylon file format)
  81696. * @param parsedVertexData defines the persisted data
  81697. * @param scene defines the hosting scene
  81698. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81699. * @returns the new geometry object
  81700. */
  81701. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81702. }
  81703. }
  81704. declare module BABYLON {
  81705. /**
  81706. * Define an interface for all classes that will get and set the data on vertices
  81707. */
  81708. export interface IGetSetVerticesData {
  81709. /**
  81710. * Gets a boolean indicating if specific vertex data is present
  81711. * @param kind defines the vertex data kind to use
  81712. * @returns true is data kind is present
  81713. */
  81714. isVerticesDataPresent(kind: string): boolean;
  81715. /**
  81716. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81717. * @param kind defines the data kind (Position, normal, etc...)
  81718. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81719. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81720. * @returns a float array containing vertex data
  81721. */
  81722. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81723. /**
  81724. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81725. * @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.
  81726. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81727. * @returns the indices array or an empty array if the mesh has no geometry
  81728. */
  81729. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81730. /**
  81731. * Set specific vertex data
  81732. * @param kind defines the data kind (Position, normal, etc...)
  81733. * @param data defines the vertex data to use
  81734. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81735. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81736. */
  81737. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81738. /**
  81739. * Update a specific associated vertex buffer
  81740. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81741. * - VertexBuffer.PositionKind
  81742. * - VertexBuffer.UVKind
  81743. * - VertexBuffer.UV2Kind
  81744. * - VertexBuffer.UV3Kind
  81745. * - VertexBuffer.UV4Kind
  81746. * - VertexBuffer.UV5Kind
  81747. * - VertexBuffer.UV6Kind
  81748. * - VertexBuffer.ColorKind
  81749. * - VertexBuffer.MatricesIndicesKind
  81750. * - VertexBuffer.MatricesIndicesExtraKind
  81751. * - VertexBuffer.MatricesWeightsKind
  81752. * - VertexBuffer.MatricesWeightsExtraKind
  81753. * @param data defines the data source
  81754. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81755. * @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)
  81756. */
  81757. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  81758. /**
  81759. * Creates a new index buffer
  81760. * @param indices defines the indices to store in the index buffer
  81761. * @param totalVertices defines the total number of vertices (could be null)
  81762. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81763. */
  81764. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  81765. }
  81766. /**
  81767. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81768. */
  81769. export class VertexData {
  81770. /**
  81771. * Mesh side orientation : usually the external or front surface
  81772. */
  81773. static readonly FRONTSIDE: number;
  81774. /**
  81775. * Mesh side orientation : usually the internal or back surface
  81776. */
  81777. static readonly BACKSIDE: number;
  81778. /**
  81779. * Mesh side orientation : both internal and external or front and back surfaces
  81780. */
  81781. static readonly DOUBLESIDE: number;
  81782. /**
  81783. * Mesh side orientation : by default, `FRONTSIDE`
  81784. */
  81785. static readonly DEFAULTSIDE: number;
  81786. /**
  81787. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81788. */
  81789. positions: Nullable<FloatArray>;
  81790. /**
  81791. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81792. */
  81793. normals: Nullable<FloatArray>;
  81794. /**
  81795. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81796. */
  81797. tangents: Nullable<FloatArray>;
  81798. /**
  81799. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81800. */
  81801. uvs: Nullable<FloatArray>;
  81802. /**
  81803. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81804. */
  81805. uvs2: Nullable<FloatArray>;
  81806. /**
  81807. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81808. */
  81809. uvs3: Nullable<FloatArray>;
  81810. /**
  81811. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81812. */
  81813. uvs4: Nullable<FloatArray>;
  81814. /**
  81815. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81816. */
  81817. uvs5: Nullable<FloatArray>;
  81818. /**
  81819. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81820. */
  81821. uvs6: Nullable<FloatArray>;
  81822. /**
  81823. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81824. */
  81825. colors: Nullable<FloatArray>;
  81826. /**
  81827. * 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).
  81828. */
  81829. matricesIndices: Nullable<FloatArray>;
  81830. /**
  81831. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81832. */
  81833. matricesWeights: Nullable<FloatArray>;
  81834. /**
  81835. * An array extending the number of possible indices
  81836. */
  81837. matricesIndicesExtra: Nullable<FloatArray>;
  81838. /**
  81839. * An array extending the number of possible weights when the number of indices is extended
  81840. */
  81841. matricesWeightsExtra: Nullable<FloatArray>;
  81842. /**
  81843. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81844. */
  81845. indices: Nullable<IndicesArray>;
  81846. /**
  81847. * Uses the passed data array to set the set the values for the specified kind of data
  81848. * @param data a linear array of floating numbers
  81849. * @param kind the type of data that is being set, eg positions, colors etc
  81850. */
  81851. set(data: FloatArray, kind: string): void;
  81852. /**
  81853. * Associates the vertexData to the passed Mesh.
  81854. * Sets it as updatable or not (default `false`)
  81855. * @param mesh the mesh the vertexData is applied to
  81856. * @param updatable when used and having the value true allows new data to update the vertexData
  81857. * @returns the VertexData
  81858. */
  81859. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81860. /**
  81861. * Associates the vertexData to the passed Geometry.
  81862. * Sets it as updatable or not (default `false`)
  81863. * @param geometry the geometry the vertexData is applied to
  81864. * @param updatable when used and having the value true allows new data to update the vertexData
  81865. * @returns VertexData
  81866. */
  81867. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81868. /**
  81869. * Updates the associated mesh
  81870. * @param mesh the mesh to be updated
  81871. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81872. * @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
  81873. * @returns VertexData
  81874. */
  81875. updateMesh(mesh: Mesh): VertexData;
  81876. /**
  81877. * Updates the associated geometry
  81878. * @param geometry the geometry to be updated
  81879. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81880. * @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
  81881. * @returns VertexData.
  81882. */
  81883. updateGeometry(geometry: Geometry): VertexData;
  81884. private _applyTo;
  81885. private _update;
  81886. /**
  81887. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81888. * @param matrix the transforming matrix
  81889. * @returns the VertexData
  81890. */
  81891. transform(matrix: Matrix): VertexData;
  81892. /**
  81893. * Merges the passed VertexData into the current one
  81894. * @param other the VertexData to be merged into the current one
  81895. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81896. * @returns the modified VertexData
  81897. */
  81898. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81899. private _mergeElement;
  81900. private _validate;
  81901. /**
  81902. * Serializes the VertexData
  81903. * @returns a serialized object
  81904. */
  81905. serialize(): any;
  81906. /**
  81907. * Extracts the vertexData from a mesh
  81908. * @param mesh the mesh from which to extract the VertexData
  81909. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81910. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81911. * @returns the object VertexData associated to the passed mesh
  81912. */
  81913. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81914. /**
  81915. * Extracts the vertexData from the geometry
  81916. * @param geometry the geometry from which to extract the VertexData
  81917. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81918. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81919. * @returns the object VertexData associated to the passed mesh
  81920. */
  81921. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81922. private static _ExtractFrom;
  81923. /**
  81924. * Creates the VertexData for a Ribbon
  81925. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81926. * * pathArray array of paths, each of which an array of successive Vector3
  81927. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81928. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81929. * * 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
  81930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81931. * * 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)
  81932. * * 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)
  81933. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81934. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81935. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81936. * @returns the VertexData of the ribbon
  81937. */
  81938. static CreateRibbon(options: {
  81939. pathArray: Vector3[][];
  81940. closeArray?: boolean;
  81941. closePath?: boolean;
  81942. offset?: number;
  81943. sideOrientation?: number;
  81944. frontUVs?: Vector4;
  81945. backUVs?: Vector4;
  81946. invertUV?: boolean;
  81947. uvs?: Vector2[];
  81948. colors?: Color4[];
  81949. }): VertexData;
  81950. /**
  81951. * Creates the VertexData for a box
  81952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81953. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81954. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81955. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81956. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81957. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81958. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81960. * * 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)
  81961. * * 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)
  81962. * @returns the VertexData of the box
  81963. */
  81964. static CreateBox(options: {
  81965. size?: number;
  81966. width?: number;
  81967. height?: number;
  81968. depth?: number;
  81969. faceUV?: Vector4[];
  81970. faceColors?: Color4[];
  81971. sideOrientation?: number;
  81972. frontUVs?: Vector4;
  81973. backUVs?: Vector4;
  81974. }): VertexData;
  81975. /**
  81976. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81977. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81978. * * segments sets the number of horizontal strips optional, default 32
  81979. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81980. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81981. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81982. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81983. * * 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
  81984. * * 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
  81985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81986. * * 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)
  81987. * * 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)
  81988. * @returns the VertexData of the ellipsoid
  81989. */
  81990. static CreateSphere(options: {
  81991. segments?: number;
  81992. diameter?: number;
  81993. diameterX?: number;
  81994. diameterY?: number;
  81995. diameterZ?: number;
  81996. arc?: number;
  81997. slice?: number;
  81998. sideOrientation?: number;
  81999. frontUVs?: Vector4;
  82000. backUVs?: Vector4;
  82001. }): VertexData;
  82002. /**
  82003. * Creates the VertexData for a cylinder, cone or prism
  82004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82005. * * height sets the height (y direction) of the cylinder, optional, default 2
  82006. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82007. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82008. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82009. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82010. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82011. * * 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
  82012. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82013. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82014. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82015. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82017. * * 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)
  82018. * * 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)
  82019. * @returns the VertexData of the cylinder, cone or prism
  82020. */
  82021. static CreateCylinder(options: {
  82022. height?: number;
  82023. diameterTop?: number;
  82024. diameterBottom?: number;
  82025. diameter?: number;
  82026. tessellation?: number;
  82027. subdivisions?: number;
  82028. arc?: number;
  82029. faceColors?: Color4[];
  82030. faceUV?: Vector4[];
  82031. hasRings?: boolean;
  82032. enclose?: boolean;
  82033. sideOrientation?: number;
  82034. frontUVs?: Vector4;
  82035. backUVs?: Vector4;
  82036. }): VertexData;
  82037. /**
  82038. * Creates the VertexData for a torus
  82039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82040. * * diameter the diameter of the torus, optional default 1
  82041. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82042. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82044. * * 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)
  82045. * * 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)
  82046. * @returns the VertexData of the torus
  82047. */
  82048. static CreateTorus(options: {
  82049. diameter?: number;
  82050. thickness?: number;
  82051. tessellation?: number;
  82052. sideOrientation?: number;
  82053. frontUVs?: Vector4;
  82054. backUVs?: Vector4;
  82055. }): VertexData;
  82056. /**
  82057. * Creates the VertexData of the LineSystem
  82058. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82059. * - lines an array of lines, each line being an array of successive Vector3
  82060. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82061. * @returns the VertexData of the LineSystem
  82062. */
  82063. static CreateLineSystem(options: {
  82064. lines: Vector3[][];
  82065. colors?: Nullable<Color4[][]>;
  82066. }): VertexData;
  82067. /**
  82068. * Create the VertexData for a DashedLines
  82069. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82070. * - points an array successive Vector3
  82071. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82072. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82073. * - dashNb the intended total number of dashes, optional, default 200
  82074. * @returns the VertexData for the DashedLines
  82075. */
  82076. static CreateDashedLines(options: {
  82077. points: Vector3[];
  82078. dashSize?: number;
  82079. gapSize?: number;
  82080. dashNb?: number;
  82081. }): VertexData;
  82082. /**
  82083. * Creates the VertexData for a Ground
  82084. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82085. * - width the width (x direction) of the ground, optional, default 1
  82086. * - height the height (z direction) of the ground, optional, default 1
  82087. * - subdivisions the number of subdivisions per side, optional, default 1
  82088. * @returns the VertexData of the Ground
  82089. */
  82090. static CreateGround(options: {
  82091. width?: number;
  82092. height?: number;
  82093. subdivisions?: number;
  82094. subdivisionsX?: number;
  82095. subdivisionsY?: number;
  82096. }): VertexData;
  82097. /**
  82098. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82099. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82100. * * xmin the ground minimum X coordinate, optional, default -1
  82101. * * zmin the ground minimum Z coordinate, optional, default -1
  82102. * * xmax the ground maximum X coordinate, optional, default 1
  82103. * * zmax the ground maximum Z coordinate, optional, default 1
  82104. * * 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}
  82105. * * 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}
  82106. * @returns the VertexData of the TiledGround
  82107. */
  82108. static CreateTiledGround(options: {
  82109. xmin: number;
  82110. zmin: number;
  82111. xmax: number;
  82112. zmax: number;
  82113. subdivisions?: {
  82114. w: number;
  82115. h: number;
  82116. };
  82117. precision?: {
  82118. w: number;
  82119. h: number;
  82120. };
  82121. }): VertexData;
  82122. /**
  82123. * Creates the VertexData of the Ground designed from a heightmap
  82124. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82125. * * width the width (x direction) of the ground
  82126. * * height the height (z direction) of the ground
  82127. * * subdivisions the number of subdivisions per side
  82128. * * minHeight the minimum altitude on the ground, optional, default 0
  82129. * * maxHeight the maximum altitude on the ground, optional default 1
  82130. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82131. * * buffer the array holding the image color data
  82132. * * bufferWidth the width of image
  82133. * * bufferHeight the height of image
  82134. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82135. * @returns the VertexData of the Ground designed from a heightmap
  82136. */
  82137. static CreateGroundFromHeightMap(options: {
  82138. width: number;
  82139. height: number;
  82140. subdivisions: number;
  82141. minHeight: number;
  82142. maxHeight: number;
  82143. colorFilter: Color3;
  82144. buffer: Uint8Array;
  82145. bufferWidth: number;
  82146. bufferHeight: number;
  82147. alphaFilter: number;
  82148. }): VertexData;
  82149. /**
  82150. * Creates the VertexData for a Plane
  82151. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82152. * * size sets the width and height of the plane to the value of size, optional default 1
  82153. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82154. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82156. * * 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)
  82157. * * 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)
  82158. * @returns the VertexData of the box
  82159. */
  82160. static CreatePlane(options: {
  82161. size?: number;
  82162. width?: number;
  82163. height?: number;
  82164. sideOrientation?: number;
  82165. frontUVs?: Vector4;
  82166. backUVs?: Vector4;
  82167. }): VertexData;
  82168. /**
  82169. * Creates the VertexData of the Disc or regular Polygon
  82170. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82171. * * radius the radius of the disc, optional default 0.5
  82172. * * tessellation the number of polygon sides, optional, default 64
  82173. * * 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
  82174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82175. * * 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)
  82176. * * 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)
  82177. * @returns the VertexData of the box
  82178. */
  82179. static CreateDisc(options: {
  82180. radius?: number;
  82181. tessellation?: number;
  82182. arc?: number;
  82183. sideOrientation?: number;
  82184. frontUVs?: Vector4;
  82185. backUVs?: Vector4;
  82186. }): VertexData;
  82187. /**
  82188. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82189. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82190. * @param polygon a mesh built from polygonTriangulation.build()
  82191. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82192. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82193. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82194. * @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)
  82195. * @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)
  82196. * @returns the VertexData of the Polygon
  82197. */
  82198. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82199. /**
  82200. * Creates the VertexData of the IcoSphere
  82201. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82202. * * radius the radius of the IcoSphere, optional default 1
  82203. * * radiusX allows stretching in the x direction, optional, default radius
  82204. * * radiusY allows stretching in the y direction, optional, default radius
  82205. * * radiusZ allows stretching in the z direction, optional, default radius
  82206. * * flat when true creates a flat shaded mesh, optional, default true
  82207. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82208. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82209. * * 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)
  82210. * * 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)
  82211. * @returns the VertexData of the IcoSphere
  82212. */
  82213. static CreateIcoSphere(options: {
  82214. radius?: number;
  82215. radiusX?: number;
  82216. radiusY?: number;
  82217. radiusZ?: number;
  82218. flat?: boolean;
  82219. subdivisions?: number;
  82220. sideOrientation?: number;
  82221. frontUVs?: Vector4;
  82222. backUVs?: Vector4;
  82223. }): VertexData;
  82224. /**
  82225. * Creates the VertexData for a Polyhedron
  82226. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82227. * * type provided types are:
  82228. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82229. * * 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)
  82230. * * size the size of the IcoSphere, optional default 1
  82231. * * sizeX allows stretching in the x direction, optional, default size
  82232. * * sizeY allows stretching in the y direction, optional, default size
  82233. * * sizeZ allows stretching in the z direction, optional, default size
  82234. * * 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
  82235. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82236. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82237. * * flat when true creates a flat shaded mesh, optional, default true
  82238. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82239. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82240. * * 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)
  82241. * * 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)
  82242. * @returns the VertexData of the Polyhedron
  82243. */
  82244. static CreatePolyhedron(options: {
  82245. type?: number;
  82246. size?: number;
  82247. sizeX?: number;
  82248. sizeY?: number;
  82249. sizeZ?: number;
  82250. custom?: any;
  82251. faceUV?: Vector4[];
  82252. faceColors?: Color4[];
  82253. flat?: boolean;
  82254. sideOrientation?: number;
  82255. frontUVs?: Vector4;
  82256. backUVs?: Vector4;
  82257. }): VertexData;
  82258. /**
  82259. * Creates the VertexData for a TorusKnot
  82260. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82261. * * radius the radius of the torus knot, optional, default 2
  82262. * * tube the thickness of the tube, optional, default 0.5
  82263. * * radialSegments the number of sides on each tube segments, optional, default 32
  82264. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82265. * * p the number of windings around the z axis, optional, default 2
  82266. * * q the number of windings around the x axis, optional, default 3
  82267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82268. * * 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)
  82269. * * 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)
  82270. * @returns the VertexData of the Torus Knot
  82271. */
  82272. static CreateTorusKnot(options: {
  82273. radius?: number;
  82274. tube?: number;
  82275. radialSegments?: number;
  82276. tubularSegments?: number;
  82277. p?: number;
  82278. q?: number;
  82279. sideOrientation?: number;
  82280. frontUVs?: Vector4;
  82281. backUVs?: Vector4;
  82282. }): VertexData;
  82283. /**
  82284. * Compute normals for given positions and indices
  82285. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82286. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82287. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82288. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82289. * * facetNormals : optional array of facet normals (vector3)
  82290. * * facetPositions : optional array of facet positions (vector3)
  82291. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82292. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82293. * * bInfo : optional bounding info, required for facetPartitioning computation
  82294. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82295. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82296. * * useRightHandedSystem: optional boolean to for right handed system computation
  82297. * * depthSort : optional boolean to enable the facet depth sort computation
  82298. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82299. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82300. */
  82301. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82302. facetNormals?: any;
  82303. facetPositions?: any;
  82304. facetPartitioning?: any;
  82305. ratio?: number;
  82306. bInfo?: any;
  82307. bbSize?: Vector3;
  82308. subDiv?: any;
  82309. useRightHandedSystem?: boolean;
  82310. depthSort?: boolean;
  82311. distanceTo?: Vector3;
  82312. depthSortedFacets?: any;
  82313. }): void;
  82314. /** @hidden */
  82315. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82316. /**
  82317. * Applies VertexData created from the imported parameters to the geometry
  82318. * @param parsedVertexData the parsed data from an imported file
  82319. * @param geometry the geometry to apply the VertexData to
  82320. */
  82321. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82322. }
  82323. }
  82324. declare module BABYLON {
  82325. /**
  82326. * Class containing static functions to help procedurally build meshes
  82327. */
  82328. export class DiscBuilder {
  82329. /**
  82330. * Creates a plane polygonal mesh. By default, this is a disc
  82331. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82332. * * 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
  82333. * * 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
  82334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82337. * @param name defines the name of the mesh
  82338. * @param options defines the options used to create the mesh
  82339. * @param scene defines the hosting scene
  82340. * @returns the plane polygonal mesh
  82341. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82342. */
  82343. static CreateDisc(name: string, options: {
  82344. radius?: number;
  82345. tessellation?: number;
  82346. arc?: number;
  82347. updatable?: boolean;
  82348. sideOrientation?: number;
  82349. frontUVs?: Vector4;
  82350. backUVs?: Vector4;
  82351. }, scene?: Nullable<Scene>): Mesh;
  82352. }
  82353. }
  82354. declare module BABYLON {
  82355. /**
  82356. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82357. *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.
  82358. * The SPS is also a particle system. It provides some methods to manage the particles.
  82359. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82360. *
  82361. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82362. */
  82363. export class SolidParticleSystem implements IDisposable {
  82364. /**
  82365. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82366. * Example : var p = SPS.particles[i];
  82367. */
  82368. particles: SolidParticle[];
  82369. /**
  82370. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82371. */
  82372. nbParticles: number;
  82373. /**
  82374. * If the particles must ever face the camera (default false). Useful for planar particles.
  82375. */
  82376. billboard: boolean;
  82377. /**
  82378. * Recompute normals when adding a shape
  82379. */
  82380. recomputeNormals: boolean;
  82381. /**
  82382. * This a counter ofr your own usage. It's not set by any SPS functions.
  82383. */
  82384. counter: number;
  82385. /**
  82386. * The SPS name. This name is also given to the underlying mesh.
  82387. */
  82388. name: string;
  82389. /**
  82390. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82391. */
  82392. mesh: Mesh;
  82393. /**
  82394. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82395. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82396. */
  82397. vars: any;
  82398. /**
  82399. * This array is populated when the SPS is set as 'pickable'.
  82400. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82401. * Each element of this array is an object `{idx: int, faceId: int}`.
  82402. * `idx` is the picked particle index in the `SPS.particles` array
  82403. * `faceId` is the picked face index counted within this particle.
  82404. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82405. */
  82406. pickedParticles: {
  82407. idx: number;
  82408. faceId: number;
  82409. }[];
  82410. /**
  82411. * This array is populated when `enableDepthSort` is set to true.
  82412. * Each element of this array is an instance of the class DepthSortedParticle.
  82413. */
  82414. depthSortedParticles: DepthSortedParticle[];
  82415. /**
  82416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82417. * @hidden
  82418. */
  82419. _bSphereOnly: boolean;
  82420. /**
  82421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82422. * @hidden
  82423. */
  82424. _bSphereRadiusFactor: number;
  82425. private _scene;
  82426. private _positions;
  82427. private _indices;
  82428. private _normals;
  82429. private _colors;
  82430. private _uvs;
  82431. private _indices32;
  82432. private _positions32;
  82433. private _normals32;
  82434. private _fixedNormal32;
  82435. private _colors32;
  82436. private _uvs32;
  82437. private _index;
  82438. private _updatable;
  82439. private _pickable;
  82440. private _isVisibilityBoxLocked;
  82441. private _alwaysVisible;
  82442. private _depthSort;
  82443. private _shapeCounter;
  82444. private _copy;
  82445. private _color;
  82446. private _computeParticleColor;
  82447. private _computeParticleTexture;
  82448. private _computeParticleRotation;
  82449. private _computeParticleVertex;
  82450. private _computeBoundingBox;
  82451. private _depthSortParticles;
  82452. private _camera;
  82453. private _mustUnrotateFixedNormals;
  82454. private _particlesIntersect;
  82455. private _needs32Bits;
  82456. /**
  82457. * Creates a SPS (Solid Particle System) object.
  82458. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82459. * @param scene (Scene) is the scene in which the SPS is added.
  82460. * @param options defines the options of the sps e.g.
  82461. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82462. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82463. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82464. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82465. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82466. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82467. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82468. */
  82469. constructor(name: string, scene: Scene, options?: {
  82470. updatable?: boolean;
  82471. isPickable?: boolean;
  82472. enableDepthSort?: boolean;
  82473. particleIntersection?: boolean;
  82474. boundingSphereOnly?: boolean;
  82475. bSphereRadiusFactor?: number;
  82476. });
  82477. /**
  82478. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82479. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82480. * @returns the created mesh
  82481. */
  82482. buildMesh(): Mesh;
  82483. /**
  82484. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82485. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82486. * Thus the particles generated from `digest()` have their property `position` set yet.
  82487. * @param mesh ( Mesh ) is the mesh to be digested
  82488. * @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
  82489. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82490. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82491. * @returns the current SPS
  82492. */
  82493. digest(mesh: Mesh, options?: {
  82494. facetNb?: number;
  82495. number?: number;
  82496. delta?: number;
  82497. }): SolidParticleSystem;
  82498. private _unrotateFixedNormals;
  82499. private _resetCopy;
  82500. private _meshBuilder;
  82501. private _posToShape;
  82502. private _uvsToShapeUV;
  82503. private _addParticle;
  82504. /**
  82505. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82506. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82507. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82508. * @param nb (positive integer) the number of particles to be created from this model
  82509. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82510. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82511. * @returns the number of shapes in the system
  82512. */
  82513. addShape(mesh: Mesh, nb: number, options?: {
  82514. positionFunction?: any;
  82515. vertexFunction?: any;
  82516. }): number;
  82517. private _rebuildParticle;
  82518. /**
  82519. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82520. * @returns the SPS.
  82521. */
  82522. rebuildMesh(): SolidParticleSystem;
  82523. /**
  82524. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82525. * This method calls `updateParticle()` for each particle of the SPS.
  82526. * For an animated SPS, it is usually called within the render loop.
  82527. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82528. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82529. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82530. * @returns the SPS.
  82531. */
  82532. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82533. /**
  82534. * Disposes the SPS.
  82535. */
  82536. dispose(): void;
  82537. /**
  82538. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82539. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82540. * @returns the SPS.
  82541. */
  82542. refreshVisibleSize(): SolidParticleSystem;
  82543. /**
  82544. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82545. * @param size the size (float) of the visibility box
  82546. * note : this doesn't lock the SPS mesh bounding box.
  82547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82548. */
  82549. setVisibilityBox(size: number): void;
  82550. /**
  82551. * Gets whether the SPS as always visible or not
  82552. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82553. */
  82554. /**
  82555. * Sets the SPS as always visible or not
  82556. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82557. */
  82558. isAlwaysVisible: boolean;
  82559. /**
  82560. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82562. */
  82563. /**
  82564. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82565. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82566. */
  82567. isVisibilityBoxLocked: boolean;
  82568. /**
  82569. * Tells to `setParticles()` to compute the particle rotations or not.
  82570. * Default value : true. The SPS is faster when it's set to false.
  82571. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82572. */
  82573. /**
  82574. * Gets if `setParticles()` computes the particle rotations or not.
  82575. * Default value : true. The SPS is faster when it's set to false.
  82576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82577. */
  82578. computeParticleRotation: boolean;
  82579. /**
  82580. * Tells to `setParticles()` to compute the particle colors or not.
  82581. * Default value : true. The SPS is faster when it's set to false.
  82582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82583. */
  82584. /**
  82585. * Gets if `setParticles()` computes the particle colors or not.
  82586. * Default value : true. The SPS is faster when it's set to false.
  82587. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82588. */
  82589. computeParticleColor: boolean;
  82590. /**
  82591. * Gets if `setParticles()` computes the particle textures or not.
  82592. * Default value : true. The SPS is faster when it's set to false.
  82593. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82594. */
  82595. computeParticleTexture: boolean;
  82596. /**
  82597. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82598. * Default value : false. The SPS is faster when it's set to false.
  82599. * Note : the particle custom vertex positions aren't stored values.
  82600. */
  82601. /**
  82602. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82603. * Default value : false. The SPS is faster when it's set to false.
  82604. * Note : the particle custom vertex positions aren't stored values.
  82605. */
  82606. computeParticleVertex: boolean;
  82607. /**
  82608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82609. */
  82610. /**
  82611. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82612. */
  82613. computeBoundingBox: boolean;
  82614. /**
  82615. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82616. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82617. * Default : `true`
  82618. */
  82619. /**
  82620. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82622. * Default : `true`
  82623. */
  82624. depthSortParticles: boolean;
  82625. /**
  82626. * This function does nothing. It may be overwritten to set all the particle first values.
  82627. * The SPS doesn't call this function, you may have to call it by your own.
  82628. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82629. */
  82630. initParticles(): void;
  82631. /**
  82632. * This function does nothing. It may be overwritten to recycle a particle.
  82633. * The SPS doesn't call this function, you may have to call it by your own.
  82634. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82635. * @param particle The particle to recycle
  82636. * @returns the recycled particle
  82637. */
  82638. recycleParticle(particle: SolidParticle): SolidParticle;
  82639. /**
  82640. * Updates a particle : this function should be overwritten by the user.
  82641. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82643. * @example : just set a particle position or velocity and recycle conditions
  82644. * @param particle The particle to update
  82645. * @returns the updated particle
  82646. */
  82647. updateParticle(particle: SolidParticle): SolidParticle;
  82648. /**
  82649. * Updates a vertex of a particle : it can be overwritten by the user.
  82650. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82651. * @param particle the current particle
  82652. * @param vertex the current index of the current particle
  82653. * @param pt the index of the current vertex in the particle shape
  82654. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82655. * @example : just set a vertex particle position
  82656. * @returns the updated vertex
  82657. */
  82658. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82659. /**
  82660. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82661. * This does nothing and may be overwritten by the user.
  82662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82664. * @param update the boolean update value actually passed to setParticles()
  82665. */
  82666. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82667. /**
  82668. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82669. * This will be passed three parameters.
  82670. * This does nothing and may be overwritten by the user.
  82671. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82673. * @param update the boolean update value actually passed to setParticles()
  82674. */
  82675. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82676. }
  82677. }
  82678. declare module BABYLON {
  82679. /**
  82680. * Represents one particle of a solid particle system.
  82681. */
  82682. export class SolidParticle {
  82683. /**
  82684. * particle global index
  82685. */
  82686. idx: number;
  82687. /**
  82688. * The color of the particle
  82689. */
  82690. color: Nullable<Color4>;
  82691. /**
  82692. * The world space position of the particle.
  82693. */
  82694. position: Vector3;
  82695. /**
  82696. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82697. */
  82698. rotation: Vector3;
  82699. /**
  82700. * The world space rotation quaternion of the particle.
  82701. */
  82702. rotationQuaternion: Nullable<Quaternion>;
  82703. /**
  82704. * The scaling of the particle.
  82705. */
  82706. scaling: Vector3;
  82707. /**
  82708. * The uvs of the particle.
  82709. */
  82710. uvs: Vector4;
  82711. /**
  82712. * The current speed of the particle.
  82713. */
  82714. velocity: Vector3;
  82715. /**
  82716. * The pivot point in the particle local space.
  82717. */
  82718. pivot: Vector3;
  82719. /**
  82720. * Must the particle be translated from its pivot point in its local space ?
  82721. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82722. * Default : false
  82723. */
  82724. translateFromPivot: boolean;
  82725. /**
  82726. * Is the particle active or not ?
  82727. */
  82728. alive: boolean;
  82729. /**
  82730. * Is the particle visible or not ?
  82731. */
  82732. isVisible: boolean;
  82733. /**
  82734. * Index of this particle in the global "positions" array (Internal use)
  82735. * @hidden
  82736. */
  82737. _pos: number;
  82738. /**
  82739. * @hidden Index of this particle in the global "indices" array (Internal use)
  82740. */
  82741. _ind: number;
  82742. /**
  82743. * @hidden ModelShape of this particle (Internal use)
  82744. */
  82745. _model: ModelShape;
  82746. /**
  82747. * ModelShape id of this particle
  82748. */
  82749. shapeId: number;
  82750. /**
  82751. * Index of the particle in its shape id (Internal use)
  82752. */
  82753. idxInShape: number;
  82754. /**
  82755. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  82756. */
  82757. _modelBoundingInfo: BoundingInfo;
  82758. /**
  82759. * @hidden Particle BoundingInfo object (Internal use)
  82760. */
  82761. _boundingInfo: BoundingInfo;
  82762. /**
  82763. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  82764. */
  82765. _sps: SolidParticleSystem;
  82766. /**
  82767. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82768. */
  82769. _stillInvisible: boolean;
  82770. /**
  82771. * @hidden Last computed particle rotation matrix
  82772. */
  82773. _rotationMatrix: number[];
  82774. /**
  82775. * Parent particle Id, if any.
  82776. * Default null.
  82777. */
  82778. parentId: Nullable<number>;
  82779. /**
  82780. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82781. * The possible values are :
  82782. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82783. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82784. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82785. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82786. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82787. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82788. * */
  82789. cullingStrategy: number;
  82790. /**
  82791. * @hidden Internal global position in the SPS.
  82792. */
  82793. _globalPosition: Vector3;
  82794. /**
  82795. * Creates a Solid Particle object.
  82796. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82797. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82798. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82799. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82800. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82801. * @param shapeId (integer) is the model shape identifier in the SPS.
  82802. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82803. * @param sps defines the sps it is associated to
  82804. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82805. */
  82806. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82807. /**
  82808. * Legacy support, changed scale to scaling
  82809. */
  82810. /**
  82811. * Legacy support, changed scale to scaling
  82812. */
  82813. scale: Vector3;
  82814. /**
  82815. * Legacy support, changed quaternion to rotationQuaternion
  82816. */
  82817. /**
  82818. * Legacy support, changed quaternion to rotationQuaternion
  82819. */
  82820. quaternion: Nullable<Quaternion>;
  82821. /**
  82822. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82823. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82824. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82825. * @returns true if it intersects
  82826. */
  82827. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82828. /**
  82829. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82830. * A particle is in the frustum if its bounding box intersects the frustum
  82831. * @param frustumPlanes defines the frustum to test
  82832. * @returns true if the particle is in the frustum planes
  82833. */
  82834. isInFrustum(frustumPlanes: Plane[]): boolean;
  82835. /**
  82836. * get the rotation matrix of the particle
  82837. * @hidden
  82838. */
  82839. getRotationMatrix(m: Matrix): void;
  82840. }
  82841. /**
  82842. * Represents the shape of the model used by one particle of a solid particle system.
  82843. * SPS internal tool, don't use it manually.
  82844. */
  82845. export class ModelShape {
  82846. /**
  82847. * The shape id
  82848. * @hidden
  82849. */
  82850. shapeID: number;
  82851. /**
  82852. * flat array of model positions (internal use)
  82853. * @hidden
  82854. */
  82855. _shape: Vector3[];
  82856. /**
  82857. * flat array of model UVs (internal use)
  82858. * @hidden
  82859. */
  82860. _shapeUV: number[];
  82861. /**
  82862. * length of the shape in the model indices array (internal use)
  82863. * @hidden
  82864. */
  82865. _indicesLength: number;
  82866. /**
  82867. * Custom position function (internal use)
  82868. * @hidden
  82869. */
  82870. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82871. /**
  82872. * Custom vertex function (internal use)
  82873. * @hidden
  82874. */
  82875. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82876. /**
  82877. * 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.
  82878. * SPS internal tool, don't use it manually.
  82879. * @hidden
  82880. */
  82881. 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>);
  82882. }
  82883. /**
  82884. * Represents a Depth Sorted Particle in the solid particle system.
  82885. */
  82886. export class DepthSortedParticle {
  82887. /**
  82888. * Index of the particle in the "indices" array
  82889. */
  82890. ind: number;
  82891. /**
  82892. * Length of the particle shape in the "indices" array
  82893. */
  82894. indicesLength: number;
  82895. /**
  82896. * Squared distance from the particle to the camera
  82897. */
  82898. sqDistance: number;
  82899. }
  82900. }
  82901. declare module BABYLON {
  82902. /**
  82903. * Class used to store all common mesh properties
  82904. */
  82905. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82906. /** No occlusion */
  82907. static OCCLUSION_TYPE_NONE: number;
  82908. /** Occlusion set to optimisitic */
  82909. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82910. /** Occlusion set to strict */
  82911. static OCCLUSION_TYPE_STRICT: number;
  82912. /** Use an accurante occlusion algorithm */
  82913. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82914. /** Use a conservative occlusion algorithm */
  82915. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82916. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82917. * Test order :
  82918. * Is the bounding sphere outside the frustum ?
  82919. * If not, are the bounding box vertices outside the frustum ?
  82920. * It not, then the cullable object is in the frustum.
  82921. */
  82922. static readonly CULLINGSTRATEGY_STANDARD: number;
  82923. /** Culling strategy : Bounding Sphere Only.
  82924. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82925. * It's also less accurate than the standard because some not visible objects can still be selected.
  82926. * Test : is the bounding sphere outside the frustum ?
  82927. * If not, then the cullable object is in the frustum.
  82928. */
  82929. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82930. /** Culling strategy : Optimistic Inclusion.
  82931. * This in an inclusion test first, then the standard exclusion test.
  82932. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82933. * 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.
  82934. * Anyway, it's as accurate as the standard strategy.
  82935. * Test :
  82936. * Is the cullable object bounding sphere center in the frustum ?
  82937. * If not, apply the default culling strategy.
  82938. */
  82939. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82940. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82941. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82942. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82943. * 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.
  82944. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82945. * Test :
  82946. * Is the cullable object bounding sphere center in the frustum ?
  82947. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82948. */
  82949. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82950. /**
  82951. * No billboard
  82952. */
  82953. static readonly BILLBOARDMODE_NONE: number;
  82954. /** Billboard on X axis */
  82955. static readonly BILLBOARDMODE_X: number;
  82956. /** Billboard on Y axis */
  82957. static readonly BILLBOARDMODE_Y: number;
  82958. /** Billboard on Z axis */
  82959. static readonly BILLBOARDMODE_Z: number;
  82960. /** Billboard on all axes */
  82961. static readonly BILLBOARDMODE_ALL: number;
  82962. private _facetData;
  82963. /**
  82964. * The culling strategy to use to check whether the mesh must be rendered or not.
  82965. * This value can be changed at any time and will be used on the next render mesh selection.
  82966. * The possible values are :
  82967. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82968. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82970. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82971. * Please read each static variable documentation to get details about the culling process.
  82972. * */
  82973. cullingStrategy: number;
  82974. /**
  82975. * Gets the number of facets in the mesh
  82976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82977. */
  82978. readonly facetNb: number;
  82979. /**
  82980. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82982. */
  82983. partitioningSubdivisions: number;
  82984. /**
  82985. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82986. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82988. */
  82989. partitioningBBoxRatio: number;
  82990. /**
  82991. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82992. * Works only for updatable meshes.
  82993. * Doesn't work with multi-materials
  82994. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82995. */
  82996. mustDepthSortFacets: boolean;
  82997. /**
  82998. * The location (Vector3) where the facet depth sort must be computed from.
  82999. * By default, the active camera position.
  83000. * Used only when facet depth sort is enabled
  83001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83002. */
  83003. facetDepthSortFrom: Vector3;
  83004. /**
  83005. * gets a boolean indicating if facetData is enabled
  83006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83007. */
  83008. readonly isFacetDataEnabled: boolean;
  83009. /** @hidden */
  83010. _updateNonUniformScalingState(value: boolean): boolean;
  83011. /**
  83012. * An event triggered when this mesh collides with another one
  83013. */
  83014. onCollideObservable: Observable<AbstractMesh>;
  83015. private _onCollideObserver;
  83016. /** Set a function to call when this mesh collides with another one */
  83017. onCollide: () => void;
  83018. /**
  83019. * An event triggered when the collision's position changes
  83020. */
  83021. onCollisionPositionChangeObservable: Observable<Vector3>;
  83022. private _onCollisionPositionChangeObserver;
  83023. /** Set a function to call when the collision's position changes */
  83024. onCollisionPositionChange: () => void;
  83025. /**
  83026. * An event triggered when material is changed
  83027. */
  83028. onMaterialChangedObservable: Observable<AbstractMesh>;
  83029. /**
  83030. * Gets or sets the orientation for POV movement & rotation
  83031. */
  83032. definedFacingForward: boolean;
  83033. /** @hidden */
  83034. _occlusionQuery: Nullable<WebGLQuery>;
  83035. private _visibility;
  83036. /**
  83037. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83038. */
  83039. /**
  83040. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83041. */
  83042. visibility: number;
  83043. /** Gets or sets the alpha index used to sort transparent meshes
  83044. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83045. */
  83046. alphaIndex: number;
  83047. /**
  83048. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83049. */
  83050. isVisible: boolean;
  83051. /**
  83052. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83053. */
  83054. isPickable: boolean;
  83055. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83056. showSubMeshesBoundingBox: boolean;
  83057. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83059. */
  83060. isBlocker: boolean;
  83061. /**
  83062. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83063. */
  83064. enablePointerMoveEvents: boolean;
  83065. /**
  83066. * Specifies the rendering group id for this mesh (0 by default)
  83067. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83068. */
  83069. renderingGroupId: number;
  83070. private _material;
  83071. /** Gets or sets current material */
  83072. material: Nullable<Material>;
  83073. private _receiveShadows;
  83074. /**
  83075. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83076. * @see http://doc.babylonjs.com/babylon101/shadows
  83077. */
  83078. receiveShadows: boolean;
  83079. /** Defines color to use when rendering outline */
  83080. outlineColor: Color3;
  83081. /** Define width to use when rendering outline */
  83082. outlineWidth: number;
  83083. /** Defines color to use when rendering overlay */
  83084. overlayColor: Color3;
  83085. /** Defines alpha to use when rendering overlay */
  83086. overlayAlpha: number;
  83087. private _hasVertexAlpha;
  83088. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83089. hasVertexAlpha: boolean;
  83090. private _useVertexColors;
  83091. /** 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) */
  83092. useVertexColors: boolean;
  83093. private _computeBonesUsingShaders;
  83094. /**
  83095. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83096. */
  83097. computeBonesUsingShaders: boolean;
  83098. private _numBoneInfluencers;
  83099. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83100. numBoneInfluencers: number;
  83101. private _applyFog;
  83102. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83103. applyFog: boolean;
  83104. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83105. useOctreeForRenderingSelection: boolean;
  83106. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83107. useOctreeForPicking: boolean;
  83108. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83109. useOctreeForCollisions: boolean;
  83110. private _layerMask;
  83111. /**
  83112. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83113. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83114. */
  83115. layerMask: number;
  83116. /**
  83117. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83118. */
  83119. alwaysSelectAsActiveMesh: boolean;
  83120. /**
  83121. * Gets or sets the current action manager
  83122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83123. */
  83124. actionManager: Nullable<AbstractActionManager>;
  83125. private _checkCollisions;
  83126. private _collisionMask;
  83127. private _collisionGroup;
  83128. /**
  83129. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83131. */
  83132. ellipsoid: Vector3;
  83133. /**
  83134. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83136. */
  83137. ellipsoidOffset: Vector3;
  83138. private _collider;
  83139. private _oldPositionForCollisions;
  83140. private _diffPositionForCollisions;
  83141. /**
  83142. * Gets or sets a collision mask used to mask collisions (default is -1).
  83143. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83144. */
  83145. collisionMask: number;
  83146. /**
  83147. * Gets or sets the current collision group mask (-1 by default).
  83148. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83149. */
  83150. collisionGroup: number;
  83151. /**
  83152. * Defines edge width used when edgesRenderer is enabled
  83153. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83154. */
  83155. edgesWidth: number;
  83156. /**
  83157. * Defines edge color used when edgesRenderer is enabled
  83158. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83159. */
  83160. edgesColor: Color4;
  83161. /** @hidden */
  83162. _edgesRenderer: Nullable<IEdgesRenderer>;
  83163. /** @hidden */
  83164. _masterMesh: Nullable<AbstractMesh>;
  83165. /** @hidden */
  83166. _boundingInfo: Nullable<BoundingInfo>;
  83167. /** @hidden */
  83168. _renderId: number;
  83169. /**
  83170. * Gets or sets the list of subMeshes
  83171. * @see http://doc.babylonjs.com/how_to/multi_materials
  83172. */
  83173. subMeshes: SubMesh[];
  83174. /** @hidden */
  83175. _intersectionsInProgress: AbstractMesh[];
  83176. /** @hidden */
  83177. _unIndexed: boolean;
  83178. /** @hidden */
  83179. _lightSources: Light[];
  83180. /** @hidden */
  83181. readonly _positions: Nullable<Vector3[]>;
  83182. /** @hidden */
  83183. _waitingActions: any;
  83184. /** @hidden */
  83185. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83186. private _skeleton;
  83187. /** @hidden */
  83188. _bonesTransformMatrices: Nullable<Float32Array>;
  83189. /**
  83190. * Gets or sets a skeleton to apply skining transformations
  83191. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83192. */
  83193. skeleton: Nullable<Skeleton>;
  83194. /**
  83195. * An event triggered when the mesh is rebuilt.
  83196. */
  83197. onRebuildObservable: Observable<AbstractMesh>;
  83198. /**
  83199. * Creates a new AbstractMesh
  83200. * @param name defines the name of the mesh
  83201. * @param scene defines the hosting scene
  83202. */
  83203. constructor(name: string, scene?: Nullable<Scene>);
  83204. /**
  83205. * Returns the string "AbstractMesh"
  83206. * @returns "AbstractMesh"
  83207. */
  83208. getClassName(): string;
  83209. /**
  83210. * Gets a string representation of the current mesh
  83211. * @param fullDetails defines a boolean indicating if full details must be included
  83212. * @returns a string representation of the current mesh
  83213. */
  83214. toString(fullDetails?: boolean): string;
  83215. /** @hidden */
  83216. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83217. /** @hidden */
  83218. _rebuild(): void;
  83219. /** @hidden */
  83220. _resyncLightSources(): void;
  83221. /** @hidden */
  83222. _resyncLighSource(light: Light): void;
  83223. /** @hidden */
  83224. _unBindEffect(): void;
  83225. /** @hidden */
  83226. _removeLightSource(light: Light): void;
  83227. private _markSubMeshesAsDirty;
  83228. /** @hidden */
  83229. _markSubMeshesAsLightDirty(): void;
  83230. /** @hidden */
  83231. _markSubMeshesAsAttributesDirty(): void;
  83232. /** @hidden */
  83233. _markSubMeshesAsMiscDirty(): void;
  83234. /**
  83235. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83236. */
  83237. scaling: Vector3;
  83238. /**
  83239. * Returns true if the mesh is blocked. Implemented by child classes
  83240. */
  83241. readonly isBlocked: boolean;
  83242. /**
  83243. * Returns the mesh itself by default. Implemented by child classes
  83244. * @param camera defines the camera to use to pick the right LOD level
  83245. * @returns the currentAbstractMesh
  83246. */
  83247. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83248. /**
  83249. * Returns 0 by default. Implemented by child classes
  83250. * @returns an integer
  83251. */
  83252. getTotalVertices(): number;
  83253. /**
  83254. * Returns a positive integer : the total number of indices in this mesh geometry.
  83255. * @returns the numner of indices or zero if the mesh has no geometry.
  83256. */
  83257. getTotalIndices(): number;
  83258. /**
  83259. * Returns null by default. Implemented by child classes
  83260. * @returns null
  83261. */
  83262. getIndices(): Nullable<IndicesArray>;
  83263. /**
  83264. * Returns the array of the requested vertex data kind. Implemented by child classes
  83265. * @param kind defines the vertex data kind to use
  83266. * @returns null
  83267. */
  83268. getVerticesData(kind: string): Nullable<FloatArray>;
  83269. /**
  83270. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83271. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83272. * Note that a new underlying VertexBuffer object is created each call.
  83273. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83274. * @param kind defines vertex data kind:
  83275. * * VertexBuffer.PositionKind
  83276. * * VertexBuffer.UVKind
  83277. * * VertexBuffer.UV2Kind
  83278. * * VertexBuffer.UV3Kind
  83279. * * VertexBuffer.UV4Kind
  83280. * * VertexBuffer.UV5Kind
  83281. * * VertexBuffer.UV6Kind
  83282. * * VertexBuffer.ColorKind
  83283. * * VertexBuffer.MatricesIndicesKind
  83284. * * VertexBuffer.MatricesIndicesExtraKind
  83285. * * VertexBuffer.MatricesWeightsKind
  83286. * * VertexBuffer.MatricesWeightsExtraKind
  83287. * @param data defines the data source
  83288. * @param updatable defines if the data must be flagged as updatable (or static)
  83289. * @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
  83290. * @returns the current mesh
  83291. */
  83292. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83293. /**
  83294. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83295. * If the mesh has no geometry, it is simply returned as it is.
  83296. * @param kind defines vertex data kind:
  83297. * * VertexBuffer.PositionKind
  83298. * * VertexBuffer.UVKind
  83299. * * VertexBuffer.UV2Kind
  83300. * * VertexBuffer.UV3Kind
  83301. * * VertexBuffer.UV4Kind
  83302. * * VertexBuffer.UV5Kind
  83303. * * VertexBuffer.UV6Kind
  83304. * * VertexBuffer.ColorKind
  83305. * * VertexBuffer.MatricesIndicesKind
  83306. * * VertexBuffer.MatricesIndicesExtraKind
  83307. * * VertexBuffer.MatricesWeightsKind
  83308. * * VertexBuffer.MatricesWeightsExtraKind
  83309. * @param data defines the data source
  83310. * @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
  83311. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83312. * @returns the current mesh
  83313. */
  83314. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83315. /**
  83316. * Sets the mesh indices,
  83317. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83318. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83319. * @param totalVertices Defines the total number of vertices
  83320. * @returns the current mesh
  83321. */
  83322. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83323. /**
  83324. * Gets a boolean indicating if specific vertex data is present
  83325. * @param kind defines the vertex data kind to use
  83326. * @returns true is data kind is present
  83327. */
  83328. isVerticesDataPresent(kind: string): boolean;
  83329. /**
  83330. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83331. * @returns a BoundingInfo
  83332. */
  83333. getBoundingInfo(): BoundingInfo;
  83334. /**
  83335. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83336. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83337. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83338. * @returns the current mesh
  83339. */
  83340. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83341. /**
  83342. * Overwrite the current bounding info
  83343. * @param boundingInfo defines the new bounding info
  83344. * @returns the current mesh
  83345. */
  83346. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83347. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83348. readonly useBones: boolean;
  83349. /** @hidden */
  83350. _preActivate(): void;
  83351. /** @hidden */
  83352. _preActivateForIntermediateRendering(renderId: number): void;
  83353. /** @hidden */
  83354. _activate(renderId: number): void;
  83355. /**
  83356. * Gets the current world matrix
  83357. * @returns a Matrix
  83358. */
  83359. getWorldMatrix(): Matrix;
  83360. /** @hidden */
  83361. _getWorldMatrixDeterminant(): number;
  83362. /**
  83363. * Perform relative position change from the point of view of behind the front of the mesh.
  83364. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83365. * Supports definition of mesh facing forward or backward
  83366. * @param amountRight defines the distance on the right axis
  83367. * @param amountUp defines the distance on the up axis
  83368. * @param amountForward defines the distance on the forward axis
  83369. * @returns the current mesh
  83370. */
  83371. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83372. /**
  83373. * Calculate relative position change from the point of view of behind the front of the mesh.
  83374. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83375. * Supports definition of mesh facing forward or backward
  83376. * @param amountRight defines the distance on the right axis
  83377. * @param amountUp defines the distance on the up axis
  83378. * @param amountForward defines the distance on the forward axis
  83379. * @returns the new displacement vector
  83380. */
  83381. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83382. /**
  83383. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83384. * Supports definition of mesh facing forward or backward
  83385. * @param flipBack defines the flip
  83386. * @param twirlClockwise defines the twirl
  83387. * @param tiltRight defines the tilt
  83388. * @returns the current mesh
  83389. */
  83390. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83391. /**
  83392. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83393. * Supports definition of mesh facing forward or backward.
  83394. * @param flipBack defines the flip
  83395. * @param twirlClockwise defines the twirl
  83396. * @param tiltRight defines the tilt
  83397. * @returns the new rotation vector
  83398. */
  83399. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83400. /**
  83401. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83402. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83403. * @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
  83404. * @returns the new bounding vectors
  83405. */
  83406. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83407. min: Vector3;
  83408. max: Vector3;
  83409. };
  83410. /**
  83411. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83412. * This means the mesh underlying bounding box and sphere are recomputed.
  83413. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83414. * @returns the current mesh
  83415. */
  83416. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83417. /** @hidden */
  83418. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83419. /** @hidden */
  83420. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83421. /** @hidden */
  83422. _updateBoundingInfo(): AbstractMesh;
  83423. /** @hidden */
  83424. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83425. /** @hidden */
  83426. protected _afterComputeWorldMatrix(): void;
  83427. /** @hidden */
  83428. readonly _effectiveMesh: AbstractMesh;
  83429. /**
  83430. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83431. * A mesh is in the frustum if its bounding box intersects the frustum
  83432. * @param frustumPlanes defines the frustum to test
  83433. * @returns true if the mesh is in the frustum planes
  83434. */
  83435. isInFrustum(frustumPlanes: Plane[]): boolean;
  83436. /**
  83437. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83438. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83439. * @param frustumPlanes defines the frustum to test
  83440. * @returns true if the mesh is completely in the frustum planes
  83441. */
  83442. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83443. /**
  83444. * True if the mesh intersects another mesh or a SolidParticle object
  83445. * @param mesh defines a target mesh or SolidParticle to test
  83446. * @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)
  83447. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83448. * @returns true if there is an intersection
  83449. */
  83450. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83451. /**
  83452. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83453. * @param point defines the point to test
  83454. * @returns true if there is an intersection
  83455. */
  83456. intersectsPoint(point: Vector3): boolean;
  83457. /**
  83458. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83460. */
  83461. checkCollisions: boolean;
  83462. /**
  83463. * Gets Collider object used to compute collisions (not physics)
  83464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83465. */
  83466. readonly collider: Collider;
  83467. /**
  83468. * Move the mesh using collision engine
  83469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83470. * @param displacement defines the requested displacement vector
  83471. * @returns the current mesh
  83472. */
  83473. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83474. private _onCollisionPositionChange;
  83475. /** @hidden */
  83476. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83477. /** @hidden */
  83478. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83479. /** @hidden */
  83480. _checkCollision(collider: Collider): AbstractMesh;
  83481. /** @hidden */
  83482. _generatePointsArray(): boolean;
  83483. /**
  83484. * Checks if the passed Ray intersects with the mesh
  83485. * @param ray defines the ray to use
  83486. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83487. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83488. * @returns the picking info
  83489. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83490. */
  83491. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83492. /**
  83493. * Clones the current mesh
  83494. * @param name defines the mesh name
  83495. * @param newParent defines the new mesh parent
  83496. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83497. * @returns the new mesh
  83498. */
  83499. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83500. /**
  83501. * Disposes all the submeshes of the current meshnp
  83502. * @returns the current mesh
  83503. */
  83504. releaseSubMeshes(): AbstractMesh;
  83505. /**
  83506. * Releases resources associated with this abstract mesh.
  83507. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83508. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83509. */
  83510. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83511. /**
  83512. * Adds the passed mesh as a child to the current mesh
  83513. * @param mesh defines the child mesh
  83514. * @returns the current mesh
  83515. */
  83516. addChild(mesh: AbstractMesh): AbstractMesh;
  83517. /**
  83518. * Removes the passed mesh from the current mesh children list
  83519. * @param mesh defines the child mesh
  83520. * @returns the current mesh
  83521. */
  83522. removeChild(mesh: AbstractMesh): AbstractMesh;
  83523. /** @hidden */
  83524. private _initFacetData;
  83525. /**
  83526. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83527. * This method can be called within the render loop.
  83528. * 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
  83529. * @returns the current mesh
  83530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83531. */
  83532. updateFacetData(): AbstractMesh;
  83533. /**
  83534. * Returns the facetLocalNormals array.
  83535. * The normals are expressed in the mesh local spac
  83536. * @returns an array of Vector3
  83537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83538. */
  83539. getFacetLocalNormals(): Vector3[];
  83540. /**
  83541. * Returns the facetLocalPositions array.
  83542. * The facet positions are expressed in the mesh local space
  83543. * @returns an array of Vector3
  83544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83545. */
  83546. getFacetLocalPositions(): Vector3[];
  83547. /**
  83548. * Returns the facetLocalPartioning array
  83549. * @returns an array of array of numbers
  83550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83551. */
  83552. getFacetLocalPartitioning(): number[][];
  83553. /**
  83554. * Returns the i-th facet position in the world system.
  83555. * This method allocates a new Vector3 per call
  83556. * @param i defines the facet index
  83557. * @returns a new Vector3
  83558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83559. */
  83560. getFacetPosition(i: number): Vector3;
  83561. /**
  83562. * Sets the reference Vector3 with the i-th facet position in the world system
  83563. * @param i defines the facet index
  83564. * @param ref defines the target vector
  83565. * @returns the current mesh
  83566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83567. */
  83568. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83569. /**
  83570. * Returns the i-th facet normal in the world system.
  83571. * This method allocates a new Vector3 per call
  83572. * @param i defines the facet index
  83573. * @returns a new Vector3
  83574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83575. */
  83576. getFacetNormal(i: number): Vector3;
  83577. /**
  83578. * Sets the reference Vector3 with the i-th facet normal in the world system
  83579. * @param i defines the facet index
  83580. * @param ref defines the target vector
  83581. * @returns the current mesh
  83582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83583. */
  83584. getFacetNormalToRef(i: number, ref: Vector3): this;
  83585. /**
  83586. * 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)
  83587. * @param x defines x coordinate
  83588. * @param y defines y coordinate
  83589. * @param z defines z coordinate
  83590. * @returns the array of facet indexes
  83591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83592. */
  83593. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83594. /**
  83595. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83596. * @param projected sets as the (x,y,z) world projection on the facet
  83597. * @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
  83598. * @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
  83599. * @param x defines x coordinate
  83600. * @param y defines y coordinate
  83601. * @param z defines z coordinate
  83602. * @returns the face index if found (or null instead)
  83603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83604. */
  83605. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83606. /**
  83607. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83608. * @param projected sets as the (x,y,z) local projection on the facet
  83609. * @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
  83610. * @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
  83611. * @param x defines x coordinate
  83612. * @param y defines y coordinate
  83613. * @param z defines z coordinate
  83614. * @returns the face index if found (or null instead)
  83615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83616. */
  83617. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83618. /**
  83619. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83620. * @returns the parameters
  83621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83622. */
  83623. getFacetDataParameters(): any;
  83624. /**
  83625. * Disables the feature FacetData and frees the related memory
  83626. * @returns the current mesh
  83627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83628. */
  83629. disableFacetData(): AbstractMesh;
  83630. /**
  83631. * Updates the AbstractMesh indices array
  83632. * @param indices defines the data source
  83633. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83634. * @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)
  83635. * @returns the current mesh
  83636. */
  83637. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83638. /**
  83639. * Creates new normals data for the mesh
  83640. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83641. * @returns the current mesh
  83642. */
  83643. createNormals(updatable: boolean): AbstractMesh;
  83644. /**
  83645. * Align the mesh with a normal
  83646. * @param normal defines the normal to use
  83647. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83648. * @returns the current mesh
  83649. */
  83650. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83651. /** @hidden */
  83652. _checkOcclusionQuery(): boolean;
  83653. }
  83654. }
  83655. declare module BABYLON {
  83656. /**
  83657. * Interface used to define ActionEvent
  83658. */
  83659. export interface IActionEvent {
  83660. /** The mesh or sprite that triggered the action */
  83661. source: any;
  83662. /** The X mouse cursor position at the time of the event */
  83663. pointerX: number;
  83664. /** The Y mouse cursor position at the time of the event */
  83665. pointerY: number;
  83666. /** The mesh that is currently pointed at (can be null) */
  83667. meshUnderPointer: Nullable<AbstractMesh>;
  83668. /** the original (browser) event that triggered the ActionEvent */
  83669. sourceEvent?: any;
  83670. /** additional data for the event */
  83671. additionalData?: any;
  83672. }
  83673. /**
  83674. * ActionEvent is the event being sent when an action is triggered.
  83675. */
  83676. export class ActionEvent implements IActionEvent {
  83677. /** The mesh or sprite that triggered the action */
  83678. source: any;
  83679. /** The X mouse cursor position at the time of the event */
  83680. pointerX: number;
  83681. /** The Y mouse cursor position at the time of the event */
  83682. pointerY: number;
  83683. /** The mesh that is currently pointed at (can be null) */
  83684. meshUnderPointer: Nullable<AbstractMesh>;
  83685. /** the original (browser) event that triggered the ActionEvent */
  83686. sourceEvent?: any;
  83687. /** additional data for the event */
  83688. additionalData?: any;
  83689. /**
  83690. * Creates a new ActionEvent
  83691. * @param source The mesh or sprite that triggered the action
  83692. * @param pointerX The X mouse cursor position at the time of the event
  83693. * @param pointerY The Y mouse cursor position at the time of the event
  83694. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83695. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83696. * @param additionalData additional data for the event
  83697. */
  83698. constructor(
  83699. /** The mesh or sprite that triggered the action */
  83700. source: any,
  83701. /** The X mouse cursor position at the time of the event */
  83702. pointerX: number,
  83703. /** The Y mouse cursor position at the time of the event */
  83704. pointerY: number,
  83705. /** The mesh that is currently pointed at (can be null) */
  83706. meshUnderPointer: Nullable<AbstractMesh>,
  83707. /** the original (browser) event that triggered the ActionEvent */
  83708. sourceEvent?: any,
  83709. /** additional data for the event */
  83710. additionalData?: any);
  83711. /**
  83712. * Helper function to auto-create an ActionEvent from a source mesh.
  83713. * @param source The source mesh that triggered the event
  83714. * @param evt The original (browser) event
  83715. * @param additionalData additional data for the event
  83716. * @returns the new ActionEvent
  83717. */
  83718. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83719. /**
  83720. * Helper function to auto-create an ActionEvent from a source sprite
  83721. * @param source The source sprite that triggered the event
  83722. * @param scene Scene associated with the sprite
  83723. * @param evt The original (browser) event
  83724. * @param additionalData additional data for the event
  83725. * @returns the new ActionEvent
  83726. */
  83727. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83728. /**
  83729. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83730. * @param scene the scene where the event occurred
  83731. * @param evt The original (browser) event
  83732. * @returns the new ActionEvent
  83733. */
  83734. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83735. /**
  83736. * Helper function to auto-create an ActionEvent from a primitive
  83737. * @param prim defines the target primitive
  83738. * @param pointerPos defines the pointer position
  83739. * @param evt The original (browser) event
  83740. * @param additionalData additional data for the event
  83741. * @returns the new ActionEvent
  83742. */
  83743. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  83744. }
  83745. }
  83746. declare module BABYLON {
  83747. /**
  83748. * Abstract class used to decouple action Manager from scene and meshes.
  83749. * Do not instantiate.
  83750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83751. */
  83752. export abstract class AbstractActionManager implements IDisposable {
  83753. /** Gets the list of active triggers */
  83754. static Triggers: {
  83755. [key: string]: number;
  83756. };
  83757. /** Gets the cursor to use when hovering items */
  83758. hoverCursor: string;
  83759. /** Gets the list of actions */
  83760. actions: IAction[];
  83761. /**
  83762. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  83763. */
  83764. isRecursive: boolean;
  83765. /**
  83766. * Releases all associated resources
  83767. */
  83768. abstract dispose(): void;
  83769. /**
  83770. * Does this action manager has pointer triggers
  83771. */
  83772. abstract readonly hasPointerTriggers: boolean;
  83773. /**
  83774. * Does this action manager has pick triggers
  83775. */
  83776. abstract readonly hasPickTriggers: boolean;
  83777. /**
  83778. * Process a specific trigger
  83779. * @param trigger defines the trigger to process
  83780. * @param evt defines the event details to be processed
  83781. */
  83782. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83783. /**
  83784. * Does this action manager handles actions of any of the given triggers
  83785. * @param triggers defines the triggers to be tested
  83786. * @return a boolean indicating whether one (or more) of the triggers is handled
  83787. */
  83788. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83789. /**
  83790. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83791. * speed.
  83792. * @param triggerA defines the trigger to be tested
  83793. * @param triggerB defines the trigger to be tested
  83794. * @return a boolean indicating whether one (or more) of the triggers is handled
  83795. */
  83796. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83797. /**
  83798. * Does this action manager handles actions of a given trigger
  83799. * @param trigger defines the trigger to be tested
  83800. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83801. * @return whether the trigger is handled
  83802. */
  83803. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83804. /**
  83805. * Serialize this manager to a JSON object
  83806. * @param name defines the property name to store this manager
  83807. * @returns a JSON representation of this manager
  83808. */
  83809. abstract serialize(name: string): any;
  83810. /**
  83811. * Registers an action to this action manager
  83812. * @param action defines the action to be registered
  83813. * @return the action amended (prepared) after registration
  83814. */
  83815. abstract registerAction(action: IAction): Nullable<IAction>;
  83816. /**
  83817. * Unregisters an action to this action manager
  83818. * @param action defines the action to be unregistered
  83819. * @return a boolean indicating whether the action has been unregistered
  83820. */
  83821. abstract unregisterAction(action: IAction): Boolean;
  83822. /**
  83823. * Does exist one action manager with at least one trigger
  83824. **/
  83825. static readonly HasTriggers: boolean;
  83826. /**
  83827. * Does exist one action manager with at least one pick trigger
  83828. **/
  83829. static readonly HasPickTriggers: boolean;
  83830. /**
  83831. * Does exist one action manager that handles actions of a given trigger
  83832. * @param trigger defines the trigger to be tested
  83833. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83834. **/
  83835. static HasSpecificTrigger(trigger: number): boolean;
  83836. }
  83837. }
  83838. declare module BABYLON {
  83839. /**
  83840. * Defines how a node can be built from a string name.
  83841. */
  83842. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83843. /**
  83844. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83845. */
  83846. export class Node implements IBehaviorAware<Node> {
  83847. /** @hidden */
  83848. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83849. private static _NodeConstructors;
  83850. /**
  83851. * Add a new node constructor
  83852. * @param type defines the type name of the node to construct
  83853. * @param constructorFunc defines the constructor function
  83854. */
  83855. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83856. /**
  83857. * Returns a node constructor based on type name
  83858. * @param type defines the type name
  83859. * @param name defines the new node name
  83860. * @param scene defines the hosting scene
  83861. * @param options defines optional options to transmit to constructors
  83862. * @returns the new constructor or null
  83863. */
  83864. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83865. /**
  83866. * Gets or sets the name of the node
  83867. */
  83868. name: string;
  83869. /**
  83870. * Gets or sets the id of the node
  83871. */
  83872. id: string;
  83873. /**
  83874. * Gets or sets the unique id of the node
  83875. */
  83876. uniqueId: number;
  83877. /**
  83878. * Gets or sets a string used to store user defined state for the node
  83879. */
  83880. state: string;
  83881. /**
  83882. * Gets or sets an object used to store user defined information for the node
  83883. */
  83884. metadata: any;
  83885. /**
  83886. * For internal use only. Please do not use.
  83887. */
  83888. reservedDataStore: any;
  83889. /**
  83890. * List of inspectable custom properties (used by the Inspector)
  83891. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83892. */
  83893. inspectableCustomProperties: IInspectable[];
  83894. /**
  83895. * Gets or sets a boolean used to define if the node must be serialized
  83896. */
  83897. doNotSerialize: boolean;
  83898. /** @hidden */
  83899. _isDisposed: boolean;
  83900. /**
  83901. * Gets a list of Animations associated with the node
  83902. */
  83903. animations: Animation[];
  83904. protected _ranges: {
  83905. [name: string]: Nullable<AnimationRange>;
  83906. };
  83907. /**
  83908. * Callback raised when the node is ready to be used
  83909. */
  83910. onReady: (node: Node) => void;
  83911. private _isEnabled;
  83912. private _isParentEnabled;
  83913. private _isReady;
  83914. /** @hidden */
  83915. _currentRenderId: number;
  83916. private _parentUpdateId;
  83917. protected _childUpdateId: number;
  83918. /** @hidden */
  83919. _waitingParentId: Nullable<string>;
  83920. /** @hidden */
  83921. _scene: Scene;
  83922. /** @hidden */
  83923. _cache: any;
  83924. private _parentNode;
  83925. private _children;
  83926. /** @hidden */
  83927. _worldMatrix: Matrix;
  83928. /** @hidden */
  83929. _worldMatrixDeterminant: number;
  83930. /** @hidden */
  83931. private _sceneRootNodesIndex;
  83932. /**
  83933. * Gets a boolean indicating if the node has been disposed
  83934. * @returns true if the node was disposed
  83935. */
  83936. isDisposed(): boolean;
  83937. /**
  83938. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83939. * @see https://doc.babylonjs.com/how_to/parenting
  83940. */
  83941. parent: Nullable<Node>;
  83942. private addToSceneRootNodes;
  83943. private removeFromSceneRootNodes;
  83944. private _animationPropertiesOverride;
  83945. /**
  83946. * Gets or sets the animation properties override
  83947. */
  83948. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83949. /**
  83950. * Gets a string idenfifying the name of the class
  83951. * @returns "Node" string
  83952. */
  83953. getClassName(): string;
  83954. /** @hidden */
  83955. readonly _isNode: boolean;
  83956. /**
  83957. * An event triggered when the mesh is disposed
  83958. */
  83959. onDisposeObservable: Observable<Node>;
  83960. private _onDisposeObserver;
  83961. /**
  83962. * Sets a callback that will be raised when the node will be disposed
  83963. */
  83964. onDispose: () => void;
  83965. /**
  83966. * Creates a new Node
  83967. * @param name the name and id to be given to this node
  83968. * @param scene the scene this node will be added to
  83969. * @param addToRootNodes the node will be added to scene.rootNodes
  83970. */
  83971. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83972. /**
  83973. * Gets the scene of the node
  83974. * @returns a scene
  83975. */
  83976. getScene(): Scene;
  83977. /**
  83978. * Gets the engine of the node
  83979. * @returns a Engine
  83980. */
  83981. getEngine(): Engine;
  83982. private _behaviors;
  83983. /**
  83984. * Attach a behavior to the node
  83985. * @see http://doc.babylonjs.com/features/behaviour
  83986. * @param behavior defines the behavior to attach
  83987. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83988. * @returns the current Node
  83989. */
  83990. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83991. /**
  83992. * Remove an attached behavior
  83993. * @see http://doc.babylonjs.com/features/behaviour
  83994. * @param behavior defines the behavior to attach
  83995. * @returns the current Node
  83996. */
  83997. removeBehavior(behavior: Behavior<Node>): Node;
  83998. /**
  83999. * Gets the list of attached behaviors
  84000. * @see http://doc.babylonjs.com/features/behaviour
  84001. */
  84002. readonly behaviors: Behavior<Node>[];
  84003. /**
  84004. * Gets an attached behavior by name
  84005. * @param name defines the name of the behavior to look for
  84006. * @see http://doc.babylonjs.com/features/behaviour
  84007. * @returns null if behavior was not found else the requested behavior
  84008. */
  84009. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84010. /**
  84011. * Returns the latest update of the World matrix
  84012. * @returns a Matrix
  84013. */
  84014. getWorldMatrix(): Matrix;
  84015. /** @hidden */
  84016. _getWorldMatrixDeterminant(): number;
  84017. /**
  84018. * Returns directly the latest state of the mesh World matrix.
  84019. * A Matrix is returned.
  84020. */
  84021. readonly worldMatrixFromCache: Matrix;
  84022. /** @hidden */
  84023. _initCache(): void;
  84024. /** @hidden */
  84025. updateCache(force?: boolean): void;
  84026. /** @hidden */
  84027. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84028. /** @hidden */
  84029. _updateCache(ignoreParentClass?: boolean): void;
  84030. /** @hidden */
  84031. _isSynchronized(): boolean;
  84032. /** @hidden */
  84033. _markSyncedWithParent(): void;
  84034. /** @hidden */
  84035. isSynchronizedWithParent(): boolean;
  84036. /** @hidden */
  84037. isSynchronized(): boolean;
  84038. /**
  84039. * Is this node ready to be used/rendered
  84040. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84041. * @return true if the node is ready
  84042. */
  84043. isReady(completeCheck?: boolean): boolean;
  84044. /**
  84045. * Is this node enabled?
  84046. * 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
  84047. * @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
  84048. * @return whether this node (and its parent) is enabled
  84049. */
  84050. isEnabled(checkAncestors?: boolean): boolean;
  84051. /** @hidden */
  84052. protected _syncParentEnabledState(): void;
  84053. /**
  84054. * Set the enabled state of this node
  84055. * @param value defines the new enabled state
  84056. */
  84057. setEnabled(value: boolean): void;
  84058. /**
  84059. * Is this node a descendant of the given node?
  84060. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84061. * @param ancestor defines the parent node to inspect
  84062. * @returns a boolean indicating if this node is a descendant of the given node
  84063. */
  84064. isDescendantOf(ancestor: Node): boolean;
  84065. /** @hidden */
  84066. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84067. /**
  84068. * Will return all nodes that have this node as ascendant
  84069. * @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
  84070. * @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
  84071. * @return all children nodes of all types
  84072. */
  84073. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84074. /**
  84075. * Get all child-meshes of this node
  84076. * @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)
  84077. * @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
  84078. * @returns an array of AbstractMesh
  84079. */
  84080. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84081. /**
  84082. * Get all direct children of this node
  84083. * @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
  84084. * @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)
  84085. * @returns an array of Node
  84086. */
  84087. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84088. /** @hidden */
  84089. _setReady(state: boolean): void;
  84090. /**
  84091. * Get an animation by name
  84092. * @param name defines the name of the animation to look for
  84093. * @returns null if not found else the requested animation
  84094. */
  84095. getAnimationByName(name: string): Nullable<Animation>;
  84096. /**
  84097. * Creates an animation range for this node
  84098. * @param name defines the name of the range
  84099. * @param from defines the starting key
  84100. * @param to defines the end key
  84101. */
  84102. createAnimationRange(name: string, from: number, to: number): void;
  84103. /**
  84104. * Delete a specific animation range
  84105. * @param name defines the name of the range to delete
  84106. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84107. */
  84108. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84109. /**
  84110. * Get an animation range by name
  84111. * @param name defines the name of the animation range to look for
  84112. * @returns null if not found else the requested animation range
  84113. */
  84114. getAnimationRange(name: string): Nullable<AnimationRange>;
  84115. /**
  84116. * Gets the list of all animation ranges defined on this node
  84117. * @returns an array
  84118. */
  84119. getAnimationRanges(): Nullable<AnimationRange>[];
  84120. /**
  84121. * Will start the animation sequence
  84122. * @param name defines the range frames for animation sequence
  84123. * @param loop defines if the animation should loop (false by default)
  84124. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84125. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84126. * @returns the object created for this animation. If range does not exist, it will return null
  84127. */
  84128. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84129. /**
  84130. * Serialize animation ranges into a JSON compatible object
  84131. * @returns serialization object
  84132. */
  84133. serializeAnimationRanges(): any;
  84134. /**
  84135. * Computes the world matrix of the node
  84136. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84137. * @returns the world matrix
  84138. */
  84139. computeWorldMatrix(force?: boolean): Matrix;
  84140. /**
  84141. * Releases resources associated with this node.
  84142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84144. */
  84145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84146. /**
  84147. * Parse animation range data from a serialization object and store them into a given node
  84148. * @param node defines where to store the animation ranges
  84149. * @param parsedNode defines the serialization object to read data from
  84150. * @param scene defines the hosting scene
  84151. */
  84152. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84153. }
  84154. }
  84155. declare module BABYLON {
  84156. /**
  84157. * Class used to store any kind of animation
  84158. */
  84159. export class Animation {
  84160. /**Name of the animation */
  84161. name: string;
  84162. /**Property to animate */
  84163. targetProperty: string;
  84164. /**The frames per second of the animation */
  84165. framePerSecond: number;
  84166. /**The data type of the animation */
  84167. dataType: number;
  84168. /**The loop mode of the animation */
  84169. loopMode?: number | undefined;
  84170. /**Specifies if blending should be enabled */
  84171. enableBlending?: boolean | undefined;
  84172. /**
  84173. * Use matrix interpolation instead of using direct key value when animating matrices
  84174. */
  84175. static AllowMatricesInterpolation: boolean;
  84176. /**
  84177. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84178. */
  84179. static AllowMatrixDecomposeForInterpolation: boolean;
  84180. /**
  84181. * Stores the key frames of the animation
  84182. */
  84183. private _keys;
  84184. /**
  84185. * Stores the easing function of the animation
  84186. */
  84187. private _easingFunction;
  84188. /**
  84189. * @hidden Internal use only
  84190. */
  84191. _runtimeAnimations: RuntimeAnimation[];
  84192. /**
  84193. * The set of event that will be linked to this animation
  84194. */
  84195. private _events;
  84196. /**
  84197. * Stores an array of target property paths
  84198. */
  84199. targetPropertyPath: string[];
  84200. /**
  84201. * Stores the blending speed of the animation
  84202. */
  84203. blendingSpeed: number;
  84204. /**
  84205. * Stores the animation ranges for the animation
  84206. */
  84207. private _ranges;
  84208. /**
  84209. * @hidden Internal use
  84210. */
  84211. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84212. /**
  84213. * Sets up an animation
  84214. * @param property The property to animate
  84215. * @param animationType The animation type to apply
  84216. * @param framePerSecond The frames per second of the animation
  84217. * @param easingFunction The easing function used in the animation
  84218. * @returns The created animation
  84219. */
  84220. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84221. /**
  84222. * Create and start an animation on a node
  84223. * @param name defines the name of the global animation that will be run on all nodes
  84224. * @param node defines the root node where the animation will take place
  84225. * @param targetProperty defines property to animate
  84226. * @param framePerSecond defines the number of frame per second yo use
  84227. * @param totalFrame defines the number of frames in total
  84228. * @param from defines the initial value
  84229. * @param to defines the final value
  84230. * @param loopMode defines which loop mode you want to use (off by default)
  84231. * @param easingFunction defines the easing function to use (linear by default)
  84232. * @param onAnimationEnd defines the callback to call when animation end
  84233. * @returns the animatable created for this animation
  84234. */
  84235. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84236. /**
  84237. * Create and start an animation on a node and its descendants
  84238. * @param name defines the name of the global animation that will be run on all nodes
  84239. * @param node defines the root node where the animation will take place
  84240. * @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
  84241. * @param targetProperty defines property to animate
  84242. * @param framePerSecond defines the number of frame per second to use
  84243. * @param totalFrame defines the number of frames in total
  84244. * @param from defines the initial value
  84245. * @param to defines the final value
  84246. * @param loopMode defines which loop mode you want to use (off by default)
  84247. * @param easingFunction defines the easing function to use (linear by default)
  84248. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84249. * @returns the list of animatables created for all nodes
  84250. * @example https://www.babylonjs-playground.com/#MH0VLI
  84251. */
  84252. 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[]>;
  84253. /**
  84254. * Creates a new animation, merges it with the existing animations and starts it
  84255. * @param name Name of the animation
  84256. * @param node Node which contains the scene that begins the animations
  84257. * @param targetProperty Specifies which property to animate
  84258. * @param framePerSecond The frames per second of the animation
  84259. * @param totalFrame The total number of frames
  84260. * @param from The frame at the beginning of the animation
  84261. * @param to The frame at the end of the animation
  84262. * @param loopMode Specifies the loop mode of the animation
  84263. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84264. * @param onAnimationEnd Callback to run once the animation is complete
  84265. * @returns Nullable animation
  84266. */
  84267. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84268. /**
  84269. * Transition property of an host to the target Value
  84270. * @param property The property to transition
  84271. * @param targetValue The target Value of the property
  84272. * @param host The object where the property to animate belongs
  84273. * @param scene Scene used to run the animation
  84274. * @param frameRate Framerate (in frame/s) to use
  84275. * @param transition The transition type we want to use
  84276. * @param duration The duration of the animation, in milliseconds
  84277. * @param onAnimationEnd Callback trigger at the end of the animation
  84278. * @returns Nullable animation
  84279. */
  84280. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84281. /**
  84282. * Return the array of runtime animations currently using this animation
  84283. */
  84284. readonly runtimeAnimations: RuntimeAnimation[];
  84285. /**
  84286. * Specifies if any of the runtime animations are currently running
  84287. */
  84288. readonly hasRunningRuntimeAnimations: boolean;
  84289. /**
  84290. * Initializes the animation
  84291. * @param name Name of the animation
  84292. * @param targetProperty Property to animate
  84293. * @param framePerSecond The frames per second of the animation
  84294. * @param dataType The data type of the animation
  84295. * @param loopMode The loop mode of the animation
  84296. * @param enableBlending Specifies if blending should be enabled
  84297. */
  84298. constructor(
  84299. /**Name of the animation */
  84300. name: string,
  84301. /**Property to animate */
  84302. targetProperty: string,
  84303. /**The frames per second of the animation */
  84304. framePerSecond: number,
  84305. /**The data type of the animation */
  84306. dataType: number,
  84307. /**The loop mode of the animation */
  84308. loopMode?: number | undefined,
  84309. /**Specifies if blending should be enabled */
  84310. enableBlending?: boolean | undefined);
  84311. /**
  84312. * Converts the animation to a string
  84313. * @param fullDetails support for multiple levels of logging within scene loading
  84314. * @returns String form of the animation
  84315. */
  84316. toString(fullDetails?: boolean): string;
  84317. /**
  84318. * Add an event to this animation
  84319. * @param event Event to add
  84320. */
  84321. addEvent(event: AnimationEvent): void;
  84322. /**
  84323. * Remove all events found at the given frame
  84324. * @param frame The frame to remove events from
  84325. */
  84326. removeEvents(frame: number): void;
  84327. /**
  84328. * Retrieves all the events from the animation
  84329. * @returns Events from the animation
  84330. */
  84331. getEvents(): AnimationEvent[];
  84332. /**
  84333. * Creates an animation range
  84334. * @param name Name of the animation range
  84335. * @param from Starting frame of the animation range
  84336. * @param to Ending frame of the animation
  84337. */
  84338. createRange(name: string, from: number, to: number): void;
  84339. /**
  84340. * Deletes an animation range by name
  84341. * @param name Name of the animation range to delete
  84342. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84343. */
  84344. deleteRange(name: string, deleteFrames?: boolean): void;
  84345. /**
  84346. * Gets the animation range by name, or null if not defined
  84347. * @param name Name of the animation range
  84348. * @returns Nullable animation range
  84349. */
  84350. getRange(name: string): Nullable<AnimationRange>;
  84351. /**
  84352. * Gets the key frames from the animation
  84353. * @returns The key frames of the animation
  84354. */
  84355. getKeys(): Array<IAnimationKey>;
  84356. /**
  84357. * Gets the highest frame rate of the animation
  84358. * @returns Highest frame rate of the animation
  84359. */
  84360. getHighestFrame(): number;
  84361. /**
  84362. * Gets the easing function of the animation
  84363. * @returns Easing function of the animation
  84364. */
  84365. getEasingFunction(): IEasingFunction;
  84366. /**
  84367. * Sets the easing function of the animation
  84368. * @param easingFunction A custom mathematical formula for animation
  84369. */
  84370. setEasingFunction(easingFunction: EasingFunction): void;
  84371. /**
  84372. * Interpolates a scalar linearly
  84373. * @param startValue Start value of the animation curve
  84374. * @param endValue End value of the animation curve
  84375. * @param gradient Scalar amount to interpolate
  84376. * @returns Interpolated scalar value
  84377. */
  84378. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84379. /**
  84380. * Interpolates a scalar cubically
  84381. * @param startValue Start value of the animation curve
  84382. * @param outTangent End tangent of the animation
  84383. * @param endValue End value of the animation curve
  84384. * @param inTangent Start tangent of the animation curve
  84385. * @param gradient Scalar amount to interpolate
  84386. * @returns Interpolated scalar value
  84387. */
  84388. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84389. /**
  84390. * Interpolates a quaternion using a spherical linear interpolation
  84391. * @param startValue Start value of the animation curve
  84392. * @param endValue End value of the animation curve
  84393. * @param gradient Scalar amount to interpolate
  84394. * @returns Interpolated quaternion value
  84395. */
  84396. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84397. /**
  84398. * Interpolates a quaternion cubically
  84399. * @param startValue Start value of the animation curve
  84400. * @param outTangent End tangent of the animation curve
  84401. * @param endValue End value of the animation curve
  84402. * @param inTangent Start tangent of the animation curve
  84403. * @param gradient Scalar amount to interpolate
  84404. * @returns Interpolated quaternion value
  84405. */
  84406. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84407. /**
  84408. * Interpolates a Vector3 linearl
  84409. * @param startValue Start value of the animation curve
  84410. * @param endValue End value of the animation curve
  84411. * @param gradient Scalar amount to interpolate
  84412. * @returns Interpolated scalar value
  84413. */
  84414. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84415. /**
  84416. * Interpolates a Vector3 cubically
  84417. * @param startValue Start value of the animation curve
  84418. * @param outTangent End tangent of the animation
  84419. * @param endValue End value of the animation curve
  84420. * @param inTangent Start tangent of the animation curve
  84421. * @param gradient Scalar amount to interpolate
  84422. * @returns InterpolatedVector3 value
  84423. */
  84424. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84425. /**
  84426. * Interpolates a Vector2 linearly
  84427. * @param startValue Start value of the animation curve
  84428. * @param endValue End value of the animation curve
  84429. * @param gradient Scalar amount to interpolate
  84430. * @returns Interpolated Vector2 value
  84431. */
  84432. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84433. /**
  84434. * Interpolates a Vector2 cubically
  84435. * @param startValue Start value of the animation curve
  84436. * @param outTangent End tangent of the animation
  84437. * @param endValue End value of the animation curve
  84438. * @param inTangent Start tangent of the animation curve
  84439. * @param gradient Scalar amount to interpolate
  84440. * @returns Interpolated Vector2 value
  84441. */
  84442. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84443. /**
  84444. * Interpolates a size linearly
  84445. * @param startValue Start value of the animation curve
  84446. * @param endValue End value of the animation curve
  84447. * @param gradient Scalar amount to interpolate
  84448. * @returns Interpolated Size value
  84449. */
  84450. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84451. /**
  84452. * Interpolates a Color3 linearly
  84453. * @param startValue Start value of the animation curve
  84454. * @param endValue End value of the animation curve
  84455. * @param gradient Scalar amount to interpolate
  84456. * @returns Interpolated Color3 value
  84457. */
  84458. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84459. /**
  84460. * @hidden Internal use only
  84461. */
  84462. _getKeyValue(value: any): any;
  84463. /**
  84464. * @hidden Internal use only
  84465. */
  84466. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84467. /**
  84468. * Defines the function to use to interpolate matrices
  84469. * @param startValue defines the start matrix
  84470. * @param endValue defines the end matrix
  84471. * @param gradient defines the gradient between both matrices
  84472. * @param result defines an optional target matrix where to store the interpolation
  84473. * @returns the interpolated matrix
  84474. */
  84475. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84476. /**
  84477. * Makes a copy of the animation
  84478. * @returns Cloned animation
  84479. */
  84480. clone(): Animation;
  84481. /**
  84482. * Sets the key frames of the animation
  84483. * @param values The animation key frames to set
  84484. */
  84485. setKeys(values: Array<IAnimationKey>): void;
  84486. /**
  84487. * Serializes the animation to an object
  84488. * @returns Serialized object
  84489. */
  84490. serialize(): any;
  84491. /**
  84492. * Float animation type
  84493. */
  84494. private static _ANIMATIONTYPE_FLOAT;
  84495. /**
  84496. * Vector3 animation type
  84497. */
  84498. private static _ANIMATIONTYPE_VECTOR3;
  84499. /**
  84500. * Quaternion animation type
  84501. */
  84502. private static _ANIMATIONTYPE_QUATERNION;
  84503. /**
  84504. * Matrix animation type
  84505. */
  84506. private static _ANIMATIONTYPE_MATRIX;
  84507. /**
  84508. * Color3 animation type
  84509. */
  84510. private static _ANIMATIONTYPE_COLOR3;
  84511. /**
  84512. * Vector2 animation type
  84513. */
  84514. private static _ANIMATIONTYPE_VECTOR2;
  84515. /**
  84516. * Size animation type
  84517. */
  84518. private static _ANIMATIONTYPE_SIZE;
  84519. /**
  84520. * Relative Loop Mode
  84521. */
  84522. private static _ANIMATIONLOOPMODE_RELATIVE;
  84523. /**
  84524. * Cycle Loop Mode
  84525. */
  84526. private static _ANIMATIONLOOPMODE_CYCLE;
  84527. /**
  84528. * Constant Loop Mode
  84529. */
  84530. private static _ANIMATIONLOOPMODE_CONSTANT;
  84531. /**
  84532. * Get the float animation type
  84533. */
  84534. static readonly ANIMATIONTYPE_FLOAT: number;
  84535. /**
  84536. * Get the Vector3 animation type
  84537. */
  84538. static readonly ANIMATIONTYPE_VECTOR3: number;
  84539. /**
  84540. * Get the Vector2 animation type
  84541. */
  84542. static readonly ANIMATIONTYPE_VECTOR2: number;
  84543. /**
  84544. * Get the Size animation type
  84545. */
  84546. static readonly ANIMATIONTYPE_SIZE: number;
  84547. /**
  84548. * Get the Quaternion animation type
  84549. */
  84550. static readonly ANIMATIONTYPE_QUATERNION: number;
  84551. /**
  84552. * Get the Matrix animation type
  84553. */
  84554. static readonly ANIMATIONTYPE_MATRIX: number;
  84555. /**
  84556. * Get the Color3 animation type
  84557. */
  84558. static readonly ANIMATIONTYPE_COLOR3: number;
  84559. /**
  84560. * Get the Relative Loop Mode
  84561. */
  84562. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84563. /**
  84564. * Get the Cycle Loop Mode
  84565. */
  84566. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84567. /**
  84568. * Get the Constant Loop Mode
  84569. */
  84570. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84571. /** @hidden */
  84572. static _UniversalLerp(left: any, right: any, amount: number): any;
  84573. /**
  84574. * Parses an animation object and creates an animation
  84575. * @param parsedAnimation Parsed animation object
  84576. * @returns Animation object
  84577. */
  84578. static Parse(parsedAnimation: any): Animation;
  84579. /**
  84580. * Appends the serialized animations from the source animations
  84581. * @param source Source containing the animations
  84582. * @param destination Target to store the animations
  84583. */
  84584. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84585. }
  84586. }
  84587. declare module BABYLON {
  84588. /**
  84589. * Base class of all the textures in babylon.
  84590. * It groups all the common properties the materials, post process, lights... might need
  84591. * in order to make a correct use of the texture.
  84592. */
  84593. export class BaseTexture implements IAnimatable {
  84594. /**
  84595. * Default anisotropic filtering level for the application.
  84596. * It is set to 4 as a good tradeoff between perf and quality.
  84597. */
  84598. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84599. /**
  84600. * Gets or sets the unique id of the texture
  84601. */
  84602. uniqueId: number;
  84603. /**
  84604. * Define the name of the texture.
  84605. */
  84606. name: string;
  84607. /**
  84608. * Gets or sets an object used to store user defined information.
  84609. */
  84610. metadata: any;
  84611. /**
  84612. * For internal use only. Please do not use.
  84613. */
  84614. reservedDataStore: any;
  84615. private _hasAlpha;
  84616. /**
  84617. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84618. */
  84619. hasAlpha: boolean;
  84620. /**
  84621. * Defines if the alpha value should be determined via the rgb values.
  84622. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84623. */
  84624. getAlphaFromRGB: boolean;
  84625. /**
  84626. * Intensity or strength of the texture.
  84627. * It is commonly used by materials to fine tune the intensity of the texture
  84628. */
  84629. level: number;
  84630. /**
  84631. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84632. * This is part of the texture as textures usually maps to one uv set.
  84633. */
  84634. coordinatesIndex: number;
  84635. private _coordinatesMode;
  84636. /**
  84637. * How a texture is mapped.
  84638. *
  84639. * | Value | Type | Description |
  84640. * | ----- | ----------------------------------- | ----------- |
  84641. * | 0 | EXPLICIT_MODE | |
  84642. * | 1 | SPHERICAL_MODE | |
  84643. * | 2 | PLANAR_MODE | |
  84644. * | 3 | CUBIC_MODE | |
  84645. * | 4 | PROJECTION_MODE | |
  84646. * | 5 | SKYBOX_MODE | |
  84647. * | 6 | INVCUBIC_MODE | |
  84648. * | 7 | EQUIRECTANGULAR_MODE | |
  84649. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84650. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84651. */
  84652. coordinatesMode: number;
  84653. /**
  84654. * | Value | Type | Description |
  84655. * | ----- | ------------------ | ----------- |
  84656. * | 0 | CLAMP_ADDRESSMODE | |
  84657. * | 1 | WRAP_ADDRESSMODE | |
  84658. * | 2 | MIRROR_ADDRESSMODE | |
  84659. */
  84660. wrapU: number;
  84661. /**
  84662. * | Value | Type | Description |
  84663. * | ----- | ------------------ | ----------- |
  84664. * | 0 | CLAMP_ADDRESSMODE | |
  84665. * | 1 | WRAP_ADDRESSMODE | |
  84666. * | 2 | MIRROR_ADDRESSMODE | |
  84667. */
  84668. wrapV: number;
  84669. /**
  84670. * | Value | Type | Description |
  84671. * | ----- | ------------------ | ----------- |
  84672. * | 0 | CLAMP_ADDRESSMODE | |
  84673. * | 1 | WRAP_ADDRESSMODE | |
  84674. * | 2 | MIRROR_ADDRESSMODE | |
  84675. */
  84676. wrapR: number;
  84677. /**
  84678. * With compliant hardware and browser (supporting anisotropic filtering)
  84679. * this defines the level of anisotropic filtering in the texture.
  84680. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84681. */
  84682. anisotropicFilteringLevel: number;
  84683. /**
  84684. * Define if the texture is a cube texture or if false a 2d texture.
  84685. */
  84686. isCube: boolean;
  84687. /**
  84688. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84689. */
  84690. is3D: boolean;
  84691. /**
  84692. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84693. * HDR texture are usually stored in linear space.
  84694. * This only impacts the PBR and Background materials
  84695. */
  84696. gammaSpace: boolean;
  84697. /**
  84698. * Gets whether or not the texture contains RGBD data.
  84699. */
  84700. readonly isRGBD: boolean;
  84701. /**
  84702. * Is Z inverted in the texture (useful in a cube texture).
  84703. */
  84704. invertZ: boolean;
  84705. /**
  84706. * Are mip maps generated for this texture or not.
  84707. */
  84708. readonly noMipmap: boolean;
  84709. /**
  84710. * @hidden
  84711. */
  84712. lodLevelInAlpha: boolean;
  84713. /**
  84714. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84715. */
  84716. lodGenerationOffset: number;
  84717. /**
  84718. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84719. */
  84720. lodGenerationScale: number;
  84721. /**
  84722. * Define if the texture is a render target.
  84723. */
  84724. isRenderTarget: boolean;
  84725. /**
  84726. * Define the unique id of the texture in the scene.
  84727. */
  84728. readonly uid: string;
  84729. /**
  84730. * Return a string representation of the texture.
  84731. * @returns the texture as a string
  84732. */
  84733. toString(): string;
  84734. /**
  84735. * Get the class name of the texture.
  84736. * @returns "BaseTexture"
  84737. */
  84738. getClassName(): string;
  84739. /**
  84740. * Define the list of animation attached to the texture.
  84741. */
  84742. animations: Animation[];
  84743. /**
  84744. * An event triggered when the texture is disposed.
  84745. */
  84746. onDisposeObservable: Observable<BaseTexture>;
  84747. private _onDisposeObserver;
  84748. /**
  84749. * Callback triggered when the texture has been disposed.
  84750. * Kept for back compatibility, you can use the onDisposeObservable instead.
  84751. */
  84752. onDispose: () => void;
  84753. /**
  84754. * Define the current state of the loading sequence when in delayed load mode.
  84755. */
  84756. delayLoadState: number;
  84757. private _scene;
  84758. /** @hidden */
  84759. _texture: Nullable<InternalTexture>;
  84760. private _uid;
  84761. /**
  84762. * Define if the texture is preventinga material to render or not.
  84763. * If not and the texture is not ready, the engine will use a default black texture instead.
  84764. */
  84765. readonly isBlocking: boolean;
  84766. /**
  84767. * Instantiates a new BaseTexture.
  84768. * Base class of all the textures in babylon.
  84769. * It groups all the common properties the materials, post process, lights... might need
  84770. * in order to make a correct use of the texture.
  84771. * @param scene Define the scene the texture blongs to
  84772. */
  84773. constructor(scene: Nullable<Scene>);
  84774. /**
  84775. * Get the scene the texture belongs to.
  84776. * @returns the scene or null if undefined
  84777. */
  84778. getScene(): Nullable<Scene>;
  84779. /**
  84780. * Get the texture transform matrix used to offset tile the texture for istance.
  84781. * @returns the transformation matrix
  84782. */
  84783. getTextureMatrix(): Matrix;
  84784. /**
  84785. * Get the texture reflection matrix used to rotate/transform the reflection.
  84786. * @returns the reflection matrix
  84787. */
  84788. getReflectionTextureMatrix(): Matrix;
  84789. /**
  84790. * Get the underlying lower level texture from Babylon.
  84791. * @returns the insternal texture
  84792. */
  84793. getInternalTexture(): Nullable<InternalTexture>;
  84794. /**
  84795. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84796. * @returns true if ready or not blocking
  84797. */
  84798. isReadyOrNotBlocking(): boolean;
  84799. /**
  84800. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84801. * @returns true if fully ready
  84802. */
  84803. isReady(): boolean;
  84804. private _cachedSize;
  84805. /**
  84806. * Get the size of the texture.
  84807. * @returns the texture size.
  84808. */
  84809. getSize(): ISize;
  84810. /**
  84811. * Get the base size of the texture.
  84812. * It can be different from the size if the texture has been resized for POT for instance
  84813. * @returns the base size
  84814. */
  84815. getBaseSize(): ISize;
  84816. /**
  84817. * Update the sampling mode of the texture.
  84818. * Default is Trilinear mode.
  84819. *
  84820. * | Value | Type | Description |
  84821. * | ----- | ------------------ | ----------- |
  84822. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84823. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84824. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84825. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84826. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84827. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84828. * | 7 | NEAREST_LINEAR | |
  84829. * | 8 | NEAREST_NEAREST | |
  84830. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84831. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84832. * | 11 | LINEAR_LINEAR | |
  84833. * | 12 | LINEAR_NEAREST | |
  84834. *
  84835. * > _mag_: magnification filter (close to the viewer)
  84836. * > _min_: minification filter (far from the viewer)
  84837. * > _mip_: filter used between mip map levels
  84838. *@param samplingMode Define the new sampling mode of the texture
  84839. */
  84840. updateSamplingMode(samplingMode: number): void;
  84841. /**
  84842. * Scales the texture if is `canRescale()`
  84843. * @param ratio the resize factor we want to use to rescale
  84844. */
  84845. scale(ratio: number): void;
  84846. /**
  84847. * Get if the texture can rescale.
  84848. */
  84849. readonly canRescale: boolean;
  84850. /** @hidden */
  84851. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84852. /** @hidden */
  84853. _rebuild(): void;
  84854. /**
  84855. * Triggers the load sequence in delayed load mode.
  84856. */
  84857. delayLoad(): void;
  84858. /**
  84859. * Clones the texture.
  84860. * @returns the cloned texture
  84861. */
  84862. clone(): Nullable<BaseTexture>;
  84863. /**
  84864. * Get the texture underlying type (INT, FLOAT...)
  84865. */
  84866. readonly textureType: number;
  84867. /**
  84868. * Get the texture underlying format (RGB, RGBA...)
  84869. */
  84870. readonly textureFormat: number;
  84871. /**
  84872. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84873. * This will returns an RGBA array buffer containing either in values (0-255) or
  84874. * float values (0-1) depending of the underlying buffer type.
  84875. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84876. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84877. * @param buffer defines a user defined buffer to fill with data (can be null)
  84878. * @returns The Array buffer containing the pixels data.
  84879. */
  84880. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84881. /**
  84882. * Release and destroy the underlying lower level texture aka internalTexture.
  84883. */
  84884. releaseInternalTexture(): void;
  84885. /**
  84886. * Get the polynomial representation of the texture data.
  84887. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84888. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84889. */
  84890. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84891. /** @hidden */
  84892. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84893. /** @hidden */
  84894. readonly _lodTextureMid: Nullable<BaseTexture>;
  84895. /** @hidden */
  84896. readonly _lodTextureLow: Nullable<BaseTexture>;
  84897. /**
  84898. * Dispose the texture and release its associated resources.
  84899. */
  84900. dispose(): void;
  84901. /**
  84902. * Serialize the texture into a JSON representation that can be parsed later on.
  84903. * @returns the JSON representation of the texture
  84904. */
  84905. serialize(): any;
  84906. /**
  84907. * Helper function to be called back once a list of texture contains only ready textures.
  84908. * @param textures Define the list of textures to wait for
  84909. * @param callback Define the callback triggered once the entire list will be ready
  84910. */
  84911. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84912. }
  84913. }
  84914. declare module BABYLON {
  84915. /**
  84916. * Uniform buffer objects.
  84917. *
  84918. * Handles blocks of uniform on the GPU.
  84919. *
  84920. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84921. *
  84922. * For more information, please refer to :
  84923. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84924. */
  84925. export class UniformBuffer {
  84926. private _engine;
  84927. private _buffer;
  84928. private _data;
  84929. private _bufferData;
  84930. private _dynamic?;
  84931. private _uniformLocations;
  84932. private _uniformSizes;
  84933. private _uniformLocationPointer;
  84934. private _needSync;
  84935. private _noUBO;
  84936. private _currentEffect;
  84937. private static _MAX_UNIFORM_SIZE;
  84938. private static _tempBuffer;
  84939. /**
  84940. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84941. * This is dynamic to allow compat with webgl 1 and 2.
  84942. * You will need to pass the name of the uniform as well as the value.
  84943. */
  84944. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84945. /**
  84946. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84947. * This is dynamic to allow compat with webgl 1 and 2.
  84948. * You will need to pass the name of the uniform as well as the value.
  84949. */
  84950. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84951. /**
  84952. * Lambda to Update a single float in a uniform buffer.
  84953. * This is dynamic to allow compat with webgl 1 and 2.
  84954. * You will need to pass the name of the uniform as well as the value.
  84955. */
  84956. updateFloat: (name: string, x: number) => void;
  84957. /**
  84958. * Lambda to Update a vec2 of float in a uniform buffer.
  84959. * This is dynamic to allow compat with webgl 1 and 2.
  84960. * You will need to pass the name of the uniform as well as the value.
  84961. */
  84962. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84963. /**
  84964. * Lambda to Update a vec3 of float in a uniform buffer.
  84965. * This is dynamic to allow compat with webgl 1 and 2.
  84966. * You will need to pass the name of the uniform as well as the value.
  84967. */
  84968. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84969. /**
  84970. * Lambda to Update a vec4 of float in a uniform buffer.
  84971. * This is dynamic to allow compat with webgl 1 and 2.
  84972. * You will need to pass the name of the uniform as well as the value.
  84973. */
  84974. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84975. /**
  84976. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84977. * This is dynamic to allow compat with webgl 1 and 2.
  84978. * You will need to pass the name of the uniform as well as the value.
  84979. */
  84980. updateMatrix: (name: string, mat: Matrix) => void;
  84981. /**
  84982. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84983. * This is dynamic to allow compat with webgl 1 and 2.
  84984. * You will need to pass the name of the uniform as well as the value.
  84985. */
  84986. updateVector3: (name: string, vector: Vector3) => void;
  84987. /**
  84988. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84989. * This is dynamic to allow compat with webgl 1 and 2.
  84990. * You will need to pass the name of the uniform as well as the value.
  84991. */
  84992. updateVector4: (name: string, vector: Vector4) => void;
  84993. /**
  84994. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84995. * This is dynamic to allow compat with webgl 1 and 2.
  84996. * You will need to pass the name of the uniform as well as the value.
  84997. */
  84998. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84999. /**
  85000. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85001. * This is dynamic to allow compat with webgl 1 and 2.
  85002. * You will need to pass the name of the uniform as well as the value.
  85003. */
  85004. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85005. /**
  85006. * Instantiates a new Uniform buffer objects.
  85007. *
  85008. * Handles blocks of uniform on the GPU.
  85009. *
  85010. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85011. *
  85012. * For more information, please refer to :
  85013. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85014. * @param engine Define the engine the buffer is associated with
  85015. * @param data Define the data contained in the buffer
  85016. * @param dynamic Define if the buffer is updatable
  85017. */
  85018. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85019. /**
  85020. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85021. * or just falling back on setUniformXXX calls.
  85022. */
  85023. readonly useUbo: boolean;
  85024. /**
  85025. * Indicates if the WebGL underlying uniform buffer is in sync
  85026. * with the javascript cache data.
  85027. */
  85028. readonly isSync: boolean;
  85029. /**
  85030. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85031. * Also, a dynamic UniformBuffer will disable cache verification and always
  85032. * update the underlying WebGL uniform buffer to the GPU.
  85033. * @returns if Dynamic, otherwise false
  85034. */
  85035. isDynamic(): boolean;
  85036. /**
  85037. * The data cache on JS side.
  85038. * @returns the underlying data as a float array
  85039. */
  85040. getData(): Float32Array;
  85041. /**
  85042. * The underlying WebGL Uniform buffer.
  85043. * @returns the webgl buffer
  85044. */
  85045. getBuffer(): Nullable<WebGLBuffer>;
  85046. /**
  85047. * std140 layout specifies how to align data within an UBO structure.
  85048. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85049. * for specs.
  85050. */
  85051. private _fillAlignment;
  85052. /**
  85053. * Adds an uniform in the buffer.
  85054. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85055. * for the layout to be correct !
  85056. * @param name Name of the uniform, as used in the uniform block in the shader.
  85057. * @param size Data size, or data directly.
  85058. */
  85059. addUniform(name: string, size: number | number[]): void;
  85060. /**
  85061. * Adds a Matrix 4x4 to the uniform buffer.
  85062. * @param name Name of the uniform, as used in the uniform block in the shader.
  85063. * @param mat A 4x4 matrix.
  85064. */
  85065. addMatrix(name: string, mat: Matrix): void;
  85066. /**
  85067. * Adds a vec2 to the uniform buffer.
  85068. * @param name Name of the uniform, as used in the uniform block in the shader.
  85069. * @param x Define the x component value of the vec2
  85070. * @param y Define the y component value of the vec2
  85071. */
  85072. addFloat2(name: string, x: number, y: number): void;
  85073. /**
  85074. * Adds a vec3 to the uniform buffer.
  85075. * @param name Name of the uniform, as used in the uniform block in the shader.
  85076. * @param x Define the x component value of the vec3
  85077. * @param y Define the y component value of the vec3
  85078. * @param z Define the z component value of the vec3
  85079. */
  85080. addFloat3(name: string, x: number, y: number, z: number): void;
  85081. /**
  85082. * Adds a vec3 to the uniform buffer.
  85083. * @param name Name of the uniform, as used in the uniform block in the shader.
  85084. * @param color Define the vec3 from a Color
  85085. */
  85086. addColor3(name: string, color: Color3): void;
  85087. /**
  85088. * Adds a vec4 to the uniform buffer.
  85089. * @param name Name of the uniform, as used in the uniform block in the shader.
  85090. * @param color Define the rgb components from a Color
  85091. * @param alpha Define the a component of the vec4
  85092. */
  85093. addColor4(name: string, color: Color3, alpha: number): void;
  85094. /**
  85095. * Adds a vec3 to the uniform buffer.
  85096. * @param name Name of the uniform, as used in the uniform block in the shader.
  85097. * @param vector Define the vec3 components from a Vector
  85098. */
  85099. addVector3(name: string, vector: Vector3): void;
  85100. /**
  85101. * Adds a Matrix 3x3 to the uniform buffer.
  85102. * @param name Name of the uniform, as used in the uniform block in the shader.
  85103. */
  85104. addMatrix3x3(name: string): void;
  85105. /**
  85106. * Adds a Matrix 2x2 to the uniform buffer.
  85107. * @param name Name of the uniform, as used in the uniform block in the shader.
  85108. */
  85109. addMatrix2x2(name: string): void;
  85110. /**
  85111. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85112. */
  85113. create(): void;
  85114. /** @hidden */
  85115. _rebuild(): void;
  85116. /**
  85117. * Updates the WebGL Uniform Buffer on the GPU.
  85118. * If the `dynamic` flag is set to true, no cache comparison is done.
  85119. * Otherwise, the buffer will be updated only if the cache differs.
  85120. */
  85121. update(): void;
  85122. /**
  85123. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85124. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85125. * @param data Define the flattened data
  85126. * @param size Define the size of the data.
  85127. */
  85128. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85129. private _updateMatrix3x3ForUniform;
  85130. private _updateMatrix3x3ForEffect;
  85131. private _updateMatrix2x2ForEffect;
  85132. private _updateMatrix2x2ForUniform;
  85133. private _updateFloatForEffect;
  85134. private _updateFloatForUniform;
  85135. private _updateFloat2ForEffect;
  85136. private _updateFloat2ForUniform;
  85137. private _updateFloat3ForEffect;
  85138. private _updateFloat3ForUniform;
  85139. private _updateFloat4ForEffect;
  85140. private _updateFloat4ForUniform;
  85141. private _updateMatrixForEffect;
  85142. private _updateMatrixForUniform;
  85143. private _updateVector3ForEffect;
  85144. private _updateVector3ForUniform;
  85145. private _updateVector4ForEffect;
  85146. private _updateVector4ForUniform;
  85147. private _updateColor3ForEffect;
  85148. private _updateColor3ForUniform;
  85149. private _updateColor4ForEffect;
  85150. private _updateColor4ForUniform;
  85151. /**
  85152. * Sets a sampler uniform on the effect.
  85153. * @param name Define the name of the sampler.
  85154. * @param texture Define the texture to set in the sampler
  85155. */
  85156. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85157. /**
  85158. * Directly updates the value of the uniform in the cache AND on the GPU.
  85159. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85160. * @param data Define the flattened data
  85161. */
  85162. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85163. /**
  85164. * Binds this uniform buffer to an effect.
  85165. * @param effect Define the effect to bind the buffer to
  85166. * @param name Name of the uniform block in the shader.
  85167. */
  85168. bindToEffect(effect: Effect, name: string): void;
  85169. /**
  85170. * Disposes the uniform buffer.
  85171. */
  85172. dispose(): void;
  85173. }
  85174. }
  85175. declare module BABYLON {
  85176. /**
  85177. * This represents the required contract to create a new type of texture loader.
  85178. */
  85179. export interface IInternalTextureLoader {
  85180. /**
  85181. * Defines wether the loader supports cascade loading the different faces.
  85182. */
  85183. supportCascades: boolean;
  85184. /**
  85185. * This returns if the loader support the current file information.
  85186. * @param extension defines the file extension of the file being loaded
  85187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85188. * @param fallback defines the fallback internal texture if any
  85189. * @param isBase64 defines whether the texture is encoded as a base64
  85190. * @param isBuffer defines whether the texture data are stored as a buffer
  85191. * @returns true if the loader can load the specified file
  85192. */
  85193. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85194. /**
  85195. * Transform the url before loading if required.
  85196. * @param rootUrl the url of the texture
  85197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85198. * @returns the transformed texture
  85199. */
  85200. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85201. /**
  85202. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85203. * @param rootUrl the url of the texture
  85204. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85205. * @returns the fallback texture
  85206. */
  85207. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85208. /**
  85209. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85210. * @param data contains the texture data
  85211. * @param texture defines the BabylonJS internal texture
  85212. * @param createPolynomials will be true if polynomials have been requested
  85213. * @param onLoad defines the callback to trigger once the texture is ready
  85214. * @param onError defines the callback to trigger in case of error
  85215. */
  85216. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85217. /**
  85218. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85219. * @param data contains the texture data
  85220. * @param texture defines the BabylonJS internal texture
  85221. * @param callback defines the method to call once ready to upload
  85222. */
  85223. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85224. }
  85225. }
  85226. declare module BABYLON {
  85227. /**
  85228. * Creation options of the multi render target texture.
  85229. */
  85230. export interface IMultiRenderTargetOptions {
  85231. /**
  85232. * Define if the texture needs to create mip maps after render.
  85233. */
  85234. generateMipMaps?: boolean;
  85235. /**
  85236. * Define the types of all the draw buffers we want to create
  85237. */
  85238. types?: number[];
  85239. /**
  85240. * Define the sampling modes of all the draw buffers we want to create
  85241. */
  85242. samplingModes?: number[];
  85243. /**
  85244. * Define if a depth buffer is required
  85245. */
  85246. generateDepthBuffer?: boolean;
  85247. /**
  85248. * Define if a stencil buffer is required
  85249. */
  85250. generateStencilBuffer?: boolean;
  85251. /**
  85252. * Define if a depth texture is required instead of a depth buffer
  85253. */
  85254. generateDepthTexture?: boolean;
  85255. /**
  85256. * Define the number of desired draw buffers
  85257. */
  85258. textureCount?: number;
  85259. /**
  85260. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85261. */
  85262. doNotChangeAspectRatio?: boolean;
  85263. /**
  85264. * Define the default type of the buffers we are creating
  85265. */
  85266. defaultType?: number;
  85267. }
  85268. /**
  85269. * A multi render target, like a render target provides the ability to render to a texture.
  85270. * Unlike the render target, it can render to several draw buffers in one draw.
  85271. * This is specially interesting in deferred rendering or for any effects requiring more than
  85272. * just one color from a single pass.
  85273. */
  85274. export class MultiRenderTarget extends RenderTargetTexture {
  85275. private _internalTextures;
  85276. private _textures;
  85277. private _multiRenderTargetOptions;
  85278. /**
  85279. * Get if draw buffers are currently supported by the used hardware and browser.
  85280. */
  85281. readonly isSupported: boolean;
  85282. /**
  85283. * Get the list of textures generated by the multi render target.
  85284. */
  85285. readonly textures: Texture[];
  85286. /**
  85287. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85288. */
  85289. readonly depthTexture: Texture;
  85290. /**
  85291. * Set the wrapping mode on U of all the textures we are rendering to.
  85292. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85293. */
  85294. wrapU: number;
  85295. /**
  85296. * Set the wrapping mode on V of all the textures we are rendering to.
  85297. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85298. */
  85299. wrapV: number;
  85300. /**
  85301. * Instantiate a new multi render target texture.
  85302. * A multi render target, like a render target provides the ability to render to a texture.
  85303. * Unlike the render target, it can render to several draw buffers in one draw.
  85304. * This is specially interesting in deferred rendering or for any effects requiring more than
  85305. * just one color from a single pass.
  85306. * @param name Define the name of the texture
  85307. * @param size Define the size of the buffers to render to
  85308. * @param count Define the number of target we are rendering into
  85309. * @param scene Define the scene the texture belongs to
  85310. * @param options Define the options used to create the multi render target
  85311. */
  85312. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85313. /** @hidden */
  85314. _rebuild(): void;
  85315. private _createInternalTextures;
  85316. private _createTextures;
  85317. /**
  85318. * Define the number of samples used if MSAA is enabled.
  85319. */
  85320. samples: number;
  85321. /**
  85322. * Resize all the textures in the multi render target.
  85323. * Be carrefull as it will recreate all the data in the new texture.
  85324. * @param size Define the new size
  85325. */
  85326. resize(size: any): void;
  85327. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85328. /**
  85329. * Dispose the render targets and their associated resources
  85330. */
  85331. dispose(): void;
  85332. /**
  85333. * Release all the underlying texture used as draw buffers.
  85334. */
  85335. releaseInternalTextures(): void;
  85336. }
  85337. }
  85338. declare module BABYLON {
  85339. /**
  85340. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85342. */
  85343. export class Analyser {
  85344. /**
  85345. * Gets or sets the smoothing
  85346. * @ignorenaming
  85347. */
  85348. SMOOTHING: number;
  85349. /**
  85350. * Gets or sets the FFT table size
  85351. * @ignorenaming
  85352. */
  85353. FFT_SIZE: number;
  85354. /**
  85355. * Gets or sets the bar graph amplitude
  85356. * @ignorenaming
  85357. */
  85358. BARGRAPHAMPLITUDE: number;
  85359. /**
  85360. * Gets or sets the position of the debug canvas
  85361. * @ignorenaming
  85362. */
  85363. DEBUGCANVASPOS: {
  85364. x: number;
  85365. y: number;
  85366. };
  85367. /**
  85368. * Gets or sets the debug canvas size
  85369. * @ignorenaming
  85370. */
  85371. DEBUGCANVASSIZE: {
  85372. width: number;
  85373. height: number;
  85374. };
  85375. private _byteFreqs;
  85376. private _byteTime;
  85377. private _floatFreqs;
  85378. private _webAudioAnalyser;
  85379. private _debugCanvas;
  85380. private _debugCanvasContext;
  85381. private _scene;
  85382. private _registerFunc;
  85383. private _audioEngine;
  85384. /**
  85385. * Creates a new analyser
  85386. * @param scene defines hosting scene
  85387. */
  85388. constructor(scene: Scene);
  85389. /**
  85390. * Get the number of data values you will have to play with for the visualization
  85391. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85392. * @returns a number
  85393. */
  85394. getFrequencyBinCount(): number;
  85395. /**
  85396. * Gets the current frequency data as a byte array
  85397. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85398. * @returns a Uint8Array
  85399. */
  85400. getByteFrequencyData(): Uint8Array;
  85401. /**
  85402. * Gets the current waveform as a byte array
  85403. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85404. * @returns a Uint8Array
  85405. */
  85406. getByteTimeDomainData(): Uint8Array;
  85407. /**
  85408. * Gets the current frequency data as a float array
  85409. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85410. * @returns a Float32Array
  85411. */
  85412. getFloatFrequencyData(): Float32Array;
  85413. /**
  85414. * Renders the debug canvas
  85415. */
  85416. drawDebugCanvas(): void;
  85417. /**
  85418. * Stops rendering the debug canvas and removes it
  85419. */
  85420. stopDebugCanvas(): void;
  85421. /**
  85422. * Connects two audio nodes
  85423. * @param inputAudioNode defines first node to connect
  85424. * @param outputAudioNode defines second node to connect
  85425. */
  85426. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85427. /**
  85428. * Releases all associated resources
  85429. */
  85430. dispose(): void;
  85431. }
  85432. }
  85433. declare module BABYLON {
  85434. /**
  85435. * This represents an audio engine and it is responsible
  85436. * to play, synchronize and analyse sounds throughout the application.
  85437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85438. */
  85439. export interface IAudioEngine extends IDisposable {
  85440. /**
  85441. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85442. */
  85443. readonly canUseWebAudio: boolean;
  85444. /**
  85445. * Gets the current AudioContext if available.
  85446. */
  85447. readonly audioContext: Nullable<AudioContext>;
  85448. /**
  85449. * The master gain node defines the global audio volume of your audio engine.
  85450. */
  85451. readonly masterGain: GainNode;
  85452. /**
  85453. * Gets whether or not mp3 are supported by your browser.
  85454. */
  85455. readonly isMP3supported: boolean;
  85456. /**
  85457. * Gets whether or not ogg are supported by your browser.
  85458. */
  85459. readonly isOGGsupported: boolean;
  85460. /**
  85461. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85462. * @ignoreNaming
  85463. */
  85464. WarnedWebAudioUnsupported: boolean;
  85465. /**
  85466. * Defines if the audio engine relies on a custom unlocked button.
  85467. * In this case, the embedded button will not be displayed.
  85468. */
  85469. useCustomUnlockedButton: boolean;
  85470. /**
  85471. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85472. */
  85473. readonly unlocked: boolean;
  85474. /**
  85475. * Event raised when audio has been unlocked on the browser.
  85476. */
  85477. onAudioUnlockedObservable: Observable<AudioEngine>;
  85478. /**
  85479. * Event raised when audio has been locked on the browser.
  85480. */
  85481. onAudioLockedObservable: Observable<AudioEngine>;
  85482. /**
  85483. * Flags the audio engine in Locked state.
  85484. * This happens due to new browser policies preventing audio to autoplay.
  85485. */
  85486. lock(): void;
  85487. /**
  85488. * Unlocks the audio engine once a user action has been done on the dom.
  85489. * This is helpful to resume play once browser policies have been satisfied.
  85490. */
  85491. unlock(): void;
  85492. }
  85493. /**
  85494. * This represents the default audio engine used in babylon.
  85495. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85497. */
  85498. export class AudioEngine implements IAudioEngine {
  85499. private _audioContext;
  85500. private _audioContextInitialized;
  85501. private _muteButton;
  85502. private _hostElement;
  85503. /**
  85504. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85505. */
  85506. canUseWebAudio: boolean;
  85507. /**
  85508. * The master gain node defines the global audio volume of your audio engine.
  85509. */
  85510. masterGain: GainNode;
  85511. /**
  85512. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85513. * @ignoreNaming
  85514. */
  85515. WarnedWebAudioUnsupported: boolean;
  85516. /**
  85517. * Gets whether or not mp3 are supported by your browser.
  85518. */
  85519. isMP3supported: boolean;
  85520. /**
  85521. * Gets whether or not ogg are supported by your browser.
  85522. */
  85523. isOGGsupported: boolean;
  85524. /**
  85525. * Gets whether audio has been unlocked on the device.
  85526. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85527. * a user interaction has happened.
  85528. */
  85529. unlocked: boolean;
  85530. /**
  85531. * Defines if the audio engine relies on a custom unlocked button.
  85532. * In this case, the embedded button will not be displayed.
  85533. */
  85534. useCustomUnlockedButton: boolean;
  85535. /**
  85536. * Event raised when audio has been unlocked on the browser.
  85537. */
  85538. onAudioUnlockedObservable: Observable<AudioEngine>;
  85539. /**
  85540. * Event raised when audio has been locked on the browser.
  85541. */
  85542. onAudioLockedObservable: Observable<AudioEngine>;
  85543. /**
  85544. * Gets the current AudioContext if available.
  85545. */
  85546. readonly audioContext: Nullable<AudioContext>;
  85547. private _connectedAnalyser;
  85548. /**
  85549. * Instantiates a new audio engine.
  85550. *
  85551. * There should be only one per page as some browsers restrict the number
  85552. * of audio contexts you can create.
  85553. * @param hostElement defines the host element where to display the mute icon if necessary
  85554. */
  85555. constructor(hostElement?: Nullable<HTMLElement>);
  85556. /**
  85557. * Flags the audio engine in Locked state.
  85558. * This happens due to new browser policies preventing audio to autoplay.
  85559. */
  85560. lock(): void;
  85561. /**
  85562. * Unlocks the audio engine once a user action has been done on the dom.
  85563. * This is helpful to resume play once browser policies have been satisfied.
  85564. */
  85565. unlock(): void;
  85566. private _resumeAudioContext;
  85567. private _initializeAudioContext;
  85568. private _tryToRun;
  85569. private _triggerRunningState;
  85570. private _triggerSuspendedState;
  85571. private _displayMuteButton;
  85572. private _moveButtonToTopLeft;
  85573. private _onResize;
  85574. private _hideMuteButton;
  85575. /**
  85576. * Destroy and release the resources associated with the audio ccontext.
  85577. */
  85578. dispose(): void;
  85579. /**
  85580. * Gets the global volume sets on the master gain.
  85581. * @returns the global volume if set or -1 otherwise
  85582. */
  85583. getGlobalVolume(): number;
  85584. /**
  85585. * Sets the global volume of your experience (sets on the master gain).
  85586. * @param newVolume Defines the new global volume of the application
  85587. */
  85588. setGlobalVolume(newVolume: number): void;
  85589. /**
  85590. * Connect the audio engine to an audio analyser allowing some amazing
  85591. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85593. * @param analyser The analyser to connect to the engine
  85594. */
  85595. connectToAnalyser(analyser: Analyser): void;
  85596. }
  85597. }
  85598. declare module BABYLON {
  85599. /**
  85600. * Interface used to present a loading screen while loading a scene
  85601. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85602. */
  85603. export interface ILoadingScreen {
  85604. /**
  85605. * Function called to display the loading screen
  85606. */
  85607. displayLoadingUI: () => void;
  85608. /**
  85609. * Function called to hide the loading screen
  85610. */
  85611. hideLoadingUI: () => void;
  85612. /**
  85613. * Gets or sets the color to use for the background
  85614. */
  85615. loadingUIBackgroundColor: string;
  85616. /**
  85617. * Gets or sets the text to display while loading
  85618. */
  85619. loadingUIText: string;
  85620. }
  85621. /**
  85622. * Class used for the default loading screen
  85623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85624. */
  85625. export class DefaultLoadingScreen implements ILoadingScreen {
  85626. private _renderingCanvas;
  85627. private _loadingText;
  85628. private _loadingDivBackgroundColor;
  85629. private _loadingDiv;
  85630. private _loadingTextDiv;
  85631. /**
  85632. * Creates a new default loading screen
  85633. * @param _renderingCanvas defines the canvas used to render the scene
  85634. * @param _loadingText defines the default text to display
  85635. * @param _loadingDivBackgroundColor defines the default background color
  85636. */
  85637. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85638. /**
  85639. * Function called to display the loading screen
  85640. */
  85641. displayLoadingUI(): void;
  85642. /**
  85643. * Function called to hide the loading screen
  85644. */
  85645. hideLoadingUI(): void;
  85646. /**
  85647. * Gets or sets the text to display while loading
  85648. */
  85649. loadingUIText: string;
  85650. /**
  85651. * Gets or sets the color to use for the background
  85652. */
  85653. loadingUIBackgroundColor: string;
  85654. private _resizeLoadingUI;
  85655. }
  85656. }
  85657. declare module BABYLON {
  85658. /**
  85659. * Settings for finer control over video usage
  85660. */
  85661. export interface VideoTextureSettings {
  85662. /**
  85663. * Applies `autoplay` to video, if specified
  85664. */
  85665. autoPlay?: boolean;
  85666. /**
  85667. * Applies `loop` to video, if specified
  85668. */
  85669. loop?: boolean;
  85670. /**
  85671. * Automatically updates internal texture from video at every frame in the render loop
  85672. */
  85673. autoUpdateTexture: boolean;
  85674. /**
  85675. * Image src displayed during the video loading or until the user interacts with the video.
  85676. */
  85677. poster?: string;
  85678. }
  85679. /**
  85680. * If you want to display a video in your scene, this is the special texture for that.
  85681. * This special texture works similar to other textures, with the exception of a few parameters.
  85682. * @see https://doc.babylonjs.com/how_to/video_texture
  85683. */
  85684. export class VideoTexture extends Texture {
  85685. /**
  85686. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85687. */
  85688. readonly autoUpdateTexture: boolean;
  85689. /**
  85690. * The video instance used by the texture internally
  85691. */
  85692. readonly video: HTMLVideoElement;
  85693. private _onUserActionRequestedObservable;
  85694. /**
  85695. * Event triggerd when a dom action is required by the user to play the video.
  85696. * This happens due to recent changes in browser policies preventing video to auto start.
  85697. */
  85698. readonly onUserActionRequestedObservable: Observable<Texture>;
  85699. private _generateMipMaps;
  85700. private _engine;
  85701. private _stillImageCaptured;
  85702. private _displayingPosterTexture;
  85703. private _settings;
  85704. private _createInternalTextureOnEvent;
  85705. /**
  85706. * Creates a video texture.
  85707. * If you want to display a video in your scene, this is the special texture for that.
  85708. * This special texture works similar to other textures, with the exception of a few parameters.
  85709. * @see https://doc.babylonjs.com/how_to/video_texture
  85710. * @param name optional name, will detect from video source, if not defined
  85711. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85712. * @param scene is obviously the current scene.
  85713. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85714. * @param invertY is false by default but can be used to invert video on Y axis
  85715. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85716. * @param settings allows finer control over video usage
  85717. */
  85718. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85719. private _getName;
  85720. private _getVideo;
  85721. private _createInternalTexture;
  85722. private reset;
  85723. /**
  85724. * @hidden Internal method to initiate `update`.
  85725. */
  85726. _rebuild(): void;
  85727. /**
  85728. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85729. */
  85730. update(): void;
  85731. /**
  85732. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85733. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85734. */
  85735. updateTexture(isVisible: boolean): void;
  85736. protected _updateInternalTexture: () => void;
  85737. /**
  85738. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85739. * @param url New url.
  85740. */
  85741. updateURL(url: string): void;
  85742. /**
  85743. * Dispose the texture and release its associated resources.
  85744. */
  85745. dispose(): void;
  85746. /**
  85747. * Creates a video texture straight from a stream.
  85748. * @param scene Define the scene the texture should be created in
  85749. * @param stream Define the stream the texture should be created from
  85750. * @returns The created video texture as a promise
  85751. */
  85752. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  85753. /**
  85754. * Creates a video texture straight from your WebCam video feed.
  85755. * @param scene Define the scene the texture should be created in
  85756. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85757. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85758. * @returns The created video texture as a promise
  85759. */
  85760. static CreateFromWebCamAsync(scene: Scene, constraints: {
  85761. minWidth: number;
  85762. maxWidth: number;
  85763. minHeight: number;
  85764. maxHeight: number;
  85765. deviceId: string;
  85766. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  85767. /**
  85768. * Creates a video texture straight from your WebCam video feed.
  85769. * @param scene Define the scene the texture should be created in
  85770. * @param onReady Define a callback to triggered once the texture will be ready
  85771. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85772. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85773. */
  85774. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85775. minWidth: number;
  85776. maxWidth: number;
  85777. minHeight: number;
  85778. maxHeight: number;
  85779. deviceId: string;
  85780. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85781. }
  85782. }
  85783. declare module BABYLON {
  85784. /**
  85785. * Interface for attribute information associated with buffer instanciation
  85786. */
  85787. export class InstancingAttributeInfo {
  85788. /**
  85789. * Index/offset of the attribute in the vertex shader
  85790. */
  85791. index: number;
  85792. /**
  85793. * size of the attribute, 1, 2, 3 or 4
  85794. */
  85795. attributeSize: number;
  85796. /**
  85797. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85798. * default is FLOAT
  85799. */
  85800. attribyteType: number;
  85801. /**
  85802. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85803. */
  85804. normalized: boolean;
  85805. /**
  85806. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85807. */
  85808. offset: number;
  85809. /**
  85810. * Name of the GLSL attribute, for debugging purpose only
  85811. */
  85812. attributeName: string;
  85813. }
  85814. /**
  85815. * Define options used to create a depth texture
  85816. */
  85817. export class DepthTextureCreationOptions {
  85818. /** Specifies whether or not a stencil should be allocated in the texture */
  85819. generateStencil?: boolean;
  85820. /** Specifies whether or not bilinear filtering is enable on the texture */
  85821. bilinearFiltering?: boolean;
  85822. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85823. comparisonFunction?: number;
  85824. /** Specifies if the created texture is a cube texture */
  85825. isCube?: boolean;
  85826. }
  85827. /**
  85828. * Class used to describe the capabilities of the engine relatively to the current browser
  85829. */
  85830. export class EngineCapabilities {
  85831. /** Maximum textures units per fragment shader */
  85832. maxTexturesImageUnits: number;
  85833. /** Maximum texture units per vertex shader */
  85834. maxVertexTextureImageUnits: number;
  85835. /** Maximum textures units in the entire pipeline */
  85836. maxCombinedTexturesImageUnits: number;
  85837. /** Maximum texture size */
  85838. maxTextureSize: number;
  85839. /** Maximum cube texture size */
  85840. maxCubemapTextureSize: number;
  85841. /** Maximum render texture size */
  85842. maxRenderTextureSize: number;
  85843. /** Maximum number of vertex attributes */
  85844. maxVertexAttribs: number;
  85845. /** Maximum number of varyings */
  85846. maxVaryingVectors: number;
  85847. /** Maximum number of uniforms per vertex shader */
  85848. maxVertexUniformVectors: number;
  85849. /** Maximum number of uniforms per fragment shader */
  85850. maxFragmentUniformVectors: number;
  85851. /** Defines if standard derivates (dx/dy) are supported */
  85852. standardDerivatives: boolean;
  85853. /** Defines if s3tc texture compression is supported */
  85854. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85855. /** Defines if pvrtc texture compression is supported */
  85856. pvrtc: any;
  85857. /** Defines if etc1 texture compression is supported */
  85858. etc1: any;
  85859. /** Defines if etc2 texture compression is supported */
  85860. etc2: any;
  85861. /** Defines if astc texture compression is supported */
  85862. astc: any;
  85863. /** Defines if float textures are supported */
  85864. textureFloat: boolean;
  85865. /** Defines if vertex array objects are supported */
  85866. vertexArrayObject: boolean;
  85867. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85868. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85869. /** Gets the maximum level of anisotropy supported */
  85870. maxAnisotropy: number;
  85871. /** Defines if instancing is supported */
  85872. instancedArrays: boolean;
  85873. /** Defines if 32 bits indices are supported */
  85874. uintIndices: boolean;
  85875. /** Defines if high precision shaders are supported */
  85876. highPrecisionShaderSupported: boolean;
  85877. /** Defines if depth reading in the fragment shader is supported */
  85878. fragmentDepthSupported: boolean;
  85879. /** Defines if float texture linear filtering is supported*/
  85880. textureFloatLinearFiltering: boolean;
  85881. /** Defines if rendering to float textures is supported */
  85882. textureFloatRender: boolean;
  85883. /** Defines if half float textures are supported*/
  85884. textureHalfFloat: boolean;
  85885. /** Defines if half float texture linear filtering is supported*/
  85886. textureHalfFloatLinearFiltering: boolean;
  85887. /** Defines if rendering to half float textures is supported */
  85888. textureHalfFloatRender: boolean;
  85889. /** Defines if textureLOD shader command is supported */
  85890. textureLOD: boolean;
  85891. /** Defines if draw buffers extension is supported */
  85892. drawBuffersExtension: boolean;
  85893. /** Defines if depth textures are supported */
  85894. depthTextureExtension: boolean;
  85895. /** Defines if float color buffer are supported */
  85896. colorBufferFloat: boolean;
  85897. /** Gets disjoint timer query extension (null if not supported) */
  85898. timerQuery: EXT_disjoint_timer_query;
  85899. /** Defines if timestamp can be used with timer query */
  85900. canUseTimestampForTimerQuery: boolean;
  85901. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  85902. multiview: any;
  85903. /** Function used to let the system compiles shaders in background */
  85904. parallelShaderCompile: {
  85905. COMPLETION_STATUS_KHR: number;
  85906. };
  85907. }
  85908. /** Interface defining initialization parameters for Engine class */
  85909. export interface EngineOptions extends WebGLContextAttributes {
  85910. /**
  85911. * Defines if the engine should no exceed a specified device ratio
  85912. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85913. */
  85914. limitDeviceRatio?: number;
  85915. /**
  85916. * Defines if webvr should be enabled automatically
  85917. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85918. */
  85919. autoEnableWebVR?: boolean;
  85920. /**
  85921. * Defines if webgl2 should be turned off even if supported
  85922. * @see http://doc.babylonjs.com/features/webgl2
  85923. */
  85924. disableWebGL2Support?: boolean;
  85925. /**
  85926. * Defines if webaudio should be initialized as well
  85927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85928. */
  85929. audioEngine?: boolean;
  85930. /**
  85931. * Defines if animations should run using a deterministic lock step
  85932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85933. */
  85934. deterministicLockstep?: boolean;
  85935. /** Defines the maximum steps to use with deterministic lock step mode */
  85936. lockstepMaxSteps?: number;
  85937. /**
  85938. * Defines that engine should ignore context lost events
  85939. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85940. */
  85941. doNotHandleContextLost?: boolean;
  85942. /**
  85943. * Defines that engine should ignore modifying touch action attribute and style
  85944. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85945. */
  85946. doNotHandleTouchAction?: boolean;
  85947. /**
  85948. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85949. */
  85950. useHighPrecisionFloats?: boolean;
  85951. }
  85952. /**
  85953. * Defines the interface used by display changed events
  85954. */
  85955. export interface IDisplayChangedEventArgs {
  85956. /** Gets the vrDisplay object (if any) */
  85957. vrDisplay: Nullable<any>;
  85958. /** Gets a boolean indicating if webVR is supported */
  85959. vrSupported: boolean;
  85960. }
  85961. /**
  85962. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85963. */
  85964. export class Engine {
  85965. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85966. static ExceptionList: ({
  85967. key: string;
  85968. capture: string;
  85969. captureConstraint: number;
  85970. targets: string[];
  85971. } | {
  85972. key: string;
  85973. capture: null;
  85974. captureConstraint: null;
  85975. targets: string[];
  85976. })[];
  85977. /** Gets the list of created engines */
  85978. static readonly Instances: Engine[];
  85979. /**
  85980. * Gets the latest created engine
  85981. */
  85982. static readonly LastCreatedEngine: Nullable<Engine>;
  85983. /**
  85984. * Gets the latest created scene
  85985. */
  85986. static readonly LastCreatedScene: Nullable<Scene>;
  85987. /**
  85988. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85989. * @param flag defines which part of the materials must be marked as dirty
  85990. * @param predicate defines a predicate used to filter which materials should be affected
  85991. */
  85992. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85993. /**
  85994. * Hidden
  85995. */
  85996. static _TextureLoaders: IInternalTextureLoader[];
  85997. /** Defines that alpha blending is disabled */
  85998. static readonly ALPHA_DISABLE: number;
  85999. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86000. static readonly ALPHA_ADD: number;
  86001. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86002. static readonly ALPHA_COMBINE: number;
  86003. /** Defines that alpha blending to DEST - SRC * DEST */
  86004. static readonly ALPHA_SUBTRACT: number;
  86005. /** Defines that alpha blending to SRC * DEST */
  86006. static readonly ALPHA_MULTIPLY: number;
  86007. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86008. static readonly ALPHA_MAXIMIZED: number;
  86009. /** Defines that alpha blending to SRC + DEST */
  86010. static readonly ALPHA_ONEONE: number;
  86011. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86012. static readonly ALPHA_PREMULTIPLIED: number;
  86013. /**
  86014. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86015. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86016. */
  86017. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86018. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86019. static readonly ALPHA_INTERPOLATE: number;
  86020. /**
  86021. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86022. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86023. */
  86024. static readonly ALPHA_SCREENMODE: number;
  86025. /** Defines that the ressource is not delayed*/
  86026. static readonly DELAYLOADSTATE_NONE: number;
  86027. /** Defines that the ressource was successfully delay loaded */
  86028. static readonly DELAYLOADSTATE_LOADED: number;
  86029. /** Defines that the ressource is currently delay loading */
  86030. static readonly DELAYLOADSTATE_LOADING: number;
  86031. /** Defines that the ressource is delayed and has not started loading */
  86032. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86033. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86034. static readonly NEVER: number;
  86035. /** 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 */
  86036. static readonly ALWAYS: number;
  86037. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86038. static readonly LESS: number;
  86039. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86040. static readonly EQUAL: number;
  86041. /** 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 */
  86042. static readonly LEQUAL: number;
  86043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86044. static readonly GREATER: number;
  86045. /** 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 */
  86046. static readonly GEQUAL: number;
  86047. /** 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 */
  86048. static readonly NOTEQUAL: number;
  86049. /** Passed to stencilOperation to specify that stencil value must be kept */
  86050. static readonly KEEP: number;
  86051. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86052. static readonly REPLACE: number;
  86053. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86054. static readonly INCR: number;
  86055. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86056. static readonly DECR: number;
  86057. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86058. static readonly INVERT: number;
  86059. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86060. static readonly INCR_WRAP: number;
  86061. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86062. static readonly DECR_WRAP: number;
  86063. /** Texture is not repeating outside of 0..1 UVs */
  86064. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86065. /** Texture is repeating outside of 0..1 UVs */
  86066. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86067. /** Texture is repeating and mirrored */
  86068. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86069. /** ALPHA */
  86070. static readonly TEXTUREFORMAT_ALPHA: number;
  86071. /** LUMINANCE */
  86072. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86073. /** LUMINANCE_ALPHA */
  86074. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86075. /** RGB */
  86076. static readonly TEXTUREFORMAT_RGB: number;
  86077. /** RGBA */
  86078. static readonly TEXTUREFORMAT_RGBA: number;
  86079. /** RED */
  86080. static readonly TEXTUREFORMAT_RED: number;
  86081. /** RED (2nd reference) */
  86082. static readonly TEXTUREFORMAT_R: number;
  86083. /** RG */
  86084. static readonly TEXTUREFORMAT_RG: number;
  86085. /** RED_INTEGER */
  86086. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86087. /** RED_INTEGER (2nd reference) */
  86088. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86089. /** RG_INTEGER */
  86090. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86091. /** RGB_INTEGER */
  86092. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86093. /** RGBA_INTEGER */
  86094. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86095. /** UNSIGNED_BYTE */
  86096. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86097. /** UNSIGNED_BYTE (2nd reference) */
  86098. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86099. /** FLOAT */
  86100. static readonly TEXTURETYPE_FLOAT: number;
  86101. /** HALF_FLOAT */
  86102. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86103. /** BYTE */
  86104. static readonly TEXTURETYPE_BYTE: number;
  86105. /** SHORT */
  86106. static readonly TEXTURETYPE_SHORT: number;
  86107. /** UNSIGNED_SHORT */
  86108. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86109. /** INT */
  86110. static readonly TEXTURETYPE_INT: number;
  86111. /** UNSIGNED_INT */
  86112. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86113. /** UNSIGNED_SHORT_4_4_4_4 */
  86114. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86115. /** UNSIGNED_SHORT_5_5_5_1 */
  86116. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86117. /** UNSIGNED_SHORT_5_6_5 */
  86118. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86119. /** UNSIGNED_INT_2_10_10_10_REV */
  86120. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86121. /** UNSIGNED_INT_24_8 */
  86122. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86123. /** UNSIGNED_INT_10F_11F_11F_REV */
  86124. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86125. /** UNSIGNED_INT_5_9_9_9_REV */
  86126. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86127. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86128. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86129. /** nearest is mag = nearest and min = nearest and mip = linear */
  86130. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86131. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86132. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86133. /** Trilinear is mag = linear and min = linear and mip = linear */
  86134. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86135. /** nearest is mag = nearest and min = nearest and mip = linear */
  86136. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86137. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86138. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86139. /** Trilinear is mag = linear and min = linear and mip = linear */
  86140. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86141. /** mag = nearest and min = nearest and mip = nearest */
  86142. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86143. /** mag = nearest and min = linear and mip = nearest */
  86144. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86145. /** mag = nearest and min = linear and mip = linear */
  86146. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86147. /** mag = nearest and min = linear and mip = none */
  86148. static readonly TEXTURE_NEAREST_LINEAR: number;
  86149. /** mag = nearest and min = nearest and mip = none */
  86150. static readonly TEXTURE_NEAREST_NEAREST: number;
  86151. /** mag = linear and min = nearest and mip = nearest */
  86152. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86153. /** mag = linear and min = nearest and mip = linear */
  86154. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86155. /** mag = linear and min = linear and mip = none */
  86156. static readonly TEXTURE_LINEAR_LINEAR: number;
  86157. /** mag = linear and min = nearest and mip = none */
  86158. static readonly TEXTURE_LINEAR_NEAREST: number;
  86159. /** Explicit coordinates mode */
  86160. static readonly TEXTURE_EXPLICIT_MODE: number;
  86161. /** Spherical coordinates mode */
  86162. static readonly TEXTURE_SPHERICAL_MODE: number;
  86163. /** Planar coordinates mode */
  86164. static readonly TEXTURE_PLANAR_MODE: number;
  86165. /** Cubic coordinates mode */
  86166. static readonly TEXTURE_CUBIC_MODE: number;
  86167. /** Projection coordinates mode */
  86168. static readonly TEXTURE_PROJECTION_MODE: number;
  86169. /** Skybox coordinates mode */
  86170. static readonly TEXTURE_SKYBOX_MODE: number;
  86171. /** Inverse Cubic coordinates mode */
  86172. static readonly TEXTURE_INVCUBIC_MODE: number;
  86173. /** Equirectangular coordinates mode */
  86174. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86175. /** Equirectangular Fixed coordinates mode */
  86176. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86177. /** Equirectangular Fixed Mirrored coordinates mode */
  86178. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86179. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86180. static readonly SCALEMODE_FLOOR: number;
  86181. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86182. static readonly SCALEMODE_NEAREST: number;
  86183. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86184. static readonly SCALEMODE_CEILING: number;
  86185. /**
  86186. * Returns the current npm package of the sdk
  86187. */
  86188. static readonly NpmPackage: string;
  86189. /**
  86190. * Returns the current version of the framework
  86191. */
  86192. static readonly Version: string;
  86193. /**
  86194. * Returns a string describing the current engine
  86195. */
  86196. readonly description: string;
  86197. /**
  86198. * Gets or sets the epsilon value used by collision engine
  86199. */
  86200. static CollisionsEpsilon: number;
  86201. /**
  86202. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86203. */
  86204. static ShadersRepository: string;
  86205. /**
  86206. * Method called to create the default loading screen.
  86207. * This can be overriden in your own app.
  86208. * @param canvas The rendering canvas element
  86209. * @returns The loading screen
  86210. */
  86211. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86212. /**
  86213. * Method called to create the default rescale post process on each engine.
  86214. */
  86215. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86216. /**
  86217. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86218. */
  86219. forcePOTTextures: boolean;
  86220. /**
  86221. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86222. */
  86223. isFullscreen: boolean;
  86224. /**
  86225. * Gets a boolean indicating if the pointer is currently locked
  86226. */
  86227. isPointerLock: boolean;
  86228. /**
  86229. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86230. */
  86231. cullBackFaces: boolean;
  86232. /**
  86233. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86234. */
  86235. renderEvenInBackground: boolean;
  86236. /**
  86237. * Gets or sets a boolean indicating that cache can be kept between frames
  86238. */
  86239. preventCacheWipeBetweenFrames: boolean;
  86240. /**
  86241. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86242. **/
  86243. enableOfflineSupport: boolean;
  86244. /**
  86245. * 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)
  86246. **/
  86247. disableManifestCheck: boolean;
  86248. /**
  86249. * Gets the list of created scenes
  86250. */
  86251. scenes: Scene[];
  86252. /**
  86253. * Event raised when a new scene is created
  86254. */
  86255. onNewSceneAddedObservable: Observable<Scene>;
  86256. /**
  86257. * Gets the list of created postprocesses
  86258. */
  86259. postProcesses: PostProcess[];
  86260. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86261. validateShaderPrograms: boolean;
  86262. /**
  86263. * Observable event triggered each time the rendering canvas is resized
  86264. */
  86265. onResizeObservable: Observable<Engine>;
  86266. /**
  86267. * Observable event triggered each time the canvas loses focus
  86268. */
  86269. onCanvasBlurObservable: Observable<Engine>;
  86270. /**
  86271. * Observable event triggered each time the canvas gains focus
  86272. */
  86273. onCanvasFocusObservable: Observable<Engine>;
  86274. /**
  86275. * Observable event triggered each time the canvas receives pointerout event
  86276. */
  86277. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86278. /**
  86279. * Observable event triggered before each texture is initialized
  86280. */
  86281. onBeforeTextureInitObservable: Observable<Texture>;
  86282. private _vrDisplay;
  86283. private _vrSupported;
  86284. private _oldSize;
  86285. private _oldHardwareScaleFactor;
  86286. private _vrExclusivePointerMode;
  86287. private _webVRInitPromise;
  86288. /**
  86289. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86290. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86291. */
  86292. readonly isInVRExclusivePointerMode: boolean;
  86293. /**
  86294. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86295. */
  86296. disableUniformBuffers: boolean;
  86297. /** @hidden */
  86298. _uniformBuffers: UniformBuffer[];
  86299. /**
  86300. * Gets a boolean indicating that the engine supports uniform buffers
  86301. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86302. */
  86303. readonly supportsUniformBuffers: boolean;
  86304. /**
  86305. * Observable raised when the engine begins a new frame
  86306. */
  86307. onBeginFrameObservable: Observable<Engine>;
  86308. /**
  86309. * If set, will be used to request the next animation frame for the render loop
  86310. */
  86311. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86312. /**
  86313. * Observable raised when the engine ends the current frame
  86314. */
  86315. onEndFrameObservable: Observable<Engine>;
  86316. /**
  86317. * Observable raised when the engine is about to compile a shader
  86318. */
  86319. onBeforeShaderCompilationObservable: Observable<Engine>;
  86320. /**
  86321. * Observable raised when the engine has jsut compiled a shader
  86322. */
  86323. onAfterShaderCompilationObservable: Observable<Engine>;
  86324. /** @hidden */
  86325. _gl: WebGLRenderingContext;
  86326. private _renderingCanvas;
  86327. private _windowIsBackground;
  86328. private _webGLVersion;
  86329. protected _highPrecisionShadersAllowed: boolean;
  86330. /** @hidden */
  86331. readonly _shouldUseHighPrecisionShader: boolean;
  86332. /**
  86333. * Gets a boolean indicating that only power of 2 textures are supported
  86334. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86335. */
  86336. readonly needPOTTextures: boolean;
  86337. /** @hidden */
  86338. _badOS: boolean;
  86339. /** @hidden */
  86340. _badDesktopOS: boolean;
  86341. /**
  86342. * Gets or sets a value indicating if we want to disable texture binding optimization.
  86343. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  86344. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  86345. */
  86346. disableTextureBindingOptimization: boolean;
  86347. /**
  86348. * Gets the audio engine
  86349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86350. * @ignorenaming
  86351. */
  86352. static audioEngine: IAudioEngine;
  86353. /**
  86354. * Default AudioEngine factory responsible of creating the Audio Engine.
  86355. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86356. */
  86357. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86358. /**
  86359. * Default offline support factory responsible of creating a tool used to store data locally.
  86360. * By default, this will create a Database object if the workload has been embedded.
  86361. */
  86362. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86363. private _onFocus;
  86364. private _onBlur;
  86365. private _onCanvasPointerOut;
  86366. private _onCanvasBlur;
  86367. private _onCanvasFocus;
  86368. private _onFullscreenChange;
  86369. private _onPointerLockChange;
  86370. private _onVRDisplayPointerRestricted;
  86371. private _onVRDisplayPointerUnrestricted;
  86372. private _onVrDisplayConnect;
  86373. private _onVrDisplayDisconnect;
  86374. private _onVrDisplayPresentChange;
  86375. /**
  86376. * Observable signaled when VR display mode changes
  86377. */
  86378. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86379. /**
  86380. * Observable signaled when VR request present is complete
  86381. */
  86382. onVRRequestPresentComplete: Observable<boolean>;
  86383. /**
  86384. * Observable signaled when VR request present starts
  86385. */
  86386. onVRRequestPresentStart: Observable<Engine>;
  86387. private _hardwareScalingLevel;
  86388. /** @hidden */
  86389. protected _caps: EngineCapabilities;
  86390. private _pointerLockRequested;
  86391. private _isStencilEnable;
  86392. private _colorWrite;
  86393. private _loadingScreen;
  86394. /** @hidden */
  86395. _drawCalls: PerfCounter;
  86396. /** @hidden */
  86397. _textureCollisions: PerfCounter;
  86398. private _glVersion;
  86399. private _glRenderer;
  86400. private _glVendor;
  86401. private _videoTextureSupported;
  86402. private _renderingQueueLaunched;
  86403. private _activeRenderLoops;
  86404. private _deterministicLockstep;
  86405. private _lockstepMaxSteps;
  86406. /**
  86407. * Observable signaled when a context lost event is raised
  86408. */
  86409. onContextLostObservable: Observable<Engine>;
  86410. /**
  86411. * Observable signaled when a context restored event is raised
  86412. */
  86413. onContextRestoredObservable: Observable<Engine>;
  86414. private _onContextLost;
  86415. private _onContextRestored;
  86416. private _contextWasLost;
  86417. private _doNotHandleContextLost;
  86418. /**
  86419. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86421. */
  86422. doNotHandleContextLost: boolean;
  86423. private _performanceMonitor;
  86424. private _fps;
  86425. private _deltaTime;
  86426. /**
  86427. * Turn this value on if you want to pause FPS computation when in background
  86428. */
  86429. disablePerformanceMonitorInBackground: boolean;
  86430. /**
  86431. * Gets the performance monitor attached to this engine
  86432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86433. */
  86434. readonly performanceMonitor: PerformanceMonitor;
  86435. /**
  86436. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86437. */
  86438. disableVertexArrayObjects: boolean;
  86439. /** @hidden */
  86440. protected _depthCullingState: _DepthCullingState;
  86441. /** @hidden */
  86442. protected _stencilState: _StencilState;
  86443. /** @hidden */
  86444. protected _alphaState: _AlphaState;
  86445. /** @hidden */
  86446. protected _alphaMode: number;
  86447. protected _internalTexturesCache: InternalTexture[];
  86448. /** @hidden */
  86449. protected _activeChannel: number;
  86450. private _currentTextureChannel;
  86451. /** @hidden */
  86452. protected _boundTexturesCache: {
  86453. [key: string]: Nullable<InternalTexture>;
  86454. };
  86455. /** @hidden */
  86456. protected _currentEffect: Nullable<Effect>;
  86457. /** @hidden */
  86458. protected _currentProgram: Nullable<WebGLProgram>;
  86459. private _compiledEffects;
  86460. private _vertexAttribArraysEnabled;
  86461. /** @hidden */
  86462. protected _cachedViewport: Nullable<Viewport>;
  86463. private _cachedVertexArrayObject;
  86464. /** @hidden */
  86465. protected _cachedVertexBuffers: any;
  86466. /** @hidden */
  86467. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86468. /** @hidden */
  86469. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86470. /** @hidden */
  86471. protected _currentRenderTarget: Nullable<InternalTexture>;
  86472. private _uintIndicesCurrentlySet;
  86473. private _currentBoundBuffer;
  86474. /** @hidden */
  86475. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86476. private _currentBufferPointers;
  86477. private _currentInstanceLocations;
  86478. private _currentInstanceBuffers;
  86479. private _textureUnits;
  86480. private _firstBoundInternalTextureTracker;
  86481. private _lastBoundInternalTextureTracker;
  86482. private _workingCanvas;
  86483. private _workingContext;
  86484. private _rescalePostProcess;
  86485. private _dummyFramebuffer;
  86486. private _externalData;
  86487. private _bindedRenderFunction;
  86488. private _vaoRecordInProgress;
  86489. private _mustWipeVertexAttributes;
  86490. private _emptyTexture;
  86491. private _emptyCubeTexture;
  86492. private _emptyTexture3D;
  86493. /** @hidden */
  86494. _frameHandler: number;
  86495. private _nextFreeTextureSlots;
  86496. private _maxSimultaneousTextures;
  86497. private _activeRequests;
  86498. private _texturesSupported;
  86499. private _textureFormatInUse;
  86500. /**
  86501. * Gets the list of texture formats supported
  86502. */
  86503. readonly texturesSupported: Array<string>;
  86504. /**
  86505. * Gets the list of texture formats in use
  86506. */
  86507. readonly textureFormatInUse: Nullable<string>;
  86508. /**
  86509. * Gets the current viewport
  86510. */
  86511. readonly currentViewport: Nullable<Viewport>;
  86512. /**
  86513. * Gets the default empty texture
  86514. */
  86515. readonly emptyTexture: InternalTexture;
  86516. /**
  86517. * Gets the default empty 3D texture
  86518. */
  86519. readonly emptyTexture3D: InternalTexture;
  86520. /**
  86521. * Gets the default empty cube texture
  86522. */
  86523. readonly emptyCubeTexture: InternalTexture;
  86524. /**
  86525. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86526. */
  86527. readonly premultipliedAlpha: boolean;
  86528. /**
  86529. * Creates a new engine
  86530. * @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
  86531. * @param antialias defines enable antialiasing (default: false)
  86532. * @param options defines further options to be sent to the getContext() function
  86533. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86534. */
  86535. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86536. private _disableTouchAction;
  86537. private _rebuildInternalTextures;
  86538. private _rebuildEffects;
  86539. /**
  86540. * Gets a boolean indicating if all created effects are ready
  86541. * @returns true if all effects are ready
  86542. */
  86543. areAllEffectsReady(): boolean;
  86544. private _rebuildBuffers;
  86545. private _initGLContext;
  86546. /**
  86547. * Gets version of the current webGL context
  86548. */
  86549. readonly webGLVersion: number;
  86550. /**
  86551. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86552. */
  86553. readonly isStencilEnable: boolean;
  86554. private _prepareWorkingCanvas;
  86555. /**
  86556. * Reset the texture cache to empty state
  86557. */
  86558. resetTextureCache(): void;
  86559. /**
  86560. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86561. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86562. * @returns true if engine is in deterministic lock step mode
  86563. */
  86564. isDeterministicLockStep(): boolean;
  86565. /**
  86566. * Gets the max steps when engine is running in deterministic lock step
  86567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86568. * @returns the max steps
  86569. */
  86570. getLockstepMaxSteps(): number;
  86571. /**
  86572. * Gets an object containing information about the current webGL context
  86573. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86574. */
  86575. getGlInfo(): {
  86576. vendor: string;
  86577. renderer: string;
  86578. version: string;
  86579. };
  86580. /**
  86581. * Gets current aspect ratio
  86582. * @param camera defines the camera to use to get the aspect ratio
  86583. * @param useScreen defines if screen size must be used (or the current render target if any)
  86584. * @returns a number defining the aspect ratio
  86585. */
  86586. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86587. /**
  86588. * Gets current screen aspect ratio
  86589. * @returns a number defining the aspect ratio
  86590. */
  86591. getScreenAspectRatio(): number;
  86592. /**
  86593. * Gets the current render width
  86594. * @param useScreen defines if screen size must be used (or the current render target if any)
  86595. * @returns a number defining the current render width
  86596. */
  86597. getRenderWidth(useScreen?: boolean): number;
  86598. /**
  86599. * Gets the current render height
  86600. * @param useScreen defines if screen size must be used (or the current render target if any)
  86601. * @returns a number defining the current render height
  86602. */
  86603. getRenderHeight(useScreen?: boolean): number;
  86604. /**
  86605. * Gets the HTML canvas attached with the current webGL context
  86606. * @returns a HTML canvas
  86607. */
  86608. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86609. /**
  86610. * Gets the client rect of the HTML canvas attached with the current webGL context
  86611. * @returns a client rectanglee
  86612. */
  86613. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86614. /**
  86615. * Defines the hardware scaling level.
  86616. * By default the hardware scaling level is computed from the window device ratio.
  86617. * 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.
  86618. * @param level defines the level to use
  86619. */
  86620. setHardwareScalingLevel(level: number): void;
  86621. /**
  86622. * Gets the current hardware scaling level.
  86623. * By default the hardware scaling level is computed from the window device ratio.
  86624. * 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.
  86625. * @returns a number indicating the current hardware scaling level
  86626. */
  86627. getHardwareScalingLevel(): number;
  86628. /**
  86629. * Gets the list of loaded textures
  86630. * @returns an array containing all loaded textures
  86631. */
  86632. getLoadedTexturesCache(): InternalTexture[];
  86633. /**
  86634. * Gets the object containing all engine capabilities
  86635. * @returns the EngineCapabilities object
  86636. */
  86637. getCaps(): EngineCapabilities;
  86638. /**
  86639. * Gets the current depth function
  86640. * @returns a number defining the depth function
  86641. */
  86642. getDepthFunction(): Nullable<number>;
  86643. /**
  86644. * Sets the current depth function
  86645. * @param depthFunc defines the function to use
  86646. */
  86647. setDepthFunction(depthFunc: number): void;
  86648. /**
  86649. * Sets the current depth function to GREATER
  86650. */
  86651. setDepthFunctionToGreater(): void;
  86652. /**
  86653. * Sets the current depth function to GEQUAL
  86654. */
  86655. setDepthFunctionToGreaterOrEqual(): void;
  86656. /**
  86657. * Sets the current depth function to LESS
  86658. */
  86659. setDepthFunctionToLess(): void;
  86660. private _cachedStencilBuffer;
  86661. private _cachedStencilFunction;
  86662. private _cachedStencilMask;
  86663. private _cachedStencilOperationPass;
  86664. private _cachedStencilOperationFail;
  86665. private _cachedStencilOperationDepthFail;
  86666. private _cachedStencilReference;
  86667. /**
  86668. * Caches the the state of the stencil buffer
  86669. */
  86670. cacheStencilState(): void;
  86671. /**
  86672. * Restores the state of the stencil buffer
  86673. */
  86674. restoreStencilState(): void;
  86675. /**
  86676. * Sets the current depth function to LEQUAL
  86677. */
  86678. setDepthFunctionToLessOrEqual(): void;
  86679. /**
  86680. * Gets a boolean indicating if stencil buffer is enabled
  86681. * @returns the current stencil buffer state
  86682. */
  86683. getStencilBuffer(): boolean;
  86684. /**
  86685. * Enable or disable the stencil buffer
  86686. * @param enable defines if the stencil buffer must be enabled or disabled
  86687. */
  86688. setStencilBuffer(enable: boolean): void;
  86689. /**
  86690. * Gets the current stencil mask
  86691. * @returns a number defining the new stencil mask to use
  86692. */
  86693. getStencilMask(): number;
  86694. /**
  86695. * Sets the current stencil mask
  86696. * @param mask defines the new stencil mask to use
  86697. */
  86698. setStencilMask(mask: number): void;
  86699. /**
  86700. * Gets the current stencil function
  86701. * @returns a number defining the stencil function to use
  86702. */
  86703. getStencilFunction(): number;
  86704. /**
  86705. * Gets the current stencil reference value
  86706. * @returns a number defining the stencil reference value to use
  86707. */
  86708. getStencilFunctionReference(): number;
  86709. /**
  86710. * Gets the current stencil mask
  86711. * @returns a number defining the stencil mask to use
  86712. */
  86713. getStencilFunctionMask(): number;
  86714. /**
  86715. * Sets the current stencil function
  86716. * @param stencilFunc defines the new stencil function to use
  86717. */
  86718. setStencilFunction(stencilFunc: number): void;
  86719. /**
  86720. * Sets the current stencil reference
  86721. * @param reference defines the new stencil reference to use
  86722. */
  86723. setStencilFunctionReference(reference: number): void;
  86724. /**
  86725. * Sets the current stencil mask
  86726. * @param mask defines the new stencil mask to use
  86727. */
  86728. setStencilFunctionMask(mask: number): void;
  86729. /**
  86730. * Gets the current stencil operation when stencil fails
  86731. * @returns a number defining stencil operation to use when stencil fails
  86732. */
  86733. getStencilOperationFail(): number;
  86734. /**
  86735. * Gets the current stencil operation when depth fails
  86736. * @returns a number defining stencil operation to use when depth fails
  86737. */
  86738. getStencilOperationDepthFail(): number;
  86739. /**
  86740. * Gets the current stencil operation when stencil passes
  86741. * @returns a number defining stencil operation to use when stencil passes
  86742. */
  86743. getStencilOperationPass(): number;
  86744. /**
  86745. * Sets the stencil operation to use when stencil fails
  86746. * @param operation defines the stencil operation to use when stencil fails
  86747. */
  86748. setStencilOperationFail(operation: number): void;
  86749. /**
  86750. * Sets the stencil operation to use when depth fails
  86751. * @param operation defines the stencil operation to use when depth fails
  86752. */
  86753. setStencilOperationDepthFail(operation: number): void;
  86754. /**
  86755. * Sets the stencil operation to use when stencil passes
  86756. * @param operation defines the stencil operation to use when stencil passes
  86757. */
  86758. setStencilOperationPass(operation: number): void;
  86759. /**
  86760. * Sets a boolean indicating if the dithering state is enabled or disabled
  86761. * @param value defines the dithering state
  86762. */
  86763. setDitheringState(value: boolean): void;
  86764. /**
  86765. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  86766. * @param value defines the rasterizer state
  86767. */
  86768. setRasterizerState(value: boolean): void;
  86769. /**
  86770. * stop executing a render loop function and remove it from the execution array
  86771. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  86772. */
  86773. stopRenderLoop(renderFunction?: () => void): void;
  86774. /** @hidden */
  86775. _renderLoop(): void;
  86776. /**
  86777. * Register and execute a render loop. The engine can have more than one render function
  86778. * @param renderFunction defines the function to continuously execute
  86779. */
  86780. runRenderLoop(renderFunction: () => void): void;
  86781. /**
  86782. * Toggle full screen mode
  86783. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86784. */
  86785. switchFullscreen(requestPointerLock: boolean): void;
  86786. /**
  86787. * Enters full screen mode
  86788. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86789. */
  86790. enterFullscreen(requestPointerLock: boolean): void;
  86791. /**
  86792. * Exits full screen mode
  86793. */
  86794. exitFullscreen(): void;
  86795. /**
  86796. * Clear the current render buffer or the current render target (if any is set up)
  86797. * @param color defines the color to use
  86798. * @param backBuffer defines if the back buffer must be cleared
  86799. * @param depth defines if the depth buffer must be cleared
  86800. * @param stencil defines if the stencil buffer must be cleared
  86801. */
  86802. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86803. /**
  86804. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86805. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86806. * @param y defines the y-coordinate of the corner of the clear rectangle
  86807. * @param width defines the width of the clear rectangle
  86808. * @param height defines the height of the clear rectangle
  86809. * @param clearColor defines the clear color
  86810. */
  86811. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86812. /**
  86813. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86814. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86815. * @param y defines the y-coordinate of the corner of the clear rectangle
  86816. * @param width defines the width of the clear rectangle
  86817. * @param height defines the height of the clear rectangle
  86818. */
  86819. enableScissor(x: number, y: number, width: number, height: number): void;
  86820. /**
  86821. * Disable previously set scissor test rectangle
  86822. */
  86823. disableScissor(): void;
  86824. private _viewportCached;
  86825. /** @hidden */
  86826. _viewport(x: number, y: number, width: number, height: number): void;
  86827. /**
  86828. * Set the WebGL's viewport
  86829. * @param viewport defines the viewport element to be used
  86830. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86831. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86832. */
  86833. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86834. /**
  86835. * Directly set the WebGL Viewport
  86836. * @param x defines the x coordinate of the viewport (in screen space)
  86837. * @param y defines the y coordinate of the viewport (in screen space)
  86838. * @param width defines the width of the viewport (in screen space)
  86839. * @param height defines the height of the viewport (in screen space)
  86840. * @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
  86841. */
  86842. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86843. /**
  86844. * Begin a new frame
  86845. */
  86846. beginFrame(): void;
  86847. /**
  86848. * Enf the current frame
  86849. */
  86850. endFrame(): void;
  86851. /**
  86852. * Resize the view according to the canvas' size
  86853. */
  86854. resize(): void;
  86855. /**
  86856. * Force a specific size of the canvas
  86857. * @param width defines the new canvas' width
  86858. * @param height defines the new canvas' height
  86859. */
  86860. setSize(width: number, height: number): void;
  86861. /**
  86862. * Gets a boolean indicating if a webVR device was detected
  86863. * @returns true if a webVR device was detected
  86864. */
  86865. isVRDevicePresent(): boolean;
  86866. /**
  86867. * Gets the current webVR device
  86868. * @returns the current webVR device (or null)
  86869. */
  86870. getVRDevice(): any;
  86871. /**
  86872. * Initializes a webVR display and starts listening to display change events
  86873. * The onVRDisplayChangedObservable will be notified upon these changes
  86874. * @returns The onVRDisplayChangedObservable
  86875. */
  86876. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86877. /**
  86878. * Initializes a webVR display and starts listening to display change events
  86879. * The onVRDisplayChangedObservable will be notified upon these changes
  86880. * @returns A promise containing a VRDisplay and if vr is supported
  86881. */
  86882. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86883. /**
  86884. * Call this function to switch to webVR mode
  86885. * Will do nothing if webVR is not supported or if there is no webVR device
  86886. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86887. */
  86888. enableVR(): void;
  86889. /**
  86890. * Call this function to leave webVR mode
  86891. * Will do nothing if webVR is not supported or if there is no webVR device
  86892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86893. */
  86894. disableVR(): void;
  86895. private _onVRFullScreenTriggered;
  86896. private _getVRDisplaysAsync;
  86897. /**
  86898. * Binds the frame buffer to the specified texture.
  86899. * @param texture The texture to render to or null for the default canvas
  86900. * @param faceIndex The face of the texture to render to in case of cube texture
  86901. * @param requiredWidth The width of the target to render to
  86902. * @param requiredHeight The height of the target to render to
  86903. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86904. * @param depthStencilTexture The depth stencil texture to use to render
  86905. * @param lodLevel defines le lod level to bind to the frame buffer
  86906. */
  86907. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86908. private bindUnboundFramebuffer;
  86909. /**
  86910. * Unbind the current render target texture from the webGL context
  86911. * @param texture defines the render target texture to unbind
  86912. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86913. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86914. */
  86915. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86916. /**
  86917. * Unbind a list of render target textures from the webGL context
  86918. * This is used only when drawBuffer extension or webGL2 are active
  86919. * @param textures defines the render target textures to unbind
  86920. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86921. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86922. */
  86923. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86924. /**
  86925. * Force the mipmap generation for the given render target texture
  86926. * @param texture defines the render target texture to use
  86927. */
  86928. generateMipMapsForCubemap(texture: InternalTexture): void;
  86929. /**
  86930. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86931. */
  86932. flushFramebuffer(): void;
  86933. /**
  86934. * Unbind the current render target and bind the default framebuffer
  86935. */
  86936. restoreDefaultFramebuffer(): void;
  86937. /**
  86938. * Create an uniform buffer
  86939. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86940. * @param elements defines the content of the uniform buffer
  86941. * @returns the webGL uniform buffer
  86942. */
  86943. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86944. /**
  86945. * Create a dynamic uniform buffer
  86946. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86947. * @param elements defines the content of the uniform buffer
  86948. * @returns the webGL uniform buffer
  86949. */
  86950. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86951. /**
  86952. * Update an existing uniform buffer
  86953. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86954. * @param uniformBuffer defines the target uniform buffer
  86955. * @param elements defines the content to update
  86956. * @param offset defines the offset in the uniform buffer where update should start
  86957. * @param count defines the size of the data to update
  86958. */
  86959. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86960. private _resetVertexBufferBinding;
  86961. /**
  86962. * Creates a vertex buffer
  86963. * @param data the data for the vertex buffer
  86964. * @returns the new WebGL static buffer
  86965. */
  86966. createVertexBuffer(data: DataArray): WebGLBuffer;
  86967. /**
  86968. * Creates a dynamic vertex buffer
  86969. * @param data the data for the dynamic vertex buffer
  86970. * @returns the new WebGL dynamic buffer
  86971. */
  86972. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86973. /**
  86974. * Update a dynamic index buffer
  86975. * @param indexBuffer defines the target index buffer
  86976. * @param indices defines the data to update
  86977. * @param offset defines the offset in the target index buffer where update should start
  86978. */
  86979. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86980. /**
  86981. * Updates a dynamic vertex buffer.
  86982. * @param vertexBuffer the vertex buffer to update
  86983. * @param data the data used to update the vertex buffer
  86984. * @param byteOffset the byte offset of the data
  86985. * @param byteLength the byte length of the data
  86986. */
  86987. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86988. private _resetIndexBufferBinding;
  86989. /**
  86990. * Creates a new index buffer
  86991. * @param indices defines the content of the index buffer
  86992. * @param updatable defines if the index buffer must be updatable
  86993. * @returns a new webGL buffer
  86994. */
  86995. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86996. /**
  86997. * Bind a webGL buffer to the webGL context
  86998. * @param buffer defines the buffer to bind
  86999. */
  87000. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87001. /**
  87002. * Bind an uniform buffer to the current webGL context
  87003. * @param buffer defines the buffer to bind
  87004. */
  87005. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87006. /**
  87007. * Bind a buffer to the current webGL context at a given location
  87008. * @param buffer defines the buffer to bind
  87009. * @param location defines the index where to bind the buffer
  87010. */
  87011. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87012. /**
  87013. * Bind a specific block at a given index in a specific shader program
  87014. * @param shaderProgram defines the shader program
  87015. * @param blockName defines the block name
  87016. * @param index defines the index where to bind the block
  87017. */
  87018. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87019. private bindIndexBuffer;
  87020. private bindBuffer;
  87021. /**
  87022. * update the bound buffer with the given data
  87023. * @param data defines the data to update
  87024. */
  87025. updateArrayBuffer(data: Float32Array): void;
  87026. private _vertexAttribPointer;
  87027. private _bindIndexBufferWithCache;
  87028. private _bindVertexBuffersAttributes;
  87029. /**
  87030. * Records a vertex array object
  87031. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87032. * @param vertexBuffers defines the list of vertex buffers to store
  87033. * @param indexBuffer defines the index buffer to store
  87034. * @param effect defines the effect to store
  87035. * @returns the new vertex array object
  87036. */
  87037. recordVertexArrayObject(vertexBuffers: {
  87038. [key: string]: VertexBuffer;
  87039. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87040. /**
  87041. * Bind a specific vertex array object
  87042. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87043. * @param vertexArrayObject defines the vertex array object to bind
  87044. * @param indexBuffer defines the index buffer to bind
  87045. */
  87046. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87047. /**
  87048. * Bind webGl buffers directly to the webGL context
  87049. * @param vertexBuffer defines the vertex buffer to bind
  87050. * @param indexBuffer defines the index buffer to bind
  87051. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87052. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87053. * @param effect defines the effect associated with the vertex buffer
  87054. */
  87055. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87056. private _unbindVertexArrayObject;
  87057. /**
  87058. * Bind a list of vertex buffers to the webGL context
  87059. * @param vertexBuffers defines the list of vertex buffers to bind
  87060. * @param indexBuffer defines the index buffer to bind
  87061. * @param effect defines the effect associated with the vertex buffers
  87062. */
  87063. bindBuffers(vertexBuffers: {
  87064. [key: string]: Nullable<VertexBuffer>;
  87065. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87066. /**
  87067. * Unbind all instance attributes
  87068. */
  87069. unbindInstanceAttributes(): void;
  87070. /**
  87071. * Release and free the memory of a vertex array object
  87072. * @param vao defines the vertex array object to delete
  87073. */
  87074. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87075. /** @hidden */
  87076. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87077. /**
  87078. * Creates a webGL buffer to use with instanciation
  87079. * @param capacity defines the size of the buffer
  87080. * @returns the webGL buffer
  87081. */
  87082. createInstancesBuffer(capacity: number): WebGLBuffer;
  87083. /**
  87084. * Delete a webGL buffer used with instanciation
  87085. * @param buffer defines the webGL buffer to delete
  87086. */
  87087. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87088. /**
  87089. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87090. * @param instancesBuffer defines the webGL buffer to update and bind
  87091. * @param data defines the data to store in the buffer
  87092. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87093. */
  87094. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87095. /**
  87096. * Apply all cached states (depth, culling, stencil and alpha)
  87097. */
  87098. applyStates(): void;
  87099. /**
  87100. * Send a draw order
  87101. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87102. * @param indexStart defines the starting index
  87103. * @param indexCount defines the number of index to draw
  87104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87105. */
  87106. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87107. /**
  87108. * Draw a list of points
  87109. * @param verticesStart defines the index of first vertex to draw
  87110. * @param verticesCount defines the count of vertices to draw
  87111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87112. */
  87113. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87114. /**
  87115. * Draw a list of unindexed primitives
  87116. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87117. * @param verticesStart defines the index of first vertex to draw
  87118. * @param verticesCount defines the count of vertices to draw
  87119. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87120. */
  87121. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87122. /**
  87123. * Draw a list of indexed primitives
  87124. * @param fillMode defines the primitive to use
  87125. * @param indexStart defines the starting index
  87126. * @param indexCount defines the number of index to draw
  87127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87128. */
  87129. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87130. /**
  87131. * Draw a list of unindexed primitives
  87132. * @param fillMode defines the primitive to use
  87133. * @param verticesStart defines the index of first vertex to draw
  87134. * @param verticesCount defines the count of vertices to draw
  87135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87136. */
  87137. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87138. private _drawMode;
  87139. /** @hidden */
  87140. _releaseEffect(effect: Effect): void;
  87141. /** @hidden */
  87142. _deleteProgram(program: WebGLProgram): void;
  87143. /**
  87144. * Create a new effect (used to store vertex/fragment shaders)
  87145. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87146. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87147. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87148. * @param samplers defines an array of string used to represent textures
  87149. * @param defines defines the string containing the defines to use to compile the shaders
  87150. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87151. * @param onCompiled defines a function to call when the effect creation is successful
  87152. * @param onError defines a function to call when the effect creation has failed
  87153. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87154. * @returns the new Effect
  87155. */
  87156. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  87157. private _compileShader;
  87158. private _compileRawShader;
  87159. /**
  87160. * Directly creates a webGL program
  87161. * @param vertexCode defines the vertex shader code to use
  87162. * @param fragmentCode defines the fragment shader code to use
  87163. * @param context defines the webGL context to use (if not set, the current one will be used)
  87164. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87165. * @returns the new webGL program
  87166. */
  87167. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87168. /**
  87169. * Creates a webGL program
  87170. * @param vertexCode defines the vertex shader code to use
  87171. * @param fragmentCode defines the fragment shader code to use
  87172. * @param defines defines the string containing the defines to use to compile the shaders
  87173. * @param context defines the webGL context to use (if not set, the current one will be used)
  87174. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87175. * @returns the new webGL program
  87176. */
  87177. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87178. private _createShaderProgram;
  87179. private _finalizeProgram;
  87180. /** @hidden */
  87181. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87182. /** @hidden */
  87183. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87184. /**
  87185. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87186. * @param shaderProgram defines the webGL program to use
  87187. * @param uniformsNames defines the list of uniform names
  87188. * @returns an array of webGL uniform locations
  87189. */
  87190. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87191. /**
  87192. * Gets the lsit of active attributes for a given webGL program
  87193. * @param shaderProgram defines the webGL program to use
  87194. * @param attributesNames defines the list of attribute names to get
  87195. * @returns an array of indices indicating the offset of each attribute
  87196. */
  87197. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87198. /**
  87199. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87200. * @param effect defines the effect to activate
  87201. */
  87202. enableEffect(effect: Nullable<Effect>): void;
  87203. /**
  87204. * Set the value of an uniform to an array of int32
  87205. * @param uniform defines the webGL uniform location where to store the value
  87206. * @param array defines the array of int32 to store
  87207. */
  87208. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87209. /**
  87210. * Set the value of an uniform to an array of int32 (stored as vec2)
  87211. * @param uniform defines the webGL uniform location where to store the value
  87212. * @param array defines the array of int32 to store
  87213. */
  87214. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87215. /**
  87216. * Set the value of an uniform to an array of int32 (stored as vec3)
  87217. * @param uniform defines the webGL uniform location where to store the value
  87218. * @param array defines the array of int32 to store
  87219. */
  87220. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87221. /**
  87222. * Set the value of an uniform to an array of int32 (stored as vec4)
  87223. * @param uniform defines the webGL uniform location where to store the value
  87224. * @param array defines the array of int32 to store
  87225. */
  87226. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87227. /**
  87228. * Set the value of an uniform to an array of float32
  87229. * @param uniform defines the webGL uniform location where to store the value
  87230. * @param array defines the array of float32 to store
  87231. */
  87232. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87233. /**
  87234. * Set the value of an uniform to an array of float32 (stored as vec2)
  87235. * @param uniform defines the webGL uniform location where to store the value
  87236. * @param array defines the array of float32 to store
  87237. */
  87238. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87239. /**
  87240. * Set the value of an uniform to an array of float32 (stored as vec3)
  87241. * @param uniform defines the webGL uniform location where to store the value
  87242. * @param array defines the array of float32 to store
  87243. */
  87244. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87245. /**
  87246. * Set the value of an uniform to an array of float32 (stored as vec4)
  87247. * @param uniform defines the webGL uniform location where to store the value
  87248. * @param array defines the array of float32 to store
  87249. */
  87250. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87251. /**
  87252. * Set the value of an uniform to an array of number
  87253. * @param uniform defines the webGL uniform location where to store the value
  87254. * @param array defines the array of number to store
  87255. */
  87256. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87257. /**
  87258. * Set the value of an uniform to an array of number (stored as vec2)
  87259. * @param uniform defines the webGL uniform location where to store the value
  87260. * @param array defines the array of number to store
  87261. */
  87262. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87263. /**
  87264. * Set the value of an uniform to an array of number (stored as vec3)
  87265. * @param uniform defines the webGL uniform location where to store the value
  87266. * @param array defines the array of number to store
  87267. */
  87268. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87269. /**
  87270. * Set the value of an uniform to an array of number (stored as vec4)
  87271. * @param uniform defines the webGL uniform location where to store the value
  87272. * @param array defines the array of number to store
  87273. */
  87274. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87275. /**
  87276. * Set the value of an uniform to an array of float32 (stored as matrices)
  87277. * @param uniform defines the webGL uniform location where to store the value
  87278. * @param matrices defines the array of float32 to store
  87279. */
  87280. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87281. /**
  87282. * Set the value of an uniform to a matrix
  87283. * @param uniform defines the webGL uniform location where to store the value
  87284. * @param matrix defines the matrix to store
  87285. */
  87286. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87287. /**
  87288. * Set the value of an uniform to a matrix (3x3)
  87289. * @param uniform defines the webGL uniform location where to store the value
  87290. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87291. */
  87292. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87293. /**
  87294. * Set the value of an uniform to a matrix (2x2)
  87295. * @param uniform defines the webGL uniform location where to store the value
  87296. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87297. */
  87298. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87299. /**
  87300. * Set the value of an uniform to a number (int)
  87301. * @param uniform defines the webGL uniform location where to store the value
  87302. * @param value defines the int number to store
  87303. */
  87304. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87305. /**
  87306. * Set the value of an uniform to a number (float)
  87307. * @param uniform defines the webGL uniform location where to store the value
  87308. * @param value defines the float number to store
  87309. */
  87310. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87311. /**
  87312. * Set the value of an uniform to a vec2
  87313. * @param uniform defines the webGL uniform location where to store the value
  87314. * @param x defines the 1st component of the value
  87315. * @param y defines the 2nd component of the value
  87316. */
  87317. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87318. /**
  87319. * Set the value of an uniform to a vec3
  87320. * @param uniform defines the webGL uniform location where to store the value
  87321. * @param x defines the 1st component of the value
  87322. * @param y defines the 2nd component of the value
  87323. * @param z defines the 3rd component of the value
  87324. */
  87325. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87326. /**
  87327. * Set the value of an uniform to a boolean
  87328. * @param uniform defines the webGL uniform location where to store the value
  87329. * @param bool defines the boolean to store
  87330. */
  87331. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87332. /**
  87333. * Set the value of an uniform to a vec4
  87334. * @param uniform defines the webGL uniform location where to store the value
  87335. * @param x defines the 1st component of the value
  87336. * @param y defines the 2nd component of the value
  87337. * @param z defines the 3rd component of the value
  87338. * @param w defines the 4th component of the value
  87339. */
  87340. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87341. /**
  87342. * Set the value of an uniform to a Color3
  87343. * @param uniform defines the webGL uniform location where to store the value
  87344. * @param color3 defines the color to store
  87345. */
  87346. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87347. /**
  87348. * Set the value of an uniform to a Color3 and an alpha value
  87349. * @param uniform defines the webGL uniform location where to store the value
  87350. * @param color3 defines the color to store
  87351. * @param alpha defines the alpha component to store
  87352. */
  87353. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87354. /**
  87355. * Sets a Color4 on a uniform variable
  87356. * @param uniform defines the uniform location
  87357. * @param color4 defines the value to be set
  87358. */
  87359. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87360. /**
  87361. * Set various states to the webGL context
  87362. * @param culling defines backface culling state
  87363. * @param zOffset defines the value to apply to zOffset (0 by default)
  87364. * @param force defines if states must be applied even if cache is up to date
  87365. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87366. */
  87367. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87368. /**
  87369. * Set the z offset to apply to current rendering
  87370. * @param value defines the offset to apply
  87371. */
  87372. setZOffset(value: number): void;
  87373. /**
  87374. * Gets the current value of the zOffset
  87375. * @returns the current zOffset state
  87376. */
  87377. getZOffset(): number;
  87378. /**
  87379. * Enable or disable depth buffering
  87380. * @param enable defines the state to set
  87381. */
  87382. setDepthBuffer(enable: boolean): void;
  87383. /**
  87384. * Gets a boolean indicating if depth writing is enabled
  87385. * @returns the current depth writing state
  87386. */
  87387. getDepthWrite(): boolean;
  87388. /**
  87389. * Enable or disable depth writing
  87390. * @param enable defines the state to set
  87391. */
  87392. setDepthWrite(enable: boolean): void;
  87393. /**
  87394. * Enable or disable color writing
  87395. * @param enable defines the state to set
  87396. */
  87397. setColorWrite(enable: boolean): void;
  87398. /**
  87399. * Gets a boolean indicating if color writing is enabled
  87400. * @returns the current color writing state
  87401. */
  87402. getColorWrite(): boolean;
  87403. /**
  87404. * Sets alpha constants used by some alpha blending modes
  87405. * @param r defines the red component
  87406. * @param g defines the green component
  87407. * @param b defines the blue component
  87408. * @param a defines the alpha component
  87409. */
  87410. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87411. /**
  87412. * Sets the current alpha mode
  87413. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87414. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87415. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87416. */
  87417. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87418. /**
  87419. * Gets the current alpha mode
  87420. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87421. * @returns the current alpha mode
  87422. */
  87423. getAlphaMode(): number;
  87424. /**
  87425. * Clears the list of texture accessible through engine.
  87426. * This can help preventing texture load conflict due to name collision.
  87427. */
  87428. clearInternalTexturesCache(): void;
  87429. /**
  87430. * Force the entire cache to be cleared
  87431. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87432. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87433. */
  87434. wipeCaches(bruteForce?: boolean): void;
  87435. /**
  87436. * Set the compressed texture format to use, based on the formats you have, and the formats
  87437. * supported by the hardware / browser.
  87438. *
  87439. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87440. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87441. * to API arguments needed to compressed textures. This puts the burden on the container
  87442. * generator to house the arcane code for determining these for current & future formats.
  87443. *
  87444. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87445. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87446. *
  87447. * Note: The result of this call is not taken into account when a texture is base64.
  87448. *
  87449. * @param formatsAvailable defines the list of those format families you have created
  87450. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87451. *
  87452. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87453. * @returns The extension selected.
  87454. */
  87455. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87456. private _getSamplingParameters;
  87457. private _partialLoadImg;
  87458. private _cascadeLoadImgs;
  87459. /** @hidden */
  87460. _createTexture(): WebGLTexture;
  87461. /**
  87462. * Usually called from Texture.ts.
  87463. * Passed information to create a WebGLTexture
  87464. * @param urlArg defines a value which contains one of the following:
  87465. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87466. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87467. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87468. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87469. * @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)
  87470. * @param scene needed for loading to the correct scene
  87471. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87472. * @param onLoad optional callback to be called upon successful completion
  87473. * @param onError optional callback to be called upon failure
  87474. * @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
  87475. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87476. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87477. * @param forcedExtension defines the extension to use to pick the right loader
  87478. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87479. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87480. */
  87481. 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;
  87482. private _rescaleTexture;
  87483. /**
  87484. * Update a raw texture
  87485. * @param texture defines the texture to update
  87486. * @param data defines the data to store in the texture
  87487. * @param format defines the format of the data
  87488. * @param invertY defines if data must be stored with Y axis inverted
  87489. * @param compression defines the compression used (null by default)
  87490. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87491. */
  87492. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87493. /**
  87494. * Creates a raw texture
  87495. * @param data defines the data to store in the texture
  87496. * @param width defines the width of the texture
  87497. * @param height defines the height of the texture
  87498. * @param format defines the format of the data
  87499. * @param generateMipMaps defines if the engine should generate the mip levels
  87500. * @param invertY defines if data must be stored with Y axis inverted
  87501. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87502. * @param compression defines the compression used (null by default)
  87503. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87504. * @returns the raw texture inside an InternalTexture
  87505. */
  87506. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87507. private _unpackFlipYCached;
  87508. /**
  87509. * In case you are sharing the context with other applications, it might
  87510. * be interested to not cache the unpack flip y state to ensure a consistent
  87511. * value would be set.
  87512. */
  87513. enableUnpackFlipYCached: boolean;
  87514. /** @hidden */
  87515. _unpackFlipY(value: boolean): void;
  87516. /** @hidden */
  87517. _getUnpackAlignement(): number;
  87518. /**
  87519. * Creates a dynamic texture
  87520. * @param width defines the width of the texture
  87521. * @param height defines the height of the texture
  87522. * @param generateMipMaps defines if the engine should generate the mip levels
  87523. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87524. * @returns the dynamic texture inside an InternalTexture
  87525. */
  87526. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87527. /**
  87528. * Update the sampling mode of a given texture
  87529. * @param samplingMode defines the required sampling mode
  87530. * @param texture defines the texture to update
  87531. */
  87532. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87533. /**
  87534. * Update the content of a dynamic texture
  87535. * @param texture defines the texture to update
  87536. * @param canvas defines the canvas containing the source
  87537. * @param invertY defines if data must be stored with Y axis inverted
  87538. * @param premulAlpha defines if alpha is stored as premultiplied
  87539. * @param format defines the format of the data
  87540. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87541. */
  87542. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87543. /**
  87544. * Update a video texture
  87545. * @param texture defines the texture to update
  87546. * @param video defines the video element to use
  87547. * @param invertY defines if data must be stored with Y axis inverted
  87548. */
  87549. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87550. /**
  87551. * Updates a depth texture Comparison Mode and Function.
  87552. * If the comparison Function is equal to 0, the mode will be set to none.
  87553. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87554. * @param texture The texture to set the comparison function for
  87555. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87556. */
  87557. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87558. private _setupDepthStencilTexture;
  87559. /**
  87560. * Creates a depth stencil texture.
  87561. * This is only available in WebGL 2 or with the depth texture extension available.
  87562. * @param size The size of face edge in the texture.
  87563. * @param options The options defining the texture.
  87564. * @returns The texture
  87565. */
  87566. createDepthStencilTexture(size: number | {
  87567. width: number;
  87568. height: number;
  87569. }, options: DepthTextureCreationOptions): InternalTexture;
  87570. /**
  87571. * Creates a depth stencil texture.
  87572. * This is only available in WebGL 2 or with the depth texture extension available.
  87573. * @param size The size of face edge in the texture.
  87574. * @param options The options defining the texture.
  87575. * @returns The texture
  87576. */
  87577. private _createDepthStencilTexture;
  87578. /**
  87579. * Creates a depth stencil cube texture.
  87580. * This is only available in WebGL 2.
  87581. * @param size The size of face edge in the cube texture.
  87582. * @param options The options defining the cube texture.
  87583. * @returns The cube texture
  87584. */
  87585. private _createDepthStencilCubeTexture;
  87586. /**
  87587. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87588. * @param renderTarget The render target to set the frame buffer for
  87589. */
  87590. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87591. /**
  87592. * Creates a new render target texture
  87593. * @param size defines the size of the texture
  87594. * @param options defines the options used to create the texture
  87595. * @returns a new render target texture stored in an InternalTexture
  87596. */
  87597. createRenderTargetTexture(size: number | {
  87598. width: number;
  87599. height: number;
  87600. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87601. /**
  87602. * Create a multi render target texture
  87603. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87604. * @param size defines the size of the texture
  87605. * @param options defines the creation options
  87606. * @returns the cube texture as an InternalTexture
  87607. */
  87608. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87609. private _setupFramebufferDepthAttachments;
  87610. /**
  87611. * Updates the sample count of a render target texture
  87612. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87613. * @param texture defines the texture to update
  87614. * @param samples defines the sample count to set
  87615. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87616. */
  87617. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87618. /**
  87619. * Update the sample count for a given multiple render target texture
  87620. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87621. * @param textures defines the textures to update
  87622. * @param samples defines the sample count to set
  87623. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87624. */
  87625. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87626. /** @hidden */
  87627. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87628. /** @hidden */
  87629. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87630. /** @hidden */
  87631. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87632. /** @hidden */
  87633. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87634. /**
  87635. * Creates a new render target cube texture
  87636. * @param size defines the size of the texture
  87637. * @param options defines the options used to create the texture
  87638. * @returns a new render target cube texture stored in an InternalTexture
  87639. */
  87640. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87641. /**
  87642. * Creates a cube texture
  87643. * @param rootUrl defines the url where the files to load is located
  87644. * @param scene defines the current scene
  87645. * @param files defines the list of files to load (1 per face)
  87646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87647. * @param onLoad defines an optional callback raised when the texture is loaded
  87648. * @param onError defines an optional callback raised if there is an issue to load the texture
  87649. * @param format defines the format of the data
  87650. * @param forcedExtension defines the extension to use to pick the right loader
  87651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87654. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87655. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87656. * @returns the cube texture as an InternalTexture
  87657. */
  87658. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  87659. /**
  87660. * @hidden
  87661. */
  87662. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87663. /**
  87664. * Update a raw cube texture
  87665. * @param texture defines the texture to udpdate
  87666. * @param data defines the data to store
  87667. * @param format defines the data format
  87668. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87669. * @param invertY defines if data must be stored with Y axis inverted
  87670. * @param compression defines the compression used (null by default)
  87671. * @param level defines which level of the texture to update
  87672. */
  87673. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87674. /**
  87675. * Creates a new raw cube texture
  87676. * @param data defines the array of data to use to create each face
  87677. * @param size defines the size of the textures
  87678. * @param format defines the format of the data
  87679. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87680. * @param generateMipMaps defines if the engine should generate the mip levels
  87681. * @param invertY defines if data must be stored with Y axis inverted
  87682. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87683. * @param compression defines the compression used (null by default)
  87684. * @returns the cube texture as an InternalTexture
  87685. */
  87686. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87687. /**
  87688. * Creates a new raw cube texture from a specified url
  87689. * @param url defines the url where the data is located
  87690. * @param scene defines the current scene
  87691. * @param size defines the size of the textures
  87692. * @param format defines the format of the data
  87693. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87694. * @param noMipmap defines if the engine should avoid generating the mip levels
  87695. * @param callback defines a callback used to extract texture data from loaded data
  87696. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87697. * @param onLoad defines a callback called when texture is loaded
  87698. * @param onError defines a callback called if there is an error
  87699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87700. * @param invertY defines if data must be stored with Y axis inverted
  87701. * @returns the cube texture as an InternalTexture
  87702. */
  87703. 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;
  87704. /**
  87705. * Update a raw 3D texture
  87706. * @param texture defines the texture to update
  87707. * @param data defines the data to store
  87708. * @param format defines the data format
  87709. * @param invertY defines if data must be stored with Y axis inverted
  87710. * @param compression defines the used compression (can be null)
  87711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87712. */
  87713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87714. /**
  87715. * Creates a new raw 3D texture
  87716. * @param data defines the data used to create the texture
  87717. * @param width defines the width of the texture
  87718. * @param height defines the height of the texture
  87719. * @param depth defines the depth of the texture
  87720. * @param format defines the format of the texture
  87721. * @param generateMipMaps defines if the engine must generate mip levels
  87722. * @param invertY defines if data must be stored with Y axis inverted
  87723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87724. * @param compression defines the compressed used (can be null)
  87725. * @param textureType defines the compressed used (can be null)
  87726. * @returns a new raw 3D texture (stored in an InternalTexture)
  87727. */
  87728. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87729. private _prepareWebGLTextureContinuation;
  87730. private _prepareWebGLTexture;
  87731. private _convertRGBtoRGBATextureData;
  87732. /** @hidden */
  87733. _releaseFramebufferObjects(texture: InternalTexture): void;
  87734. /** @hidden */
  87735. _releaseTexture(texture: InternalTexture): void;
  87736. private setProgram;
  87737. private _boundUniforms;
  87738. /**
  87739. * Binds an effect to the webGL context
  87740. * @param effect defines the effect to bind
  87741. */
  87742. bindSamplers(effect: Effect): void;
  87743. private _moveBoundTextureOnTop;
  87744. private _getCorrectTextureChannel;
  87745. private _linkTrackers;
  87746. private _removeDesignatedSlot;
  87747. private _activateCurrentTexture;
  87748. /** @hidden */
  87749. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87750. /** @hidden */
  87751. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87752. /**
  87753. * Sets a texture to the webGL context from a postprocess
  87754. * @param channel defines the channel to use
  87755. * @param postProcess defines the source postprocess
  87756. */
  87757. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  87758. /**
  87759. * Binds the output of the passed in post process to the texture channel specified
  87760. * @param channel The channel the texture should be bound to
  87761. * @param postProcess The post process which's output should be bound
  87762. */
  87763. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  87764. /**
  87765. * Unbind all textures from the webGL context
  87766. */
  87767. unbindAllTextures(): void;
  87768. /**
  87769. * Sets a texture to the according uniform.
  87770. * @param channel The texture channel
  87771. * @param uniform The uniform to set
  87772. * @param texture The texture to apply
  87773. */
  87774. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87775. /**
  87776. * Sets a depth stencil texture from a render target to the according uniform.
  87777. * @param channel The texture channel
  87778. * @param uniform The uniform to set
  87779. * @param texture The render target texture containing the depth stencil texture to apply
  87780. */
  87781. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87782. private _bindSamplerUniformToChannel;
  87783. private _getTextureWrapMode;
  87784. private _setTexture;
  87785. /**
  87786. * Sets an array of texture to the webGL context
  87787. * @param channel defines the channel where the texture array must be set
  87788. * @param uniform defines the associated uniform location
  87789. * @param textures defines the array of textures to bind
  87790. */
  87791. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87792. /** @hidden */
  87793. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87794. private _setTextureParameterFloat;
  87795. private _setTextureParameterInteger;
  87796. /**
  87797. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87798. * @param x defines the x coordinate of the rectangle where pixels must be read
  87799. * @param y defines the y coordinate of the rectangle where pixels must be read
  87800. * @param width defines the width of the rectangle where pixels must be read
  87801. * @param height defines the height of the rectangle where pixels must be read
  87802. * @returns a Uint8Array containing RGBA colors
  87803. */
  87804. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87805. /**
  87806. * Add an externaly attached data from its key.
  87807. * This method call will fail and return false, if such key already exists.
  87808. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87809. * @param key the unique key that identifies the data
  87810. * @param data the data object to associate to the key for this Engine instance
  87811. * @return true if no such key were already present and the data was added successfully, false otherwise
  87812. */
  87813. addExternalData<T>(key: string, data: T): boolean;
  87814. /**
  87815. * Get an externaly attached data from its key
  87816. * @param key the unique key that identifies the data
  87817. * @return the associated data, if present (can be null), or undefined if not present
  87818. */
  87819. getExternalData<T>(key: string): T;
  87820. /**
  87821. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87822. * @param key the unique key that identifies the data
  87823. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87824. * @return the associated data, can be null if the factory returned null.
  87825. */
  87826. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87827. /**
  87828. * Remove an externaly attached data from the Engine instance
  87829. * @param key the unique key that identifies the data
  87830. * @return true if the data was successfully removed, false if it doesn't exist
  87831. */
  87832. removeExternalData(key: string): boolean;
  87833. /**
  87834. * Unbind all vertex attributes from the webGL context
  87835. */
  87836. unbindAllAttributes(): void;
  87837. /**
  87838. * 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
  87839. */
  87840. releaseEffects(): void;
  87841. /**
  87842. * Dispose and release all associated resources
  87843. */
  87844. dispose(): void;
  87845. /**
  87846. * Display the loading screen
  87847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87848. */
  87849. displayLoadingUI(): void;
  87850. /**
  87851. * Hide the loading screen
  87852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87853. */
  87854. hideLoadingUI(): void;
  87855. /**
  87856. * Gets the current loading screen object
  87857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87858. */
  87859. /**
  87860. * Sets the current loading screen object
  87861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87862. */
  87863. loadingScreen: ILoadingScreen;
  87864. /**
  87865. * Sets the current loading screen text
  87866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87867. */
  87868. loadingUIText: string;
  87869. /**
  87870. * Sets the current loading screen background color
  87871. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87872. */
  87873. loadingUIBackgroundColor: string;
  87874. /**
  87875. * Attach a new callback raised when context lost event is fired
  87876. * @param callback defines the callback to call
  87877. */
  87878. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87879. /**
  87880. * Attach a new callback raised when context restored event is fired
  87881. * @param callback defines the callback to call
  87882. */
  87883. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87884. /**
  87885. * Gets the source code of the vertex shader associated with a specific webGL program
  87886. * @param program defines the program to use
  87887. * @returns a string containing the source code of the vertex shader associated with the program
  87888. */
  87889. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87890. /**
  87891. * Gets the source code of the fragment shader associated with a specific webGL program
  87892. * @param program defines the program to use
  87893. * @returns a string containing the source code of the fragment shader associated with the program
  87894. */
  87895. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87896. /**
  87897. * Get the current error code of the webGL context
  87898. * @returns the error code
  87899. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87900. */
  87901. getError(): number;
  87902. /**
  87903. * Gets the current framerate
  87904. * @returns a number representing the framerate
  87905. */
  87906. getFps(): number;
  87907. /**
  87908. * Gets the time spent between current and previous frame
  87909. * @returns a number representing the delta time in ms
  87910. */
  87911. getDeltaTime(): number;
  87912. private _measureFps;
  87913. /** @hidden */
  87914. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87915. private _canRenderToFloatFramebuffer;
  87916. private _canRenderToHalfFloatFramebuffer;
  87917. private _canRenderToFramebuffer;
  87918. /** @hidden */
  87919. _getWebGLTextureType(type: number): number;
  87920. private _getInternalFormat;
  87921. /** @hidden */
  87922. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87923. /** @hidden */
  87924. _getRGBAMultiSampleBufferFormat(type: number): number;
  87925. /** @hidden */
  87926. _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;
  87927. /** @hidden */
  87928. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87929. private _partialLoadFile;
  87930. private _cascadeLoadFiles;
  87931. /**
  87932. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87933. * @returns true if the engine can be created
  87934. * @ignorenaming
  87935. */
  87936. static isSupported(): boolean;
  87937. }
  87938. }
  87939. declare module BABYLON {
  87940. /**
  87941. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87942. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87943. */
  87944. export class EffectFallbacks {
  87945. private _defines;
  87946. private _currentRank;
  87947. private _maxRank;
  87948. private _mesh;
  87949. /**
  87950. * Removes the fallback from the bound mesh.
  87951. */
  87952. unBindMesh(): void;
  87953. /**
  87954. * Adds a fallback on the specified property.
  87955. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87956. * @param define The name of the define in the shader
  87957. */
  87958. addFallback(rank: number, define: string): void;
  87959. /**
  87960. * Sets the mesh to use CPU skinning when needing to fallback.
  87961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87962. * @param mesh The mesh to use the fallbacks.
  87963. */
  87964. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87965. /**
  87966. * Checks to see if more fallbacks are still availible.
  87967. */
  87968. readonly isMoreFallbacks: boolean;
  87969. /**
  87970. * Removes the defines that shoould be removed when falling back.
  87971. * @param currentDefines defines the current define statements for the shader.
  87972. * @param effect defines the current effect we try to compile
  87973. * @returns The resulting defines with defines of the current rank removed.
  87974. */
  87975. reduce(currentDefines: string, effect: Effect): string;
  87976. }
  87977. /**
  87978. * Options to be used when creating an effect.
  87979. */
  87980. export class EffectCreationOptions {
  87981. /**
  87982. * Atrributes that will be used in the shader.
  87983. */
  87984. attributes: string[];
  87985. /**
  87986. * Uniform varible names that will be set in the shader.
  87987. */
  87988. uniformsNames: string[];
  87989. /**
  87990. * Uniform buffer varible names that will be set in the shader.
  87991. */
  87992. uniformBuffersNames: string[];
  87993. /**
  87994. * Sampler texture variable names that will be set in the shader.
  87995. */
  87996. samplers: string[];
  87997. /**
  87998. * Define statements that will be set in the shader.
  87999. */
  88000. defines: any;
  88001. /**
  88002. * Possible fallbacks for this effect to improve performance when needed.
  88003. */
  88004. fallbacks: Nullable<EffectFallbacks>;
  88005. /**
  88006. * Callback that will be called when the shader is compiled.
  88007. */
  88008. onCompiled: Nullable<(effect: Effect) => void>;
  88009. /**
  88010. * Callback that will be called if an error occurs during shader compilation.
  88011. */
  88012. onError: Nullable<(effect: Effect, errors: string) => void>;
  88013. /**
  88014. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88015. */
  88016. indexParameters: any;
  88017. /**
  88018. * Max number of lights that can be used in the shader.
  88019. */
  88020. maxSimultaneousLights: number;
  88021. /**
  88022. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88023. */
  88024. transformFeedbackVaryings: Nullable<string[]>;
  88025. }
  88026. /**
  88027. * Effect containing vertex and fragment shader that can be executed on an object.
  88028. */
  88029. export class Effect {
  88030. /**
  88031. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88032. */
  88033. static ShadersRepository: string;
  88034. /**
  88035. * Name of the effect.
  88036. */
  88037. name: any;
  88038. /**
  88039. * String container all the define statements that should be set on the shader.
  88040. */
  88041. defines: string;
  88042. /**
  88043. * Callback that will be called when the shader is compiled.
  88044. */
  88045. onCompiled: Nullable<(effect: Effect) => void>;
  88046. /**
  88047. * Callback that will be called if an error occurs during shader compilation.
  88048. */
  88049. onError: Nullable<(effect: Effect, errors: string) => void>;
  88050. /**
  88051. * Callback that will be called when effect is bound.
  88052. */
  88053. onBind: Nullable<(effect: Effect) => void>;
  88054. /**
  88055. * Unique ID of the effect.
  88056. */
  88057. uniqueId: number;
  88058. /**
  88059. * Observable that will be called when the shader is compiled.
  88060. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88061. */
  88062. onCompileObservable: Observable<Effect>;
  88063. /**
  88064. * Observable that will be called if an error occurs during shader compilation.
  88065. */
  88066. onErrorObservable: Observable<Effect>;
  88067. /** @hidden */
  88068. _onBindObservable: Nullable<Observable<Effect>>;
  88069. /**
  88070. * Observable that will be called when effect is bound.
  88071. */
  88072. readonly onBindObservable: Observable<Effect>;
  88073. /** @hidden */
  88074. _bonesComputationForcedToCPU: boolean;
  88075. private static _uniqueIdSeed;
  88076. private _engine;
  88077. private _uniformBuffersNames;
  88078. private _uniformsNames;
  88079. private _samplers;
  88080. private _isReady;
  88081. private _compilationError;
  88082. private _attributesNames;
  88083. private _attributes;
  88084. private _uniforms;
  88085. /**
  88086. * Key for the effect.
  88087. * @hidden
  88088. */
  88089. _key: string;
  88090. private _indexParameters;
  88091. private _fallbacks;
  88092. private _vertexSourceCode;
  88093. private _fragmentSourceCode;
  88094. private _vertexSourceCodeOverride;
  88095. private _fragmentSourceCodeOverride;
  88096. private _transformFeedbackVaryings;
  88097. /**
  88098. * Compiled shader to webGL program.
  88099. * @hidden
  88100. */
  88101. _program: WebGLProgram;
  88102. private _valueCache;
  88103. private static _baseCache;
  88104. /**
  88105. * Instantiates an effect.
  88106. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88107. * @param baseName Name of the effect.
  88108. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88109. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88110. * @param samplers List of sampler variables that will be passed to the shader.
  88111. * @param engine Engine to be used to render the effect
  88112. * @param defines Define statements to be added to the shader.
  88113. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88114. * @param onCompiled Callback that will be called when the shader is compiled.
  88115. * @param onError Callback that will be called if an error occurs during shader compilation.
  88116. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88117. */
  88118. 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);
  88119. /**
  88120. * Unique key for this effect
  88121. */
  88122. readonly key: string;
  88123. /**
  88124. * If the effect has been compiled and prepared.
  88125. * @returns if the effect is compiled and prepared.
  88126. */
  88127. isReady(): boolean;
  88128. /**
  88129. * The engine the effect was initialized with.
  88130. * @returns the engine.
  88131. */
  88132. getEngine(): Engine;
  88133. /**
  88134. * The compiled webGL program for the effect
  88135. * @returns the webGL program.
  88136. */
  88137. getProgram(): WebGLProgram;
  88138. /**
  88139. * The set of names of attribute variables for the shader.
  88140. * @returns An array of attribute names.
  88141. */
  88142. getAttributesNames(): string[];
  88143. /**
  88144. * Returns the attribute at the given index.
  88145. * @param index The index of the attribute.
  88146. * @returns The location of the attribute.
  88147. */
  88148. getAttributeLocation(index: number): number;
  88149. /**
  88150. * Returns the attribute based on the name of the variable.
  88151. * @param name of the attribute to look up.
  88152. * @returns the attribute location.
  88153. */
  88154. getAttributeLocationByName(name: string): number;
  88155. /**
  88156. * The number of attributes.
  88157. * @returns the numnber of attributes.
  88158. */
  88159. getAttributesCount(): number;
  88160. /**
  88161. * Gets the index of a uniform variable.
  88162. * @param uniformName of the uniform to look up.
  88163. * @returns the index.
  88164. */
  88165. getUniformIndex(uniformName: string): number;
  88166. /**
  88167. * Returns the attribute based on the name of the variable.
  88168. * @param uniformName of the uniform to look up.
  88169. * @returns the location of the uniform.
  88170. */
  88171. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88172. /**
  88173. * Returns an array of sampler variable names
  88174. * @returns The array of sampler variable neames.
  88175. */
  88176. getSamplers(): string[];
  88177. /**
  88178. * The error from the last compilation.
  88179. * @returns the error string.
  88180. */
  88181. getCompilationError(): string;
  88182. /**
  88183. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88184. * @param func The callback to be used.
  88185. */
  88186. executeWhenCompiled(func: (effect: Effect) => void): void;
  88187. private _checkIsReady;
  88188. /** @hidden */
  88189. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88190. /** @hidden */
  88191. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88192. /** @hidden */
  88193. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88194. private _processShaderConversion;
  88195. private _processIncludes;
  88196. private _processPrecision;
  88197. /**
  88198. * Recompiles the webGL program
  88199. * @param vertexSourceCode The source code for the vertex shader.
  88200. * @param fragmentSourceCode The source code for the fragment shader.
  88201. * @param onCompiled Callback called when completed.
  88202. * @param onError Callback called on error.
  88203. * @hidden
  88204. */
  88205. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88206. /**
  88207. * Gets the uniform locations of the the specified variable names
  88208. * @param names THe names of the variables to lookup.
  88209. * @returns Array of locations in the same order as variable names.
  88210. */
  88211. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88212. /**
  88213. * Prepares the effect
  88214. * @hidden
  88215. */
  88216. _prepareEffect(): void;
  88217. /**
  88218. * Checks if the effect is supported. (Must be called after compilation)
  88219. */
  88220. readonly isSupported: boolean;
  88221. /**
  88222. * Binds a texture to the engine to be used as output of the shader.
  88223. * @param channel Name of the output variable.
  88224. * @param texture Texture to bind.
  88225. * @hidden
  88226. */
  88227. _bindTexture(channel: string, texture: InternalTexture): void;
  88228. /**
  88229. * Sets a texture on the engine to be used in the shader.
  88230. * @param channel Name of the sampler variable.
  88231. * @param texture Texture to set.
  88232. */
  88233. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88234. /**
  88235. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88236. * @param channel Name of the sampler variable.
  88237. * @param texture Texture to set.
  88238. */
  88239. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88240. /**
  88241. * Sets an array of textures on the engine to be used in the shader.
  88242. * @param channel Name of the variable.
  88243. * @param textures Textures to set.
  88244. */
  88245. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88246. /**
  88247. * 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)
  88248. * @param channel Name of the sampler variable.
  88249. * @param postProcess Post process to get the input texture from.
  88250. */
  88251. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88252. /**
  88253. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88254. * 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)
  88255. * @param channel Name of the sampler variable.
  88256. * @param postProcess Post process to get the output texture from.
  88257. */
  88258. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88259. /** @hidden */
  88260. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88261. /** @hidden */
  88262. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88263. /** @hidden */
  88264. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88265. /** @hidden */
  88266. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88267. /**
  88268. * Binds a buffer to a uniform.
  88269. * @param buffer Buffer to bind.
  88270. * @param name Name of the uniform variable to bind to.
  88271. */
  88272. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88273. /**
  88274. * Binds block to a uniform.
  88275. * @param blockName Name of the block to bind.
  88276. * @param index Index to bind.
  88277. */
  88278. bindUniformBlock(blockName: string, index: number): void;
  88279. /**
  88280. * Sets an interger value on a uniform variable.
  88281. * @param uniformName Name of the variable.
  88282. * @param value Value to be set.
  88283. * @returns this effect.
  88284. */
  88285. setInt(uniformName: string, value: number): Effect;
  88286. /**
  88287. * Sets an int array on a uniform variable.
  88288. * @param uniformName Name of the variable.
  88289. * @param array array to be set.
  88290. * @returns this effect.
  88291. */
  88292. setIntArray(uniformName: string, array: Int32Array): Effect;
  88293. /**
  88294. * 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)
  88295. * @param uniformName Name of the variable.
  88296. * @param array array to be set.
  88297. * @returns this effect.
  88298. */
  88299. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88300. /**
  88301. * 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)
  88302. * @param uniformName Name of the variable.
  88303. * @param array array to be set.
  88304. * @returns this effect.
  88305. */
  88306. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88307. /**
  88308. * 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)
  88309. * @param uniformName Name of the variable.
  88310. * @param array array to be set.
  88311. * @returns this effect.
  88312. */
  88313. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88314. /**
  88315. * Sets an float array on a uniform variable.
  88316. * @param uniformName Name of the variable.
  88317. * @param array array to be set.
  88318. * @returns this effect.
  88319. */
  88320. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88321. /**
  88322. * 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)
  88323. * @param uniformName Name of the variable.
  88324. * @param array array to be set.
  88325. * @returns this effect.
  88326. */
  88327. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88328. /**
  88329. * 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)
  88330. * @param uniformName Name of the variable.
  88331. * @param array array to be set.
  88332. * @returns this effect.
  88333. */
  88334. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88335. /**
  88336. * 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)
  88337. * @param uniformName Name of the variable.
  88338. * @param array array to be set.
  88339. * @returns this effect.
  88340. */
  88341. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88342. /**
  88343. * Sets an array on a uniform variable.
  88344. * @param uniformName Name of the variable.
  88345. * @param array array to be set.
  88346. * @returns this effect.
  88347. */
  88348. setArray(uniformName: string, array: number[]): Effect;
  88349. /**
  88350. * 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)
  88351. * @param uniformName Name of the variable.
  88352. * @param array array to be set.
  88353. * @returns this effect.
  88354. */
  88355. setArray2(uniformName: string, array: number[]): Effect;
  88356. /**
  88357. * 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)
  88358. * @param uniformName Name of the variable.
  88359. * @param array array to be set.
  88360. * @returns this effect.
  88361. */
  88362. setArray3(uniformName: string, array: number[]): Effect;
  88363. /**
  88364. * 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)
  88365. * @param uniformName Name of the variable.
  88366. * @param array array to be set.
  88367. * @returns this effect.
  88368. */
  88369. setArray4(uniformName: string, array: number[]): Effect;
  88370. /**
  88371. * Sets matrices on a uniform variable.
  88372. * @param uniformName Name of the variable.
  88373. * @param matrices matrices to be set.
  88374. * @returns this effect.
  88375. */
  88376. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88377. /**
  88378. * Sets matrix on a uniform variable.
  88379. * @param uniformName Name of the variable.
  88380. * @param matrix matrix to be set.
  88381. * @returns this effect.
  88382. */
  88383. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88384. /**
  88385. * 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)
  88386. * @param uniformName Name of the variable.
  88387. * @param matrix matrix to be set.
  88388. * @returns this effect.
  88389. */
  88390. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88391. /**
  88392. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88393. * @param uniformName Name of the variable.
  88394. * @param matrix matrix to be set.
  88395. * @returns this effect.
  88396. */
  88397. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88398. /**
  88399. * Sets a float on a uniform variable.
  88400. * @param uniformName Name of the variable.
  88401. * @param value value to be set.
  88402. * @returns this effect.
  88403. */
  88404. setFloat(uniformName: string, value: number): Effect;
  88405. /**
  88406. * Sets a boolean on a uniform variable.
  88407. * @param uniformName Name of the variable.
  88408. * @param bool value to be set.
  88409. * @returns this effect.
  88410. */
  88411. setBool(uniformName: string, bool: boolean): Effect;
  88412. /**
  88413. * Sets a Vector2 on a uniform variable.
  88414. * @param uniformName Name of the variable.
  88415. * @param vector2 vector2 to be set.
  88416. * @returns this effect.
  88417. */
  88418. setVector2(uniformName: string, vector2: Vector2): Effect;
  88419. /**
  88420. * Sets a float2 on a uniform variable.
  88421. * @param uniformName Name of the variable.
  88422. * @param x First float in float2.
  88423. * @param y Second float in float2.
  88424. * @returns this effect.
  88425. */
  88426. setFloat2(uniformName: string, x: number, y: number): Effect;
  88427. /**
  88428. * Sets a Vector3 on a uniform variable.
  88429. * @param uniformName Name of the variable.
  88430. * @param vector3 Value to be set.
  88431. * @returns this effect.
  88432. */
  88433. setVector3(uniformName: string, vector3: Vector3): Effect;
  88434. /**
  88435. * Sets a float3 on a uniform variable.
  88436. * @param uniformName Name of the variable.
  88437. * @param x First float in float3.
  88438. * @param y Second float in float3.
  88439. * @param z Third float in float3.
  88440. * @returns this effect.
  88441. */
  88442. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88443. /**
  88444. * Sets a Vector4 on a uniform variable.
  88445. * @param uniformName Name of the variable.
  88446. * @param vector4 Value to be set.
  88447. * @returns this effect.
  88448. */
  88449. setVector4(uniformName: string, vector4: Vector4): Effect;
  88450. /**
  88451. * Sets a float4 on a uniform variable.
  88452. * @param uniformName Name of the variable.
  88453. * @param x First float in float4.
  88454. * @param y Second float in float4.
  88455. * @param z Third float in float4.
  88456. * @param w Fourth float in float4.
  88457. * @returns this effect.
  88458. */
  88459. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88460. /**
  88461. * Sets a Color3 on a uniform variable.
  88462. * @param uniformName Name of the variable.
  88463. * @param color3 Value to be set.
  88464. * @returns this effect.
  88465. */
  88466. setColor3(uniformName: string, color3: Color3): Effect;
  88467. /**
  88468. * Sets a Color4 on a uniform variable.
  88469. * @param uniformName Name of the variable.
  88470. * @param color3 Value to be set.
  88471. * @param alpha Alpha value to be set.
  88472. * @returns this effect.
  88473. */
  88474. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88475. /**
  88476. * Sets a Color4 on a uniform variable
  88477. * @param uniformName defines the name of the variable
  88478. * @param color4 defines the value to be set
  88479. * @returns this effect.
  88480. */
  88481. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88482. /**
  88483. * This function will add a new shader to the shader store
  88484. * @param name the name of the shader
  88485. * @param pixelShader optional pixel shader content
  88486. * @param vertexShader optional vertex shader content
  88487. */
  88488. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88489. /**
  88490. * Store of each shader (The can be looked up using effect.key)
  88491. */
  88492. static ShadersStore: {
  88493. [key: string]: string;
  88494. };
  88495. /**
  88496. * Store of each included file for a shader (The can be looked up using effect.key)
  88497. */
  88498. static IncludesShadersStore: {
  88499. [key: string]: string;
  88500. };
  88501. /**
  88502. * Resets the cache of effects.
  88503. */
  88504. static ResetCache(): void;
  88505. }
  88506. }
  88507. declare module BABYLON {
  88508. /**
  88509. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88510. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88511. * 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;
  88512. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88513. */
  88514. export class ColorCurves {
  88515. private _dirty;
  88516. private _tempColor;
  88517. private _globalCurve;
  88518. private _highlightsCurve;
  88519. private _midtonesCurve;
  88520. private _shadowsCurve;
  88521. private _positiveCurve;
  88522. private _negativeCurve;
  88523. private _globalHue;
  88524. private _globalDensity;
  88525. private _globalSaturation;
  88526. private _globalExposure;
  88527. /**
  88528. * Gets the global Hue value.
  88529. * 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).
  88530. */
  88531. /**
  88532. * Sets the global Hue value.
  88533. * 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).
  88534. */
  88535. globalHue: number;
  88536. /**
  88537. * Gets the global Density value.
  88538. * 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.
  88539. * Values less than zero provide a filter of opposite hue.
  88540. */
  88541. /**
  88542. * Sets the global Density value.
  88543. * 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.
  88544. * Values less than zero provide a filter of opposite hue.
  88545. */
  88546. globalDensity: number;
  88547. /**
  88548. * Gets the global Saturation value.
  88549. * 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.
  88550. */
  88551. /**
  88552. * Sets the global Saturation value.
  88553. * 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.
  88554. */
  88555. globalSaturation: number;
  88556. /**
  88557. * Gets the global Exposure value.
  88558. * 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.
  88559. */
  88560. /**
  88561. * Sets the global Exposure value.
  88562. * 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.
  88563. */
  88564. globalExposure: number;
  88565. private _highlightsHue;
  88566. private _highlightsDensity;
  88567. private _highlightsSaturation;
  88568. private _highlightsExposure;
  88569. /**
  88570. * Gets the highlights Hue value.
  88571. * 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).
  88572. */
  88573. /**
  88574. * Sets the highlights Hue value.
  88575. * 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).
  88576. */
  88577. highlightsHue: number;
  88578. /**
  88579. * Gets the highlights Density value.
  88580. * 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.
  88581. * Values less than zero provide a filter of opposite hue.
  88582. */
  88583. /**
  88584. * Sets the highlights Density value.
  88585. * 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.
  88586. * Values less than zero provide a filter of opposite hue.
  88587. */
  88588. highlightsDensity: number;
  88589. /**
  88590. * Gets the highlights Saturation value.
  88591. * 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.
  88592. */
  88593. /**
  88594. * Sets the highlights Saturation value.
  88595. * 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.
  88596. */
  88597. highlightsSaturation: number;
  88598. /**
  88599. * Gets the highlights Exposure value.
  88600. * 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.
  88601. */
  88602. /**
  88603. * Sets the highlights Exposure value.
  88604. * 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.
  88605. */
  88606. highlightsExposure: number;
  88607. private _midtonesHue;
  88608. private _midtonesDensity;
  88609. private _midtonesSaturation;
  88610. private _midtonesExposure;
  88611. /**
  88612. * Gets the midtones Hue value.
  88613. * 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).
  88614. */
  88615. /**
  88616. * Sets the midtones Hue value.
  88617. * 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).
  88618. */
  88619. midtonesHue: number;
  88620. /**
  88621. * Gets the midtones Density value.
  88622. * 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.
  88623. * Values less than zero provide a filter of opposite hue.
  88624. */
  88625. /**
  88626. * Sets the midtones Density value.
  88627. * 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.
  88628. * Values less than zero provide a filter of opposite hue.
  88629. */
  88630. midtonesDensity: number;
  88631. /**
  88632. * Gets the midtones Saturation value.
  88633. * 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.
  88634. */
  88635. /**
  88636. * Sets the midtones Saturation value.
  88637. * 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.
  88638. */
  88639. midtonesSaturation: number;
  88640. /**
  88641. * Gets the midtones Exposure value.
  88642. * 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.
  88643. */
  88644. /**
  88645. * Sets the midtones Exposure value.
  88646. * 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.
  88647. */
  88648. midtonesExposure: number;
  88649. private _shadowsHue;
  88650. private _shadowsDensity;
  88651. private _shadowsSaturation;
  88652. private _shadowsExposure;
  88653. /**
  88654. * Gets the shadows Hue value.
  88655. * 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).
  88656. */
  88657. /**
  88658. * Sets the shadows Hue value.
  88659. * 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).
  88660. */
  88661. shadowsHue: number;
  88662. /**
  88663. * Gets the shadows Density value.
  88664. * 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.
  88665. * Values less than zero provide a filter of opposite hue.
  88666. */
  88667. /**
  88668. * Sets the shadows Density value.
  88669. * 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.
  88670. * Values less than zero provide a filter of opposite hue.
  88671. */
  88672. shadowsDensity: number;
  88673. /**
  88674. * Gets the shadows Saturation value.
  88675. * 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.
  88676. */
  88677. /**
  88678. * Sets the shadows Saturation value.
  88679. * 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.
  88680. */
  88681. shadowsSaturation: number;
  88682. /**
  88683. * Gets the shadows Exposure value.
  88684. * 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.
  88685. */
  88686. /**
  88687. * Sets the shadows Exposure value.
  88688. * 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.
  88689. */
  88690. shadowsExposure: number;
  88691. /**
  88692. * Returns the class name
  88693. * @returns The class name
  88694. */
  88695. getClassName(): string;
  88696. /**
  88697. * Binds the color curves to the shader.
  88698. * @param colorCurves The color curve to bind
  88699. * @param effect The effect to bind to
  88700. * @param positiveUniform The positive uniform shader parameter
  88701. * @param neutralUniform The neutral uniform shader parameter
  88702. * @param negativeUniform The negative uniform shader parameter
  88703. */
  88704. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88705. /**
  88706. * Prepare the list of uniforms associated with the ColorCurves effects.
  88707. * @param uniformsList The list of uniforms used in the effect
  88708. */
  88709. static PrepareUniforms(uniformsList: string[]): void;
  88710. /**
  88711. * Returns color grading data based on a hue, density, saturation and exposure value.
  88712. * @param filterHue The hue of the color filter.
  88713. * @param filterDensity The density of the color filter.
  88714. * @param saturation The saturation.
  88715. * @param exposure The exposure.
  88716. * @param result The result data container.
  88717. */
  88718. private getColorGradingDataToRef;
  88719. /**
  88720. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88721. * @param value The input slider value in range [-100,100].
  88722. * @returns Adjusted value.
  88723. */
  88724. private static applyColorGradingSliderNonlinear;
  88725. /**
  88726. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88727. * @param hue The hue (H) input.
  88728. * @param saturation The saturation (S) input.
  88729. * @param brightness The brightness (B) input.
  88730. * @result An RGBA color represented as Vector4.
  88731. */
  88732. private static fromHSBToRef;
  88733. /**
  88734. * Returns a value clamped between min and max
  88735. * @param value The value to clamp
  88736. * @param min The minimum of value
  88737. * @param max The maximum of value
  88738. * @returns The clamped value.
  88739. */
  88740. private static clamp;
  88741. /**
  88742. * Clones the current color curve instance.
  88743. * @return The cloned curves
  88744. */
  88745. clone(): ColorCurves;
  88746. /**
  88747. * Serializes the current color curve instance to a json representation.
  88748. * @return a JSON representation
  88749. */
  88750. serialize(): any;
  88751. /**
  88752. * Parses the color curve from a json representation.
  88753. * @param source the JSON source to parse
  88754. * @return The parsed curves
  88755. */
  88756. static Parse(source: any): ColorCurves;
  88757. }
  88758. }
  88759. declare module BABYLON {
  88760. /**
  88761. * Interface to follow in your material defines to integrate easily the
  88762. * Image proccessing functions.
  88763. * @hidden
  88764. */
  88765. export interface IImageProcessingConfigurationDefines {
  88766. IMAGEPROCESSING: boolean;
  88767. VIGNETTE: boolean;
  88768. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88769. VIGNETTEBLENDMODEOPAQUE: boolean;
  88770. TONEMAPPING: boolean;
  88771. TONEMAPPING_ACES: boolean;
  88772. CONTRAST: boolean;
  88773. EXPOSURE: boolean;
  88774. COLORCURVES: boolean;
  88775. COLORGRADING: boolean;
  88776. COLORGRADING3D: boolean;
  88777. SAMPLER3DGREENDEPTH: boolean;
  88778. SAMPLER3DBGRMAP: boolean;
  88779. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88780. }
  88781. /**
  88782. * @hidden
  88783. */
  88784. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88785. IMAGEPROCESSING: boolean;
  88786. VIGNETTE: boolean;
  88787. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88788. VIGNETTEBLENDMODEOPAQUE: boolean;
  88789. TONEMAPPING: boolean;
  88790. TONEMAPPING_ACES: boolean;
  88791. CONTRAST: boolean;
  88792. COLORCURVES: boolean;
  88793. COLORGRADING: boolean;
  88794. COLORGRADING3D: boolean;
  88795. SAMPLER3DGREENDEPTH: boolean;
  88796. SAMPLER3DBGRMAP: boolean;
  88797. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88798. EXPOSURE: boolean;
  88799. constructor();
  88800. }
  88801. /**
  88802. * This groups together the common properties used for image processing either in direct forward pass
  88803. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88804. * or not.
  88805. */
  88806. export class ImageProcessingConfiguration {
  88807. /**
  88808. * Default tone mapping applied in BabylonJS.
  88809. */
  88810. static readonly TONEMAPPING_STANDARD: number;
  88811. /**
  88812. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88813. * to other engines rendering to increase portability.
  88814. */
  88815. static readonly TONEMAPPING_ACES: number;
  88816. /**
  88817. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88818. */
  88819. colorCurves: Nullable<ColorCurves>;
  88820. private _colorCurvesEnabled;
  88821. /**
  88822. * Gets wether the color curves effect is enabled.
  88823. */
  88824. /**
  88825. * Sets wether the color curves effect is enabled.
  88826. */
  88827. colorCurvesEnabled: boolean;
  88828. private _colorGradingTexture;
  88829. /**
  88830. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88831. */
  88832. /**
  88833. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88834. */
  88835. colorGradingTexture: Nullable<BaseTexture>;
  88836. private _colorGradingEnabled;
  88837. /**
  88838. * Gets wether the color grading effect is enabled.
  88839. */
  88840. /**
  88841. * Sets wether the color grading effect is enabled.
  88842. */
  88843. colorGradingEnabled: boolean;
  88844. private _colorGradingWithGreenDepth;
  88845. /**
  88846. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88847. */
  88848. /**
  88849. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88850. */
  88851. colorGradingWithGreenDepth: boolean;
  88852. private _colorGradingBGR;
  88853. /**
  88854. * Gets wether the color grading texture contains BGR values.
  88855. */
  88856. /**
  88857. * Sets wether the color grading texture contains BGR values.
  88858. */
  88859. colorGradingBGR: boolean;
  88860. /** @hidden */
  88861. _exposure: number;
  88862. /**
  88863. * Gets the Exposure used in the effect.
  88864. */
  88865. /**
  88866. * Sets the Exposure used in the effect.
  88867. */
  88868. exposure: number;
  88869. private _toneMappingEnabled;
  88870. /**
  88871. * Gets wether the tone mapping effect is enabled.
  88872. */
  88873. /**
  88874. * Sets wether the tone mapping effect is enabled.
  88875. */
  88876. toneMappingEnabled: boolean;
  88877. private _toneMappingType;
  88878. /**
  88879. * Gets the type of tone mapping effect.
  88880. */
  88881. /**
  88882. * Sets the type of tone mapping effect used in BabylonJS.
  88883. */
  88884. toneMappingType: number;
  88885. protected _contrast: number;
  88886. /**
  88887. * Gets the contrast used in the effect.
  88888. */
  88889. /**
  88890. * Sets the contrast used in the effect.
  88891. */
  88892. contrast: number;
  88893. /**
  88894. * Vignette stretch size.
  88895. */
  88896. vignetteStretch: number;
  88897. /**
  88898. * Vignette centre X Offset.
  88899. */
  88900. vignetteCentreX: number;
  88901. /**
  88902. * Vignette centre Y Offset.
  88903. */
  88904. vignetteCentreY: number;
  88905. /**
  88906. * Vignette weight or intensity of the vignette effect.
  88907. */
  88908. vignetteWeight: number;
  88909. /**
  88910. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88911. * if vignetteEnabled is set to true.
  88912. */
  88913. vignetteColor: Color4;
  88914. /**
  88915. * Camera field of view used by the Vignette effect.
  88916. */
  88917. vignetteCameraFov: number;
  88918. private _vignetteBlendMode;
  88919. /**
  88920. * Gets the vignette blend mode allowing different kind of effect.
  88921. */
  88922. /**
  88923. * Sets the vignette blend mode allowing different kind of effect.
  88924. */
  88925. vignetteBlendMode: number;
  88926. private _vignetteEnabled;
  88927. /**
  88928. * Gets wether the vignette effect is enabled.
  88929. */
  88930. /**
  88931. * Sets wether the vignette effect is enabled.
  88932. */
  88933. vignetteEnabled: boolean;
  88934. private _applyByPostProcess;
  88935. /**
  88936. * Gets wether the image processing is applied through a post process or not.
  88937. */
  88938. /**
  88939. * Sets wether the image processing is applied through a post process or not.
  88940. */
  88941. applyByPostProcess: boolean;
  88942. private _isEnabled;
  88943. /**
  88944. * Gets wether the image processing is enabled or not.
  88945. */
  88946. /**
  88947. * Sets wether the image processing is enabled or not.
  88948. */
  88949. isEnabled: boolean;
  88950. /**
  88951. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88952. */
  88953. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88954. /**
  88955. * Method called each time the image processing information changes requires to recompile the effect.
  88956. */
  88957. protected _updateParameters(): void;
  88958. /**
  88959. * Gets the current class name.
  88960. * @return "ImageProcessingConfiguration"
  88961. */
  88962. getClassName(): string;
  88963. /**
  88964. * Prepare the list of uniforms associated with the Image Processing effects.
  88965. * @param uniforms The list of uniforms used in the effect
  88966. * @param defines the list of defines currently in use
  88967. */
  88968. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88969. /**
  88970. * Prepare the list of samplers associated with the Image Processing effects.
  88971. * @param samplersList The list of uniforms used in the effect
  88972. * @param defines the list of defines currently in use
  88973. */
  88974. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88975. /**
  88976. * Prepare the list of defines associated to the shader.
  88977. * @param defines the list of defines to complete
  88978. * @param forPostProcess Define if we are currently in post process mode or not
  88979. */
  88980. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88981. /**
  88982. * Returns true if all the image processing information are ready.
  88983. * @returns True if ready, otherwise, false
  88984. */
  88985. isReady(): boolean;
  88986. /**
  88987. * Binds the image processing to the shader.
  88988. * @param effect The effect to bind to
  88989. * @param aspectRatio Define the current aspect ratio of the effect
  88990. */
  88991. bind(effect: Effect, aspectRatio?: number): void;
  88992. /**
  88993. * Clones the current image processing instance.
  88994. * @return The cloned image processing
  88995. */
  88996. clone(): ImageProcessingConfiguration;
  88997. /**
  88998. * Serializes the current image processing instance to a json representation.
  88999. * @return a JSON representation
  89000. */
  89001. serialize(): any;
  89002. /**
  89003. * Parses the image processing from a json representation.
  89004. * @param source the JSON source to parse
  89005. * @return The parsed image processing
  89006. */
  89007. static Parse(source: any): ImageProcessingConfiguration;
  89008. private static _VIGNETTEMODE_MULTIPLY;
  89009. private static _VIGNETTEMODE_OPAQUE;
  89010. /**
  89011. * Used to apply the vignette as a mix with the pixel color.
  89012. */
  89013. static readonly VIGNETTEMODE_MULTIPLY: number;
  89014. /**
  89015. * Used to apply the vignette as a replacement of the pixel color.
  89016. */
  89017. static readonly VIGNETTEMODE_OPAQUE: number;
  89018. }
  89019. }
  89020. declare module BABYLON {
  89021. /**
  89022. * This represents all the required information to add a fresnel effect on a material:
  89023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89024. */
  89025. export class FresnelParameters {
  89026. private _isEnabled;
  89027. /**
  89028. * Define if the fresnel effect is enable or not.
  89029. */
  89030. isEnabled: boolean;
  89031. /**
  89032. * Define the color used on edges (grazing angle)
  89033. */
  89034. leftColor: Color3;
  89035. /**
  89036. * Define the color used on center
  89037. */
  89038. rightColor: Color3;
  89039. /**
  89040. * Define bias applied to computed fresnel term
  89041. */
  89042. bias: number;
  89043. /**
  89044. * Defined the power exponent applied to fresnel term
  89045. */
  89046. power: number;
  89047. /**
  89048. * Clones the current fresnel and its valuues
  89049. * @returns a clone fresnel configuration
  89050. */
  89051. clone(): FresnelParameters;
  89052. /**
  89053. * Serializes the current fresnel parameters to a JSON representation.
  89054. * @return the JSON serialization
  89055. */
  89056. serialize(): any;
  89057. /**
  89058. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89059. * @param parsedFresnelParameters Define the JSON representation
  89060. * @returns the parsed parameters
  89061. */
  89062. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89063. }
  89064. }
  89065. declare module BABYLON {
  89066. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89067. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89068. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89069. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89070. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89071. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89072. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89073. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89074. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89075. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89076. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89077. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89078. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89079. /**
  89080. * Decorator used to define property that can be serialized as reference to a camera
  89081. * @param sourceName defines the name of the property to decorate
  89082. */
  89083. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89084. /**
  89085. * Class used to help serialization objects
  89086. */
  89087. export class SerializationHelper {
  89088. /** hidden */
  89089. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89090. /** hidden */
  89091. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89092. /** hidden */
  89093. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89094. /** hidden */
  89095. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89096. /**
  89097. * Appends the serialized animations from the source animations
  89098. * @param source Source containing the animations
  89099. * @param destination Target to store the animations
  89100. */
  89101. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89102. /**
  89103. * Static function used to serialized a specific entity
  89104. * @param entity defines the entity to serialize
  89105. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89106. * @returns a JSON compatible object representing the serialization of the entity
  89107. */
  89108. static Serialize<T>(entity: T, serializationObject?: any): any;
  89109. /**
  89110. * Creates a new entity from a serialization data object
  89111. * @param creationFunction defines a function used to instanciated the new entity
  89112. * @param source defines the source serialization data
  89113. * @param scene defines the hosting scene
  89114. * @param rootUrl defines the root url for resources
  89115. * @returns a new entity
  89116. */
  89117. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89118. /**
  89119. * Clones an object
  89120. * @param creationFunction defines the function used to instanciate the new object
  89121. * @param source defines the source object
  89122. * @returns the cloned object
  89123. */
  89124. static Clone<T>(creationFunction: () => T, source: T): T;
  89125. /**
  89126. * Instanciates a new object based on a source one (some data will be shared between both object)
  89127. * @param creationFunction defines the function used to instanciate the new object
  89128. * @param source defines the source object
  89129. * @returns the new object
  89130. */
  89131. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89132. }
  89133. }
  89134. declare module BABYLON {
  89135. /**
  89136. * This is the base class of all the camera used in the application.
  89137. * @see http://doc.babylonjs.com/features/cameras
  89138. */
  89139. export class Camera extends Node {
  89140. /** @hidden */
  89141. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89142. /**
  89143. * This is the default projection mode used by the cameras.
  89144. * It helps recreating a feeling of perspective and better appreciate depth.
  89145. * This is the best way to simulate real life cameras.
  89146. */
  89147. static readonly PERSPECTIVE_CAMERA: number;
  89148. /**
  89149. * This helps creating camera with an orthographic mode.
  89150. * 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.
  89151. */
  89152. static readonly ORTHOGRAPHIC_CAMERA: number;
  89153. /**
  89154. * This is the default FOV mode for perspective cameras.
  89155. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89156. */
  89157. static readonly FOVMODE_VERTICAL_FIXED: number;
  89158. /**
  89159. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89160. */
  89161. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89162. /**
  89163. * This specifies ther is no need for a camera rig.
  89164. * Basically only one eye is rendered corresponding to the camera.
  89165. */
  89166. static readonly RIG_MODE_NONE: number;
  89167. /**
  89168. * Simulates a camera Rig with one blue eye and one red eye.
  89169. * This can be use with 3d blue and red glasses.
  89170. */
  89171. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89172. /**
  89173. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89174. */
  89175. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89176. /**
  89177. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89178. */
  89179. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89180. /**
  89181. * Defines that both eyes of the camera will be rendered over under each other.
  89182. */
  89183. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89184. /**
  89185. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89186. */
  89187. static readonly RIG_MODE_VR: number;
  89188. /**
  89189. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89190. */
  89191. static readonly RIG_MODE_WEBVR: number;
  89192. /**
  89193. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89194. */
  89195. static readonly RIG_MODE_CUSTOM: number;
  89196. /**
  89197. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89198. */
  89199. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89200. /**
  89201. * Define the input manager associated with the camera.
  89202. */
  89203. inputs: CameraInputsManager<Camera>;
  89204. /** @hidden */
  89205. _position: Vector3;
  89206. /**
  89207. * Define the current local position of the camera in the scene
  89208. */
  89209. position: Vector3;
  89210. /**
  89211. * The vector the camera should consider as up.
  89212. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89213. */
  89214. upVector: Vector3;
  89215. /**
  89216. * Define the current limit on the left side for an orthographic camera
  89217. * In scene unit
  89218. */
  89219. orthoLeft: Nullable<number>;
  89220. /**
  89221. * Define the current limit on the right side for an orthographic camera
  89222. * In scene unit
  89223. */
  89224. orthoRight: Nullable<number>;
  89225. /**
  89226. * Define the current limit on the bottom side for an orthographic camera
  89227. * In scene unit
  89228. */
  89229. orthoBottom: Nullable<number>;
  89230. /**
  89231. * Define the current limit on the top side for an orthographic camera
  89232. * In scene unit
  89233. */
  89234. orthoTop: Nullable<number>;
  89235. /**
  89236. * Field Of View is set in Radians. (default is 0.8)
  89237. */
  89238. fov: number;
  89239. /**
  89240. * Define the minimum distance the camera can see from.
  89241. * This is important to note that the depth buffer are not infinite and the closer it starts
  89242. * the more your scene might encounter depth fighting issue.
  89243. */
  89244. minZ: number;
  89245. /**
  89246. * Define the maximum distance the camera can see to.
  89247. * This is important to note that the depth buffer are not infinite and the further it end
  89248. * the more your scene might encounter depth fighting issue.
  89249. */
  89250. maxZ: number;
  89251. /**
  89252. * Define the default inertia of the camera.
  89253. * This helps giving a smooth feeling to the camera movement.
  89254. */
  89255. inertia: number;
  89256. /**
  89257. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89258. */
  89259. mode: number;
  89260. /**
  89261. * Define wether the camera is intermediate.
  89262. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89263. */
  89264. isIntermediate: boolean;
  89265. /**
  89266. * Define the viewport of the camera.
  89267. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89268. */
  89269. viewport: Viewport;
  89270. /**
  89271. * Restricts the camera to viewing objects with the same layerMask.
  89272. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89273. */
  89274. layerMask: number;
  89275. /**
  89276. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89277. */
  89278. fovMode: number;
  89279. /**
  89280. * Rig mode of the camera.
  89281. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89282. * This is normally controlled byt the camera themselves as internal use.
  89283. */
  89284. cameraRigMode: number;
  89285. /**
  89286. * Defines the distance between both "eyes" in case of a RIG
  89287. */
  89288. interaxialDistance: number;
  89289. /**
  89290. * Defines if stereoscopic rendering is done side by side or over under.
  89291. */
  89292. isStereoscopicSideBySide: boolean;
  89293. /**
  89294. * 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
  89295. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89296. * else in the scene.
  89297. */
  89298. customRenderTargets: RenderTargetTexture[];
  89299. /**
  89300. * When set, the camera will render to this render target instead of the default canvas
  89301. */
  89302. outputRenderTarget: Nullable<RenderTargetTexture>;
  89303. /**
  89304. * Observable triggered when the camera view matrix has changed.
  89305. */
  89306. onViewMatrixChangedObservable: Observable<Camera>;
  89307. /**
  89308. * Observable triggered when the camera Projection matrix has changed.
  89309. */
  89310. onProjectionMatrixChangedObservable: Observable<Camera>;
  89311. /**
  89312. * Observable triggered when the inputs have been processed.
  89313. */
  89314. onAfterCheckInputsObservable: Observable<Camera>;
  89315. /**
  89316. * Observable triggered when reset has been called and applied to the camera.
  89317. */
  89318. onRestoreStateObservable: Observable<Camera>;
  89319. /** @hidden */
  89320. _cameraRigParams: any;
  89321. /** @hidden */
  89322. _rigCameras: Camera[];
  89323. /** @hidden */
  89324. _rigPostProcess: Nullable<PostProcess>;
  89325. protected _webvrViewMatrix: Matrix;
  89326. /** @hidden */
  89327. _skipRendering: boolean;
  89328. /** @hidden */
  89329. _projectionMatrix: Matrix;
  89330. /** @hidden */
  89331. _postProcesses: Nullable<PostProcess>[];
  89332. /** @hidden */
  89333. _activeMeshes: SmartArray<AbstractMesh>;
  89334. protected _globalPosition: Vector3;
  89335. /** hidden */
  89336. _computedViewMatrix: Matrix;
  89337. private _doNotComputeProjectionMatrix;
  89338. private _transformMatrix;
  89339. private _frustumPlanes;
  89340. private _refreshFrustumPlanes;
  89341. private _storedFov;
  89342. private _stateStored;
  89343. /**
  89344. * Instantiates a new camera object.
  89345. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89346. * @see http://doc.babylonjs.com/features/cameras
  89347. * @param name Defines the name of the camera in the scene
  89348. * @param position Defines the position of the camera
  89349. * @param scene Defines the scene the camera belongs too
  89350. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89351. */
  89352. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89353. /**
  89354. * Store current camera state (fov, position, etc..)
  89355. * @returns the camera
  89356. */
  89357. storeState(): Camera;
  89358. /**
  89359. * Restores the camera state values if it has been stored. You must call storeState() first
  89360. */
  89361. protected _restoreStateValues(): boolean;
  89362. /**
  89363. * Restored camera state. You must call storeState() first.
  89364. * @returns true if restored and false otherwise
  89365. */
  89366. restoreState(): boolean;
  89367. /**
  89368. * Gets the class name of the camera.
  89369. * @returns the class name
  89370. */
  89371. getClassName(): string;
  89372. /** @hidden */
  89373. readonly _isCamera: boolean;
  89374. /**
  89375. * Gets a string representation of the camera useful for debug purpose.
  89376. * @param fullDetails Defines that a more verboe level of logging is required
  89377. * @returns the string representation
  89378. */
  89379. toString(fullDetails?: boolean): string;
  89380. /**
  89381. * Gets the current world space position of the camera.
  89382. */
  89383. readonly globalPosition: Vector3;
  89384. /**
  89385. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89386. * @returns the active meshe list
  89387. */
  89388. getActiveMeshes(): SmartArray<AbstractMesh>;
  89389. /**
  89390. * Check wether a mesh is part of the current active mesh list of the camera
  89391. * @param mesh Defines the mesh to check
  89392. * @returns true if active, false otherwise
  89393. */
  89394. isActiveMesh(mesh: Mesh): boolean;
  89395. /**
  89396. * Is this camera ready to be used/rendered
  89397. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89398. * @return true if the camera is ready
  89399. */
  89400. isReady(completeCheck?: boolean): boolean;
  89401. /** @hidden */
  89402. _initCache(): void;
  89403. /** @hidden */
  89404. _updateCache(ignoreParentClass?: boolean): void;
  89405. /** @hidden */
  89406. _isSynchronized(): boolean;
  89407. /** @hidden */
  89408. _isSynchronizedViewMatrix(): boolean;
  89409. /** @hidden */
  89410. _isSynchronizedProjectionMatrix(): boolean;
  89411. /**
  89412. * Attach the input controls to a specific dom element to get the input from.
  89413. * @param element Defines the element the controls should be listened from
  89414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89415. */
  89416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89417. /**
  89418. * Detach the current controls from the specified dom element.
  89419. * @param element Defines the element to stop listening the inputs from
  89420. */
  89421. detachControl(element: HTMLElement): void;
  89422. /**
  89423. * Update the camera state according to the different inputs gathered during the frame.
  89424. */
  89425. update(): void;
  89426. /** @hidden */
  89427. _checkInputs(): void;
  89428. /** @hidden */
  89429. readonly rigCameras: Camera[];
  89430. /**
  89431. * Gets the post process used by the rig cameras
  89432. */
  89433. readonly rigPostProcess: Nullable<PostProcess>;
  89434. /**
  89435. * Internal, gets the first post proces.
  89436. * @returns the first post process to be run on this camera.
  89437. */
  89438. _getFirstPostProcess(): Nullable<PostProcess>;
  89439. private _cascadePostProcessesToRigCams;
  89440. /**
  89441. * Attach a post process to the camera.
  89442. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89443. * @param postProcess The post process to attach to the camera
  89444. * @param insertAt The position of the post process in case several of them are in use in the scene
  89445. * @returns the position the post process has been inserted at
  89446. */
  89447. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89448. /**
  89449. * Detach a post process to the camera.
  89450. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89451. * @param postProcess The post process to detach from the camera
  89452. */
  89453. detachPostProcess(postProcess: PostProcess): void;
  89454. /**
  89455. * Gets the current world matrix of the camera
  89456. */
  89457. getWorldMatrix(): Matrix;
  89458. /** @hidden */
  89459. _getViewMatrix(): Matrix;
  89460. /**
  89461. * Gets the current view matrix of the camera.
  89462. * @param force forces the camera to recompute the matrix without looking at the cached state
  89463. * @returns the view matrix
  89464. */
  89465. getViewMatrix(force?: boolean): Matrix;
  89466. /**
  89467. * Freeze the projection matrix.
  89468. * It will prevent the cache check of the camera projection compute and can speed up perf
  89469. * if no parameter of the camera are meant to change
  89470. * @param projection Defines manually a projection if necessary
  89471. */
  89472. freezeProjectionMatrix(projection?: Matrix): void;
  89473. /**
  89474. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89475. */
  89476. unfreezeProjectionMatrix(): void;
  89477. /**
  89478. * Gets the current projection matrix of the camera.
  89479. * @param force forces the camera to recompute the matrix without looking at the cached state
  89480. * @returns the projection matrix
  89481. */
  89482. getProjectionMatrix(force?: boolean): Matrix;
  89483. /**
  89484. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89485. * @returns a Matrix
  89486. */
  89487. getTransformationMatrix(): Matrix;
  89488. private _updateFrustumPlanes;
  89489. /**
  89490. * Checks if a cullable object (mesh...) is in the camera frustum
  89491. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89492. * @param target The object to check
  89493. * @returns true if the object is in frustum otherwise false
  89494. */
  89495. isInFrustum(target: ICullable): boolean;
  89496. /**
  89497. * Checks if a cullable object (mesh...) is in the camera frustum
  89498. * Unlike isInFrustum this cheks the full bounding box
  89499. * @param target The object to check
  89500. * @returns true if the object is in frustum otherwise false
  89501. */
  89502. isCompletelyInFrustum(target: ICullable): boolean;
  89503. /**
  89504. * Gets a ray in the forward direction from the camera.
  89505. * @param length Defines the length of the ray to create
  89506. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89507. * @param origin Defines the start point of the ray which defaults to the camera position
  89508. * @returns the forward ray
  89509. */
  89510. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89511. /**
  89512. * Releases resources associated with this node.
  89513. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89514. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89515. */
  89516. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89517. /** @hidden */
  89518. _isLeftCamera: boolean;
  89519. /**
  89520. * Gets the left camera of a rig setup in case of Rigged Camera
  89521. */
  89522. readonly isLeftCamera: boolean;
  89523. /** @hidden */
  89524. _isRightCamera: boolean;
  89525. /**
  89526. * Gets the right camera of a rig setup in case of Rigged Camera
  89527. */
  89528. readonly isRightCamera: boolean;
  89529. /**
  89530. * Gets the left camera of a rig setup in case of Rigged Camera
  89531. */
  89532. readonly leftCamera: Nullable<FreeCamera>;
  89533. /**
  89534. * Gets the right camera of a rig setup in case of Rigged Camera
  89535. */
  89536. readonly rightCamera: Nullable<FreeCamera>;
  89537. /**
  89538. * Gets the left camera target of a rig setup in case of Rigged Camera
  89539. * @returns the target position
  89540. */
  89541. getLeftTarget(): Nullable<Vector3>;
  89542. /**
  89543. * Gets the right camera target of a rig setup in case of Rigged Camera
  89544. * @returns the target position
  89545. */
  89546. getRightTarget(): Nullable<Vector3>;
  89547. /**
  89548. * @hidden
  89549. */
  89550. setCameraRigMode(mode: number, rigParams: any): void;
  89551. /** @hidden */
  89552. static _setStereoscopicRigMode(camera: Camera): void;
  89553. /** @hidden */
  89554. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89555. /** @hidden */
  89556. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89557. /** @hidden */
  89558. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89559. /** @hidden */
  89560. _getVRProjectionMatrix(): Matrix;
  89561. protected _updateCameraRotationMatrix(): void;
  89562. protected _updateWebVRCameraRotationMatrix(): void;
  89563. /**
  89564. * This function MUST be overwritten by the different WebVR cameras available.
  89565. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89566. * @hidden
  89567. */
  89568. _getWebVRProjectionMatrix(): Matrix;
  89569. /**
  89570. * This function MUST be overwritten by the different WebVR cameras available.
  89571. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89572. * @hidden
  89573. */
  89574. _getWebVRViewMatrix(): Matrix;
  89575. /** @hidden */
  89576. setCameraRigParameter(name: string, value: any): void;
  89577. /**
  89578. * needs to be overridden by children so sub has required properties to be copied
  89579. * @hidden
  89580. */
  89581. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89582. /**
  89583. * May need to be overridden by children
  89584. * @hidden
  89585. */
  89586. _updateRigCameras(): void;
  89587. /** @hidden */
  89588. _setupInputs(): void;
  89589. /**
  89590. * Serialiaze the camera setup to a json represention
  89591. * @returns the JSON representation
  89592. */
  89593. serialize(): any;
  89594. /**
  89595. * Clones the current camera.
  89596. * @param name The cloned camera name
  89597. * @returns the cloned camera
  89598. */
  89599. clone(name: string): Camera;
  89600. /**
  89601. * Gets the direction of the camera relative to a given local axis.
  89602. * @param localAxis Defines the reference axis to provide a relative direction.
  89603. * @return the direction
  89604. */
  89605. getDirection(localAxis: Vector3): Vector3;
  89606. /**
  89607. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89608. * @param localAxis Defines the reference axis to provide a relative direction.
  89609. * @param result Defines the vector to store the result in
  89610. */
  89611. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89612. /**
  89613. * Gets a camera constructor for a given camera type
  89614. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89615. * @param name The name of the camera the result will be able to instantiate
  89616. * @param scene The scene the result will construct the camera in
  89617. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89618. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89619. * @returns a factory method to construc the camera
  89620. */
  89621. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89622. /**
  89623. * Compute the world matrix of the camera.
  89624. * @returns the camera workd matrix
  89625. */
  89626. computeWorldMatrix(): Matrix;
  89627. /**
  89628. * Parse a JSON and creates the camera from the parsed information
  89629. * @param parsedCamera The JSON to parse
  89630. * @param scene The scene to instantiate the camera in
  89631. * @returns the newly constructed camera
  89632. */
  89633. static Parse(parsedCamera: any, scene: Scene): Camera;
  89634. }
  89635. }
  89636. declare module BABYLON {
  89637. /**
  89638. * Interface for any object that can request an animation frame
  89639. */
  89640. export interface ICustomAnimationFrameRequester {
  89641. /**
  89642. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89643. */
  89644. renderFunction?: Function;
  89645. /**
  89646. * Called to request the next frame to render to
  89647. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89648. */
  89649. requestAnimationFrame: Function;
  89650. /**
  89651. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89652. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89653. */
  89654. requestID?: number;
  89655. }
  89656. /**
  89657. * Interface containing an array of animations
  89658. */
  89659. export interface IAnimatable {
  89660. /**
  89661. * Array of animations
  89662. */
  89663. animations: Array<Animation>;
  89664. }
  89665. /** Interface used by value gradients (color, factor, ...) */
  89666. export interface IValueGradient {
  89667. /**
  89668. * Gets or sets the gradient value (between 0 and 1)
  89669. */
  89670. gradient: number;
  89671. }
  89672. /** Class used to store color4 gradient */
  89673. export class ColorGradient implements IValueGradient {
  89674. /**
  89675. * Gets or sets the gradient value (between 0 and 1)
  89676. */
  89677. gradient: number;
  89678. /**
  89679. * Gets or sets first associated color
  89680. */
  89681. color1: Color4;
  89682. /**
  89683. * Gets or sets second associated color
  89684. */
  89685. color2?: Color4;
  89686. /**
  89687. * Will get a color picked randomly between color1 and color2.
  89688. * If color2 is undefined then color1 will be used
  89689. * @param result defines the target Color4 to store the result in
  89690. */
  89691. getColorToRef(result: Color4): void;
  89692. }
  89693. /** Class used to store color 3 gradient */
  89694. export class Color3Gradient implements IValueGradient {
  89695. /**
  89696. * Gets or sets the gradient value (between 0 and 1)
  89697. */
  89698. gradient: number;
  89699. /**
  89700. * Gets or sets the associated color
  89701. */
  89702. color: Color3;
  89703. }
  89704. /** Class used to store factor gradient */
  89705. export class FactorGradient implements IValueGradient {
  89706. /**
  89707. * Gets or sets the gradient value (between 0 and 1)
  89708. */
  89709. gradient: number;
  89710. /**
  89711. * Gets or sets first associated factor
  89712. */
  89713. factor1: number;
  89714. /**
  89715. * Gets or sets second associated factor
  89716. */
  89717. factor2?: number;
  89718. /**
  89719. * Will get a number picked randomly between factor1 and factor2.
  89720. * If factor2 is undefined then factor1 will be used
  89721. * @returns the picked number
  89722. */
  89723. getFactor(): number;
  89724. }
  89725. /**
  89726. * @ignore
  89727. * Application error to support additional information when loading a file
  89728. */
  89729. export class LoadFileError extends Error {
  89730. /** defines the optional web request */
  89731. request?: WebRequest | undefined;
  89732. private static _setPrototypeOf;
  89733. /**
  89734. * Creates a new LoadFileError
  89735. * @param message defines the message of the error
  89736. * @param request defines the optional web request
  89737. */
  89738. constructor(message: string,
  89739. /** defines the optional web request */
  89740. request?: WebRequest | undefined);
  89741. }
  89742. /**
  89743. * Class used to define a retry strategy when error happens while loading assets
  89744. */
  89745. export class RetryStrategy {
  89746. /**
  89747. * Function used to defines an exponential back off strategy
  89748. * @param maxRetries defines the maximum number of retries (3 by default)
  89749. * @param baseInterval defines the interval between retries
  89750. * @returns the strategy function to use
  89751. */
  89752. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89753. }
  89754. /**
  89755. * File request interface
  89756. */
  89757. export interface IFileRequest {
  89758. /**
  89759. * Raised when the request is complete (success or error).
  89760. */
  89761. onCompleteObservable: Observable<IFileRequest>;
  89762. /**
  89763. * Aborts the request for a file.
  89764. */
  89765. abort: () => void;
  89766. }
  89767. /**
  89768. * Class containing a set of static utilities functions
  89769. */
  89770. export class Tools {
  89771. /**
  89772. * Gets or sets the base URL to use to load assets
  89773. */
  89774. static BaseUrl: string;
  89775. /**
  89776. * Enable/Disable Custom HTTP Request Headers globally.
  89777. * default = false
  89778. * @see CustomRequestHeaders
  89779. */
  89780. static UseCustomRequestHeaders: boolean;
  89781. /**
  89782. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89783. * i.e. when loading files, where the server/service expects an Authorization header
  89784. */
  89785. static CustomRequestHeaders: {
  89786. [key: string]: string;
  89787. };
  89788. /**
  89789. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89790. */
  89791. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89792. /**
  89793. * Default behaviour for cors in the application.
  89794. * It can be a string if the expected behavior is identical in the entire app.
  89795. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89796. */
  89797. static CorsBehavior: string | ((url: string | string[]) => string);
  89798. /**
  89799. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89800. * @ignorenaming
  89801. */
  89802. static UseFallbackTexture: boolean;
  89803. /**
  89804. * Use this object to register external classes like custom textures or material
  89805. * to allow the laoders to instantiate them
  89806. */
  89807. static RegisteredExternalClasses: {
  89808. [key: string]: Object;
  89809. };
  89810. /**
  89811. * Texture content used if a texture cannot loaded
  89812. * @ignorenaming
  89813. */
  89814. static fallbackTexture: string;
  89815. /**
  89816. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89817. * @param u defines the coordinate on X axis
  89818. * @param v defines the coordinate on Y axis
  89819. * @param width defines the width of the source data
  89820. * @param height defines the height of the source data
  89821. * @param pixels defines the source byte array
  89822. * @param color defines the output color
  89823. */
  89824. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89825. /**
  89826. * Interpolates between a and b via alpha
  89827. * @param a The lower value (returned when alpha = 0)
  89828. * @param b The upper value (returned when alpha = 1)
  89829. * @param alpha The interpolation-factor
  89830. * @return The mixed value
  89831. */
  89832. static Mix(a: number, b: number, alpha: number): number;
  89833. /**
  89834. * Tries to instantiate a new object from a given class name
  89835. * @param className defines the class name to instantiate
  89836. * @returns the new object or null if the system was not able to do the instantiation
  89837. */
  89838. static Instantiate(className: string): any;
  89839. /**
  89840. * Provides a slice function that will work even on IE
  89841. * @param data defines the array to slice
  89842. * @param start defines the start of the data (optional)
  89843. * @param end defines the end of the data (optional)
  89844. * @returns the new sliced array
  89845. */
  89846. static Slice<T>(data: T, start?: number, end?: number): T;
  89847. /**
  89848. * Polyfill for setImmediate
  89849. * @param action defines the action to execute after the current execution block
  89850. */
  89851. static SetImmediate(action: () => void): void;
  89852. /**
  89853. * Function indicating if a number is an exponent of 2
  89854. * @param value defines the value to test
  89855. * @returns true if the value is an exponent of 2
  89856. */
  89857. static IsExponentOfTwo(value: number): boolean;
  89858. private static _tmpFloatArray;
  89859. /**
  89860. * Returns the nearest 32-bit single precision float representation of a Number
  89861. * @param value A Number. If the parameter is of a different type, it will get converted
  89862. * to a number or to NaN if it cannot be converted
  89863. * @returns number
  89864. */
  89865. static FloatRound(value: number): number;
  89866. /**
  89867. * Find the next highest power of two.
  89868. * @param x Number to start search from.
  89869. * @return Next highest power of two.
  89870. */
  89871. static CeilingPOT(x: number): number;
  89872. /**
  89873. * Find the next lowest power of two.
  89874. * @param x Number to start search from.
  89875. * @return Next lowest power of two.
  89876. */
  89877. static FloorPOT(x: number): number;
  89878. /**
  89879. * Find the nearest power of two.
  89880. * @param x Number to start search from.
  89881. * @return Next nearest power of two.
  89882. */
  89883. static NearestPOT(x: number): number;
  89884. /**
  89885. * Get the closest exponent of two
  89886. * @param value defines the value to approximate
  89887. * @param max defines the maximum value to return
  89888. * @param mode defines how to define the closest value
  89889. * @returns closest exponent of two of the given value
  89890. */
  89891. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89892. /**
  89893. * Extracts the filename from a path
  89894. * @param path defines the path to use
  89895. * @returns the filename
  89896. */
  89897. static GetFilename(path: string): string;
  89898. /**
  89899. * Extracts the "folder" part of a path (everything before the filename).
  89900. * @param uri The URI to extract the info from
  89901. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89902. * @returns The "folder" part of the path
  89903. */
  89904. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89905. /**
  89906. * Extracts text content from a DOM element hierarchy
  89907. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89908. */
  89909. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89910. /**
  89911. * Convert an angle in radians to degrees
  89912. * @param angle defines the angle to convert
  89913. * @returns the angle in degrees
  89914. */
  89915. static ToDegrees(angle: number): number;
  89916. /**
  89917. * Convert an angle in degrees to radians
  89918. * @param angle defines the angle to convert
  89919. * @returns the angle in radians
  89920. */
  89921. static ToRadians(angle: number): number;
  89922. /**
  89923. * Encode a buffer to a base64 string
  89924. * @param buffer defines the buffer to encode
  89925. * @returns the encoded string
  89926. */
  89927. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89928. /**
  89929. * Extracts minimum and maximum values from a list of indexed positions
  89930. * @param positions defines the positions to use
  89931. * @param indices defines the indices to the positions
  89932. * @param indexStart defines the start index
  89933. * @param indexCount defines the end index
  89934. * @param bias defines bias value to add to the result
  89935. * @return minimum and maximum values
  89936. */
  89937. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89938. minimum: Vector3;
  89939. maximum: Vector3;
  89940. };
  89941. /**
  89942. * Extracts minimum and maximum values from a list of positions
  89943. * @param positions defines the positions to use
  89944. * @param start defines the start index in the positions array
  89945. * @param count defines the number of positions to handle
  89946. * @param bias defines bias value to add to the result
  89947. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89948. * @return minimum and maximum values
  89949. */
  89950. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89951. minimum: Vector3;
  89952. maximum: Vector3;
  89953. };
  89954. /**
  89955. * Returns an array if obj is not an array
  89956. * @param obj defines the object to evaluate as an array
  89957. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89958. * @returns either obj directly if obj is an array or a new array containing obj
  89959. */
  89960. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89961. /**
  89962. * Gets the pointer prefix to use
  89963. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89964. */
  89965. static GetPointerPrefix(): string;
  89966. /**
  89967. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89968. * @param func - the function to be called
  89969. * @param requester - the object that will request the next frame. Falls back to window.
  89970. * @returns frame number
  89971. */
  89972. static QueueNewFrame(func: () => void, requester?: any): number;
  89973. /**
  89974. * Ask the browser to promote the current element to fullscreen rendering mode
  89975. * @param element defines the DOM element to promote
  89976. */
  89977. static RequestFullscreen(element: HTMLElement): void;
  89978. /**
  89979. * Asks the browser to exit fullscreen mode
  89980. */
  89981. static ExitFullscreen(): void;
  89982. /**
  89983. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89984. * @param url define the url we are trying
  89985. * @param element define the dom element where to configure the cors policy
  89986. */
  89987. static SetCorsBehavior(url: string | string[], element: {
  89988. crossOrigin: string | null;
  89989. }): void;
  89990. /**
  89991. * Removes unwanted characters from an url
  89992. * @param url defines the url to clean
  89993. * @returns the cleaned url
  89994. */
  89995. static CleanUrl(url: string): string;
  89996. /**
  89997. * Gets or sets a function used to pre-process url before using them to load assets
  89998. */
  89999. static PreprocessUrl: (url: string) => string;
  90000. /**
  90001. * Loads an image as an HTMLImageElement.
  90002. * @param input url string, ArrayBuffer, or Blob to load
  90003. * @param onLoad callback called when the image successfully loads
  90004. * @param onError callback called when the image fails to load
  90005. * @param offlineProvider offline provider for caching
  90006. * @returns the HTMLImageElement of the loaded image
  90007. */
  90008. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90009. /**
  90010. * Loads a file
  90011. * @param url url string, ArrayBuffer, or Blob to load
  90012. * @param onSuccess callback called when the file successfully loads
  90013. * @param onProgress callback called while file is loading (if the server supports this mode)
  90014. * @param offlineProvider defines the offline provider for caching
  90015. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90016. * @param onError callback called when the file fails to load
  90017. * @returns a file request object
  90018. */
  90019. 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;
  90020. /**
  90021. * Load a script (identified by an url). When the url returns, the
  90022. * content of this file is added into a new script element, attached to the DOM (body element)
  90023. * @param scriptUrl defines the url of the script to laod
  90024. * @param onSuccess defines the callback called when the script is loaded
  90025. * @param onError defines the callback to call if an error occurs
  90026. * @param scriptId defines the id of the script element
  90027. */
  90028. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90029. /**
  90030. * Load an asynchronous script (identified by an url). When the url returns, the
  90031. * content of this file is added into a new script element, attached to the DOM (body element)
  90032. * @param scriptUrl defines the url of the script to laod
  90033. * @param scriptId defines the id of the script element
  90034. * @returns a promise request object
  90035. */
  90036. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90037. /**
  90038. * Loads a file from a blob
  90039. * @param fileToLoad defines the blob to use
  90040. * @param callback defines the callback to call when data is loaded
  90041. * @param progressCallback defines the callback to call during loading process
  90042. * @returns a file request object
  90043. */
  90044. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90045. /**
  90046. * Loads a file
  90047. * @param fileToLoad defines the file to load
  90048. * @param callback defines the callback to call when data is loaded
  90049. * @param progressCallBack defines the callback to call during loading process
  90050. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90051. * @returns a file request object
  90052. */
  90053. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90054. /**
  90055. * Creates a data url from a given string content
  90056. * @param content defines the content to convert
  90057. * @returns the new data url link
  90058. */
  90059. static FileAsURL(content: string): string;
  90060. /**
  90061. * Format the given number to a specific decimal format
  90062. * @param value defines the number to format
  90063. * @param decimals defines the number of decimals to use
  90064. * @returns the formatted string
  90065. */
  90066. static Format(value: number, decimals?: number): string;
  90067. /**
  90068. * Checks if a given vector is inside a specific range
  90069. * @param v defines the vector to test
  90070. * @param min defines the minimum range
  90071. * @param max defines the maximum range
  90072. */
  90073. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90074. /**
  90075. * Tries to copy an object by duplicating every property
  90076. * @param source defines the source object
  90077. * @param destination defines the target object
  90078. * @param doNotCopyList defines a list of properties to avoid
  90079. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90080. */
  90081. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90082. /**
  90083. * Gets a boolean indicating if the given object has no own property
  90084. * @param obj defines the object to test
  90085. * @returns true if object has no own property
  90086. */
  90087. static IsEmpty(obj: any): boolean;
  90088. /**
  90089. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90090. * @param str Source string
  90091. * @param suffix Suffix to search for in the source string
  90092. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90093. */
  90094. static EndsWith(str: string, suffix: string): boolean;
  90095. /**
  90096. * Function used to register events at window level
  90097. * @param events defines the events to register
  90098. */
  90099. static RegisterTopRootEvents(events: {
  90100. name: string;
  90101. handler: Nullable<(e: FocusEvent) => any>;
  90102. }[]): void;
  90103. /**
  90104. * Function used to unregister events from window level
  90105. * @param events defines the events to unregister
  90106. */
  90107. static UnregisterTopRootEvents(events: {
  90108. name: string;
  90109. handler: Nullable<(e: FocusEvent) => any>;
  90110. }[]): void;
  90111. /**
  90112. * @ignore
  90113. */
  90114. static _ScreenshotCanvas: HTMLCanvasElement;
  90115. /**
  90116. * Dumps the current bound framebuffer
  90117. * @param width defines the rendering width
  90118. * @param height defines the rendering height
  90119. * @param engine defines the hosting engine
  90120. * @param successCallback defines the callback triggered once the data are available
  90121. * @param mimeType defines the mime type of the result
  90122. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90123. */
  90124. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90125. /**
  90126. * Converts the canvas data to blob.
  90127. * This acts as a polyfill for browsers not supporting the to blob function.
  90128. * @param canvas Defines the canvas to extract the data from
  90129. * @param successCallback Defines the callback triggered once the data are available
  90130. * @param mimeType Defines the mime type of the result
  90131. */
  90132. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90133. /**
  90134. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90135. * @param successCallback defines the callback triggered once the data are available
  90136. * @param mimeType defines the mime type of the result
  90137. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90138. */
  90139. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90140. /**
  90141. * Downloads a blob in the browser
  90142. * @param blob defines the blob to download
  90143. * @param fileName defines the name of the downloaded file
  90144. */
  90145. static Download(blob: Blob, fileName: string): void;
  90146. /**
  90147. * Captures a screenshot of the current rendering
  90148. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90149. * @param engine defines the rendering engine
  90150. * @param camera defines the source camera
  90151. * @param size This parameter can be set to a single number or to an object with the
  90152. * following (optional) properties: precision, width, height. If a single number is passed,
  90153. * it will be used for both width and height. If an object is passed, the screenshot size
  90154. * will be derived from the parameters. The precision property is a multiplier allowing
  90155. * rendering at a higher or lower resolution
  90156. * @param successCallback defines the callback receives a single parameter which contains the
  90157. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90158. * src parameter of an <img> to display it
  90159. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90160. * Check your browser for supported MIME types
  90161. */
  90162. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90163. /**
  90164. * Generates an image screenshot from the specified camera.
  90165. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90166. * @param engine The engine to use for rendering
  90167. * @param camera The camera to use for rendering
  90168. * @param size This parameter can be set to a single number or to an object with the
  90169. * following (optional) properties: precision, width, height. If a single number is passed,
  90170. * it will be used for both width and height. If an object is passed, the screenshot size
  90171. * will be derived from the parameters. The precision property is a multiplier allowing
  90172. * rendering at a higher or lower resolution
  90173. * @param successCallback The callback receives a single parameter which contains the
  90174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90175. * src parameter of an <img> to display it
  90176. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90177. * Check your browser for supported MIME types
  90178. * @param samples Texture samples (default: 1)
  90179. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90180. * @param fileName A name for for the downloaded file.
  90181. */
  90182. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90183. /**
  90184. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90185. * Be aware Math.random() could cause collisions, but:
  90186. * "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"
  90187. * @returns a pseudo random id
  90188. */
  90189. static RandomId(): string;
  90190. /**
  90191. * Test if the given uri is a base64 string
  90192. * @param uri The uri to test
  90193. * @return True if the uri is a base64 string or false otherwise
  90194. */
  90195. static IsBase64(uri: string): boolean;
  90196. /**
  90197. * Decode the given base64 uri.
  90198. * @param uri The uri to decode
  90199. * @return The decoded base64 data.
  90200. */
  90201. static DecodeBase64(uri: string): ArrayBuffer;
  90202. /**
  90203. * No log
  90204. */
  90205. static readonly NoneLogLevel: number;
  90206. /**
  90207. * Only message logs
  90208. */
  90209. static readonly MessageLogLevel: number;
  90210. /**
  90211. * Only warning logs
  90212. */
  90213. static readonly WarningLogLevel: number;
  90214. /**
  90215. * Only error logs
  90216. */
  90217. static readonly ErrorLogLevel: number;
  90218. /**
  90219. * All logs
  90220. */
  90221. static readonly AllLogLevel: number;
  90222. /**
  90223. * Gets a value indicating the number of loading errors
  90224. * @ignorenaming
  90225. */
  90226. static readonly errorsCount: number;
  90227. /**
  90228. * Callback called when a new log is added
  90229. */
  90230. static OnNewCacheEntry: (entry: string) => void;
  90231. /**
  90232. * Log a message to the console
  90233. * @param message defines the message to log
  90234. */
  90235. static Log(message: string): void;
  90236. /**
  90237. * Write a warning message to the console
  90238. * @param message defines the message to log
  90239. */
  90240. static Warn(message: string): void;
  90241. /**
  90242. * Write an error message to the console
  90243. * @param message defines the message to log
  90244. */
  90245. static Error(message: string): void;
  90246. /**
  90247. * Gets current log cache (list of logs)
  90248. */
  90249. static readonly LogCache: string;
  90250. /**
  90251. * Clears the log cache
  90252. */
  90253. static ClearLogCache(): void;
  90254. /**
  90255. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90256. */
  90257. static LogLevels: number;
  90258. /**
  90259. * Checks if the loaded document was accessed via `file:`-Protocol.
  90260. * @returns boolean
  90261. */
  90262. static IsFileURL(): boolean;
  90263. /**
  90264. * Checks if the window object exists
  90265. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90266. */
  90267. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90268. /**
  90269. * No performance log
  90270. */
  90271. static readonly PerformanceNoneLogLevel: number;
  90272. /**
  90273. * Use user marks to log performance
  90274. */
  90275. static readonly PerformanceUserMarkLogLevel: number;
  90276. /**
  90277. * Log performance to the console
  90278. */
  90279. static readonly PerformanceConsoleLogLevel: number;
  90280. private static _performance;
  90281. /**
  90282. * Sets the current performance log level
  90283. */
  90284. static PerformanceLogLevel: number;
  90285. private static _StartPerformanceCounterDisabled;
  90286. private static _EndPerformanceCounterDisabled;
  90287. private static _StartUserMark;
  90288. private static _EndUserMark;
  90289. private static _StartPerformanceConsole;
  90290. private static _EndPerformanceConsole;
  90291. /**
  90292. * Starts a performance counter
  90293. */
  90294. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90295. /**
  90296. * Ends a specific performance coutner
  90297. */
  90298. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90299. /**
  90300. * Gets either window.performance.now() if supported or Date.now() else
  90301. */
  90302. static readonly Now: number;
  90303. /**
  90304. * This method will return the name of the class used to create the instance of the given object.
  90305. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90306. * @param object the object to get the class name from
  90307. * @param isType defines if the object is actually a type
  90308. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90309. */
  90310. static GetClassName(object: any, isType?: boolean): string;
  90311. /**
  90312. * Gets the first element of an array satisfying a given predicate
  90313. * @param array defines the array to browse
  90314. * @param predicate defines the predicate to use
  90315. * @returns null if not found or the element
  90316. */
  90317. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90318. /**
  90319. * This method will return the name of the full name of the class, including its owning module (if any).
  90320. * 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).
  90321. * @param object the object to get the class name from
  90322. * @param isType defines if the object is actually a type
  90323. * @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.
  90324. * @ignorenaming
  90325. */
  90326. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90327. /**
  90328. * Returns a promise that resolves after the given amount of time.
  90329. * @param delay Number of milliseconds to delay
  90330. * @returns Promise that resolves after the given amount of time
  90331. */
  90332. static DelayAsync(delay: number): Promise<void>;
  90333. /**
  90334. * Gets the current gradient from an array of IValueGradient
  90335. * @param ratio defines the current ratio to get
  90336. * @param gradients defines the array of IValueGradient
  90337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90338. */
  90339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90340. }
  90341. /**
  90342. * This class is used to track a performance counter which is number based.
  90343. * The user has access to many properties which give statistics of different nature.
  90344. *
  90345. * The implementer can track two kinds of Performance Counter: time and count.
  90346. * 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.
  90347. * 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.
  90348. */
  90349. export class PerfCounter {
  90350. /**
  90351. * Gets or sets a global boolean to turn on and off all the counters
  90352. */
  90353. static Enabled: boolean;
  90354. /**
  90355. * Returns the smallest value ever
  90356. */
  90357. readonly min: number;
  90358. /**
  90359. * Returns the biggest value ever
  90360. */
  90361. readonly max: number;
  90362. /**
  90363. * Returns the average value since the performance counter is running
  90364. */
  90365. readonly average: number;
  90366. /**
  90367. * Returns the average value of the last second the counter was monitored
  90368. */
  90369. readonly lastSecAverage: number;
  90370. /**
  90371. * Returns the current value
  90372. */
  90373. readonly current: number;
  90374. /**
  90375. * Gets the accumulated total
  90376. */
  90377. readonly total: number;
  90378. /**
  90379. * Gets the total value count
  90380. */
  90381. readonly count: number;
  90382. /**
  90383. * Creates a new counter
  90384. */
  90385. constructor();
  90386. /**
  90387. * Call this method to start monitoring a new frame.
  90388. * 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.
  90389. */
  90390. fetchNewFrame(): void;
  90391. /**
  90392. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90393. * @param newCount the count value to add to the monitored count
  90394. * @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.
  90395. */
  90396. addCount(newCount: number, fetchResult: boolean): void;
  90397. /**
  90398. * Start monitoring this performance counter
  90399. */
  90400. beginMonitoring(): void;
  90401. /**
  90402. * Compute the time lapsed since the previous beginMonitoring() call.
  90403. * @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
  90404. */
  90405. endMonitoring(newFrame?: boolean): void;
  90406. private _fetchResult;
  90407. private _startMonitoringTime;
  90408. private _min;
  90409. private _max;
  90410. private _average;
  90411. private _current;
  90412. private _totalValueCount;
  90413. private _totalAccumulated;
  90414. private _lastSecAverage;
  90415. private _lastSecAccumulated;
  90416. private _lastSecTime;
  90417. private _lastSecValueCount;
  90418. }
  90419. /**
  90420. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90421. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90422. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90423. * @param name The name of the class, case should be preserved
  90424. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90425. */
  90426. export function className(name: string, module?: string): (target: Object) => void;
  90427. /**
  90428. * An implementation of a loop for asynchronous functions.
  90429. */
  90430. export class AsyncLoop {
  90431. /**
  90432. * Defines the number of iterations for the loop
  90433. */
  90434. iterations: number;
  90435. /**
  90436. * Defines the current index of the loop.
  90437. */
  90438. index: number;
  90439. private _done;
  90440. private _fn;
  90441. private _successCallback;
  90442. /**
  90443. * Constructor.
  90444. * @param iterations the number of iterations.
  90445. * @param func the function to run each iteration
  90446. * @param successCallback the callback that will be called upon succesful execution
  90447. * @param offset starting offset.
  90448. */
  90449. constructor(
  90450. /**
  90451. * Defines the number of iterations for the loop
  90452. */
  90453. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90454. /**
  90455. * Execute the next iteration. Must be called after the last iteration was finished.
  90456. */
  90457. executeNext(): void;
  90458. /**
  90459. * Break the loop and run the success callback.
  90460. */
  90461. breakLoop(): void;
  90462. /**
  90463. * Create and run an async loop.
  90464. * @param iterations the number of iterations.
  90465. * @param fn the function to run each iteration
  90466. * @param successCallback the callback that will be called upon succesful execution
  90467. * @param offset starting offset.
  90468. * @returns the created async loop object
  90469. */
  90470. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90471. /**
  90472. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90473. * @param iterations total number of iterations
  90474. * @param syncedIterations number of synchronous iterations in each async iteration.
  90475. * @param fn the function to call each iteration.
  90476. * @param callback a success call back that will be called when iterating stops.
  90477. * @param breakFunction a break condition (optional)
  90478. * @param timeout timeout settings for the setTimeout function. default - 0.
  90479. * @returns the created async loop object
  90480. */
  90481. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90482. }
  90483. }
  90484. declare module BABYLON {
  90485. /** @hidden */
  90486. export interface ICollisionCoordinator {
  90487. createCollider(): Collider;
  90488. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90489. init(scene: Scene): void;
  90490. }
  90491. /** @hidden */
  90492. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90493. private _scene;
  90494. private _scaledPosition;
  90495. private _scaledVelocity;
  90496. private _finalPosition;
  90497. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90498. createCollider(): Collider;
  90499. init(scene: Scene): void;
  90500. private _collideWithWorld;
  90501. }
  90502. }
  90503. declare module BABYLON {
  90504. /**
  90505. * This class defines the direct association between an animation and a target
  90506. */
  90507. export class TargetedAnimation {
  90508. /**
  90509. * Animation to perform
  90510. */
  90511. animation: Animation;
  90512. /**
  90513. * Target to animate
  90514. */
  90515. target: any;
  90516. }
  90517. /**
  90518. * Use this class to create coordinated animations on multiple targets
  90519. */
  90520. export class AnimationGroup implements IDisposable {
  90521. /** The name of the animation group */
  90522. name: string;
  90523. private _scene;
  90524. private _targetedAnimations;
  90525. private _animatables;
  90526. private _from;
  90527. private _to;
  90528. private _isStarted;
  90529. private _isPaused;
  90530. private _speedRatio;
  90531. /**
  90532. * Gets or sets the unique id of the node
  90533. */
  90534. uniqueId: number;
  90535. /**
  90536. * This observable will notify when one animation have ended
  90537. */
  90538. onAnimationEndObservable: Observable<TargetedAnimation>;
  90539. /**
  90540. * Observer raised when one animation loops
  90541. */
  90542. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90543. /**
  90544. * This observable will notify when all animations have ended.
  90545. */
  90546. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90547. /**
  90548. * This observable will notify when all animations have paused.
  90549. */
  90550. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90551. /**
  90552. * This observable will notify when all animations are playing.
  90553. */
  90554. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90555. /**
  90556. * Gets the first frame
  90557. */
  90558. readonly from: number;
  90559. /**
  90560. * Gets the last frame
  90561. */
  90562. readonly to: number;
  90563. /**
  90564. * Define if the animations are started
  90565. */
  90566. readonly isStarted: boolean;
  90567. /**
  90568. * Gets a value indicating that the current group is playing
  90569. */
  90570. readonly isPlaying: boolean;
  90571. /**
  90572. * Gets or sets the speed ratio to use for all animations
  90573. */
  90574. /**
  90575. * Gets or sets the speed ratio to use for all animations
  90576. */
  90577. speedRatio: number;
  90578. /**
  90579. * Gets the targeted animations for this animation group
  90580. */
  90581. readonly targetedAnimations: Array<TargetedAnimation>;
  90582. /**
  90583. * returning the list of animatables controlled by this animation group.
  90584. */
  90585. readonly animatables: Array<Animatable>;
  90586. /**
  90587. * Instantiates a new Animation Group.
  90588. * This helps managing several animations at once.
  90589. * @see http://doc.babylonjs.com/how_to/group
  90590. * @param name Defines the name of the group
  90591. * @param scene Defines the scene the group belongs to
  90592. */
  90593. constructor(
  90594. /** The name of the animation group */
  90595. name: string, scene?: Nullable<Scene>);
  90596. /**
  90597. * Add an animation (with its target) in the group
  90598. * @param animation defines the animation we want to add
  90599. * @param target defines the target of the animation
  90600. * @returns the TargetedAnimation object
  90601. */
  90602. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90603. /**
  90604. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90605. * It can add constant keys at begin or end
  90606. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90607. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90608. * @returns the animation group
  90609. */
  90610. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90611. /**
  90612. * Start all animations on given targets
  90613. * @param loop defines if animations must loop
  90614. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90615. * @param from defines the from key (optional)
  90616. * @param to defines the to key (optional)
  90617. * @returns the current animation group
  90618. */
  90619. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90620. /**
  90621. * Pause all animations
  90622. * @returns the animation group
  90623. */
  90624. pause(): AnimationGroup;
  90625. /**
  90626. * Play all animations to initial state
  90627. * This function will start() the animations if they were not started or will restart() them if they were paused
  90628. * @param loop defines if animations must loop
  90629. * @returns the animation group
  90630. */
  90631. play(loop?: boolean): AnimationGroup;
  90632. /**
  90633. * Reset all animations to initial state
  90634. * @returns the animation group
  90635. */
  90636. reset(): AnimationGroup;
  90637. /**
  90638. * Restart animations from key 0
  90639. * @returns the animation group
  90640. */
  90641. restart(): AnimationGroup;
  90642. /**
  90643. * Stop all animations
  90644. * @returns the animation group
  90645. */
  90646. stop(): AnimationGroup;
  90647. /**
  90648. * Set animation weight for all animatables
  90649. * @param weight defines the weight to use
  90650. * @return the animationGroup
  90651. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90652. */
  90653. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90654. /**
  90655. * Synchronize and normalize all animatables with a source animatable
  90656. * @param root defines the root animatable to synchronize with
  90657. * @return the animationGroup
  90658. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90659. */
  90660. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90661. /**
  90662. * Goes to a specific frame in this animation group
  90663. * @param frame the frame number to go to
  90664. * @return the animationGroup
  90665. */
  90666. goToFrame(frame: number): AnimationGroup;
  90667. /**
  90668. * Dispose all associated resources
  90669. */
  90670. dispose(): void;
  90671. private _checkAnimationGroupEnded;
  90672. /**
  90673. * Clone the current animation group and returns a copy
  90674. * @param newName defines the name of the new group
  90675. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90676. * @returns the new aniamtion group
  90677. */
  90678. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90679. /**
  90680. * Returns a new AnimationGroup object parsed from the source provided.
  90681. * @param parsedAnimationGroup defines the source
  90682. * @param scene defines the scene that will receive the animationGroup
  90683. * @returns a new AnimationGroup
  90684. */
  90685. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90686. /**
  90687. * Returns the string "AnimationGroup"
  90688. * @returns "AnimationGroup"
  90689. */
  90690. getClassName(): string;
  90691. /**
  90692. * Creates a detailled string about the object
  90693. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90694. * @returns a string representing the object
  90695. */
  90696. toString(fullDetails?: boolean): string;
  90697. }
  90698. }
  90699. declare module BABYLON {
  90700. /**
  90701. * Define an interface for all classes that will hold resources
  90702. */
  90703. export interface IDisposable {
  90704. /**
  90705. * Releases all held resources
  90706. */
  90707. dispose(): void;
  90708. }
  90709. /** Interface defining initialization parameters for Scene class */
  90710. export interface SceneOptions {
  90711. /**
  90712. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90713. * It will improve performance when the number of geometries becomes important.
  90714. */
  90715. useGeometryUniqueIdsMap?: boolean;
  90716. /**
  90717. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90718. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90719. */
  90720. useMaterialMeshMap?: boolean;
  90721. /**
  90722. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90723. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90724. */
  90725. useClonedMeshhMap?: boolean;
  90726. }
  90727. /**
  90728. * Represents a scene to be rendered by the engine.
  90729. * @see http://doc.babylonjs.com/features/scene
  90730. */
  90731. export class Scene extends AbstractScene implements IAnimatable {
  90732. private static _uniqueIdCounter;
  90733. /** The fog is deactivated */
  90734. static readonly FOGMODE_NONE: number;
  90735. /** The fog density is following an exponential function */
  90736. static readonly FOGMODE_EXP: number;
  90737. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90738. static readonly FOGMODE_EXP2: number;
  90739. /** The fog density is following a linear function. */
  90740. static readonly FOGMODE_LINEAR: number;
  90741. /**
  90742. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90743. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90744. */
  90745. static MinDeltaTime: number;
  90746. /**
  90747. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90748. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90749. */
  90750. static MaxDeltaTime: number;
  90751. /**
  90752. * Factory used to create the default material.
  90753. * @param name The name of the material to create
  90754. * @param scene The scene to create the material for
  90755. * @returns The default material
  90756. */
  90757. static DefaultMaterialFactory(scene: Scene): Material;
  90758. /**
  90759. * Factory used to create the a collision coordinator.
  90760. * @returns The collision coordinator
  90761. */
  90762. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  90763. /** @hidden */
  90764. readonly _isScene: boolean;
  90765. /**
  90766. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  90767. */
  90768. autoClear: boolean;
  90769. /**
  90770. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  90771. */
  90772. autoClearDepthAndStencil: boolean;
  90773. /**
  90774. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  90775. */
  90776. clearColor: Color4;
  90777. /**
  90778. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  90779. */
  90780. ambientColor: Color3;
  90781. /**
  90782. * This is use to store the default BRDF lookup for PBR materials in your scene.
  90783. * It should only be one of the following (if not the default embedded one):
  90784. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  90785. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  90786. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  90787. * The material properties need to be setup according to the type of texture in use.
  90788. */
  90789. environmentBRDFTexture: BaseTexture;
  90790. /** @hidden */
  90791. protected _environmentTexture: Nullable<BaseTexture>;
  90792. /**
  90793. * Texture used in all pbr material as the reflection texture.
  90794. * As in the majority of the scene they are the same (exception for multi room and so on),
  90795. * this is easier to reference from here than from all the materials.
  90796. */
  90797. /**
  90798. * Texture used in all pbr material as the reflection texture.
  90799. * As in the majority of the scene they are the same (exception for multi room and so on),
  90800. * this is easier to set here than in all the materials.
  90801. */
  90802. environmentTexture: Nullable<BaseTexture>;
  90803. /** @hidden */
  90804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90805. /**
  90806. * Default image processing configuration used either in the rendering
  90807. * Forward main pass or through the imageProcessingPostProcess if present.
  90808. * As in the majority of the scene they are the same (exception for multi camera),
  90809. * this is easier to reference from here than from all the materials and post process.
  90810. *
  90811. * No setter as we it is a shared configuration, you can set the values instead.
  90812. */
  90813. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90814. private _forceWireframe;
  90815. /**
  90816. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90817. */
  90818. forceWireframe: boolean;
  90819. private _forcePointsCloud;
  90820. /**
  90821. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90822. */
  90823. forcePointsCloud: boolean;
  90824. /**
  90825. * Gets or sets the active clipplane 1
  90826. */
  90827. clipPlane: Nullable<Plane>;
  90828. /**
  90829. * Gets or sets the active clipplane 2
  90830. */
  90831. clipPlane2: Nullable<Plane>;
  90832. /**
  90833. * Gets or sets the active clipplane 3
  90834. */
  90835. clipPlane3: Nullable<Plane>;
  90836. /**
  90837. * Gets or sets the active clipplane 4
  90838. */
  90839. clipPlane4: Nullable<Plane>;
  90840. /**
  90841. * Gets or sets a boolean indicating if animations are enabled
  90842. */
  90843. animationsEnabled: boolean;
  90844. private _animationPropertiesOverride;
  90845. /**
  90846. * Gets or sets the animation properties override
  90847. */
  90848. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90849. /**
  90850. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90851. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90852. */
  90853. useConstantAnimationDeltaTime: boolean;
  90854. /**
  90855. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90856. * Please note that it requires to run a ray cast through the scene on every frame
  90857. */
  90858. constantlyUpdateMeshUnderPointer: boolean;
  90859. /**
  90860. * Defines the HTML cursor to use when hovering over interactive elements
  90861. */
  90862. hoverCursor: string;
  90863. /**
  90864. * Defines the HTML default cursor to use (empty by default)
  90865. */
  90866. defaultCursor: string;
  90867. /**
  90868. * This is used to call preventDefault() on pointer down
  90869. * in order to block unwanted artifacts like system double clicks
  90870. */
  90871. preventDefaultOnPointerDown: boolean;
  90872. /**
  90873. * This is used to call preventDefault() on pointer up
  90874. * in order to block unwanted artifacts like system double clicks
  90875. */
  90876. preventDefaultOnPointerUp: boolean;
  90877. /**
  90878. * Gets or sets user defined metadata
  90879. */
  90880. metadata: any;
  90881. /**
  90882. * For internal use only. Please do not use.
  90883. */
  90884. reservedDataStore: any;
  90885. /**
  90886. * Gets the name of the plugin used to load this scene (null by default)
  90887. */
  90888. loadingPluginName: string;
  90889. /**
  90890. * Use this array to add regular expressions used to disable offline support for specific urls
  90891. */
  90892. disableOfflineSupportExceptionRules: RegExp[];
  90893. /**
  90894. * An event triggered when the scene is disposed.
  90895. */
  90896. onDisposeObservable: Observable<Scene>;
  90897. private _onDisposeObserver;
  90898. /** Sets a function to be executed when this scene is disposed. */
  90899. onDispose: () => void;
  90900. /**
  90901. * An event triggered before rendering the scene (right after animations and physics)
  90902. */
  90903. onBeforeRenderObservable: Observable<Scene>;
  90904. private _onBeforeRenderObserver;
  90905. /** Sets a function to be executed before rendering this scene */
  90906. beforeRender: Nullable<() => void>;
  90907. /**
  90908. * An event triggered after rendering the scene
  90909. */
  90910. onAfterRenderObservable: Observable<Scene>;
  90911. private _onAfterRenderObserver;
  90912. /** Sets a function to be executed after rendering this scene */
  90913. afterRender: Nullable<() => void>;
  90914. /**
  90915. * An event triggered before animating the scene
  90916. */
  90917. onBeforeAnimationsObservable: Observable<Scene>;
  90918. /**
  90919. * An event triggered after animations processing
  90920. */
  90921. onAfterAnimationsObservable: Observable<Scene>;
  90922. /**
  90923. * An event triggered before draw calls are ready to be sent
  90924. */
  90925. onBeforeDrawPhaseObservable: Observable<Scene>;
  90926. /**
  90927. * An event triggered after draw calls have been sent
  90928. */
  90929. onAfterDrawPhaseObservable: Observable<Scene>;
  90930. /**
  90931. * An event triggered when the scene is ready
  90932. */
  90933. onReadyObservable: Observable<Scene>;
  90934. /**
  90935. * An event triggered before rendering a camera
  90936. */
  90937. onBeforeCameraRenderObservable: Observable<Camera>;
  90938. private _onBeforeCameraRenderObserver;
  90939. /** Sets a function to be executed before rendering a camera*/
  90940. beforeCameraRender: () => void;
  90941. /**
  90942. * An event triggered after rendering a camera
  90943. */
  90944. onAfterCameraRenderObservable: Observable<Camera>;
  90945. private _onAfterCameraRenderObserver;
  90946. /** Sets a function to be executed after rendering a camera*/
  90947. afterCameraRender: () => void;
  90948. /**
  90949. * An event triggered when active meshes evaluation is about to start
  90950. */
  90951. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90952. /**
  90953. * An event triggered when active meshes evaluation is done
  90954. */
  90955. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90956. /**
  90957. * An event triggered when particles rendering is about to start
  90958. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90959. */
  90960. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90961. /**
  90962. * An event triggered when particles rendering is done
  90963. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90964. */
  90965. onAfterParticlesRenderingObservable: Observable<Scene>;
  90966. /**
  90967. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90968. */
  90969. onDataLoadedObservable: Observable<Scene>;
  90970. /**
  90971. * An event triggered when a camera is created
  90972. */
  90973. onNewCameraAddedObservable: Observable<Camera>;
  90974. /**
  90975. * An event triggered when a camera is removed
  90976. */
  90977. onCameraRemovedObservable: Observable<Camera>;
  90978. /**
  90979. * An event triggered when a light is created
  90980. */
  90981. onNewLightAddedObservable: Observable<Light>;
  90982. /**
  90983. * An event triggered when a light is removed
  90984. */
  90985. onLightRemovedObservable: Observable<Light>;
  90986. /**
  90987. * An event triggered when a geometry is created
  90988. */
  90989. onNewGeometryAddedObservable: Observable<Geometry>;
  90990. /**
  90991. * An event triggered when a geometry is removed
  90992. */
  90993. onGeometryRemovedObservable: Observable<Geometry>;
  90994. /**
  90995. * An event triggered when a transform node is created
  90996. */
  90997. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90998. /**
  90999. * An event triggered when a transform node is removed
  91000. */
  91001. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91002. /**
  91003. * An event triggered when a mesh is created
  91004. */
  91005. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91006. /**
  91007. * An event triggered when a mesh is removed
  91008. */
  91009. onMeshRemovedObservable: Observable<AbstractMesh>;
  91010. /**
  91011. * An event triggered when a skeleton is created
  91012. */
  91013. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91014. /**
  91015. * An event triggered when a skeleton is removed
  91016. */
  91017. onSkeletonRemovedObservable: Observable<Skeleton>;
  91018. /**
  91019. * An event triggered when a material is created
  91020. */
  91021. onNewMaterialAddedObservable: Observable<Material>;
  91022. /**
  91023. * An event triggered when a material is removed
  91024. */
  91025. onMaterialRemovedObservable: Observable<Material>;
  91026. /**
  91027. * An event triggered when a texture is created
  91028. */
  91029. onNewTextureAddedObservable: Observable<BaseTexture>;
  91030. /**
  91031. * An event triggered when a texture is removed
  91032. */
  91033. onTextureRemovedObservable: Observable<BaseTexture>;
  91034. /**
  91035. * An event triggered when render targets are about to be rendered
  91036. * Can happen multiple times per frame.
  91037. */
  91038. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91039. /**
  91040. * An event triggered when render targets were rendered.
  91041. * Can happen multiple times per frame.
  91042. */
  91043. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91044. /**
  91045. * An event triggered before calculating deterministic simulation step
  91046. */
  91047. onBeforeStepObservable: Observable<Scene>;
  91048. /**
  91049. * An event triggered after calculating deterministic simulation step
  91050. */
  91051. onAfterStepObservable: Observable<Scene>;
  91052. /**
  91053. * An event triggered when the activeCamera property is updated
  91054. */
  91055. onActiveCameraChanged: Observable<Scene>;
  91056. /**
  91057. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91058. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91059. * 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)
  91060. */
  91061. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91062. /**
  91063. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91064. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91065. * 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)
  91066. */
  91067. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91068. /**
  91069. * This Observable will when a mesh has been imported into the scene.
  91070. */
  91071. onMeshImportedObservable: Observable<AbstractMesh>;
  91072. /**
  91073. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91074. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91075. */
  91076. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91077. /** @hidden */
  91078. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91079. /**
  91080. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91081. */
  91082. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91083. /**
  91084. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91085. */
  91086. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91087. /**
  91088. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91089. */
  91090. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91091. private _onPointerMove;
  91092. private _onPointerDown;
  91093. private _onPointerUp;
  91094. /** Callback called when a pointer move is detected */
  91095. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91096. /** Callback called when a pointer down is detected */
  91097. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91098. /** Callback called when a pointer up is detected */
  91099. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91100. /** Callback called when a pointer pick is detected */
  91101. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91102. /**
  91103. * 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).
  91104. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91105. */
  91106. onPrePointerObservable: Observable<PointerInfoPre>;
  91107. /**
  91108. * Observable event triggered each time an input event is received from the rendering canvas
  91109. */
  91110. onPointerObservable: Observable<PointerInfo>;
  91111. /**
  91112. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91113. */
  91114. readonly unTranslatedPointer: Vector2;
  91115. /** The distance in pixel that you have to move to prevent some events */
  91116. static DragMovementThreshold: number;
  91117. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91118. static LongPressDelay: number;
  91119. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91120. static DoubleClickDelay: number;
  91121. /** If you need to check double click without raising a single click at first click, enable this flag */
  91122. static ExclusiveDoubleClickMode: boolean;
  91123. private _initClickEvent;
  91124. private _initActionManager;
  91125. private _delayedSimpleClick;
  91126. private _delayedSimpleClickTimeout;
  91127. private _previousDelayedSimpleClickTimeout;
  91128. private _meshPickProceed;
  91129. private _previousButtonPressed;
  91130. private _currentPickResult;
  91131. private _previousPickResult;
  91132. private _totalPointersPressed;
  91133. private _doubleClickOccured;
  91134. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91135. cameraToUseForPointers: Nullable<Camera>;
  91136. private _pointerX;
  91137. private _pointerY;
  91138. private _unTranslatedPointerX;
  91139. private _unTranslatedPointerY;
  91140. private _startingPointerPosition;
  91141. private _previousStartingPointerPosition;
  91142. private _startingPointerTime;
  91143. private _previousStartingPointerTime;
  91144. private _pointerCaptures;
  91145. private _timeAccumulator;
  91146. private _currentStepId;
  91147. private _currentInternalStep;
  91148. /** @hidden */
  91149. _mirroredCameraPosition: Nullable<Vector3>;
  91150. /**
  91151. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91152. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91153. */
  91154. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91155. /**
  91156. * Observable event triggered each time an keyboard event is received from the hosting window
  91157. */
  91158. onKeyboardObservable: Observable<KeyboardInfo>;
  91159. private _onKeyDown;
  91160. private _onKeyUp;
  91161. private _onCanvasFocusObserver;
  91162. private _onCanvasBlurObserver;
  91163. private _useRightHandedSystem;
  91164. /**
  91165. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91166. */
  91167. useRightHandedSystem: boolean;
  91168. /**
  91169. * Sets the step Id used by deterministic lock step
  91170. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91171. * @param newStepId defines the step Id
  91172. */
  91173. setStepId(newStepId: number): void;
  91174. /**
  91175. * Gets the step Id used by deterministic lock step
  91176. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91177. * @returns the step Id
  91178. */
  91179. getStepId(): number;
  91180. /**
  91181. * Gets the internal step used by deterministic lock step
  91182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91183. * @returns the internal step
  91184. */
  91185. getInternalStep(): number;
  91186. private _fogEnabled;
  91187. /**
  91188. * Gets or sets a boolean indicating if fog is enabled on this scene
  91189. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91190. * (Default is true)
  91191. */
  91192. fogEnabled: boolean;
  91193. private _fogMode;
  91194. /**
  91195. * Gets or sets the fog mode to use
  91196. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91197. * | mode | value |
  91198. * | --- | --- |
  91199. * | FOGMODE_NONE | 0 |
  91200. * | FOGMODE_EXP | 1 |
  91201. * | FOGMODE_EXP2 | 2 |
  91202. * | FOGMODE_LINEAR | 3 |
  91203. */
  91204. fogMode: number;
  91205. /**
  91206. * Gets or sets the fog color to use
  91207. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91208. * (Default is Color3(0.2, 0.2, 0.3))
  91209. */
  91210. fogColor: Color3;
  91211. /**
  91212. * Gets or sets the fog density to use
  91213. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91214. * (Default is 0.1)
  91215. */
  91216. fogDensity: number;
  91217. /**
  91218. * Gets or sets the fog start distance to use
  91219. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91220. * (Default is 0)
  91221. */
  91222. fogStart: number;
  91223. /**
  91224. * Gets or sets the fog end distance to use
  91225. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91226. * (Default is 1000)
  91227. */
  91228. fogEnd: number;
  91229. private _shadowsEnabled;
  91230. /**
  91231. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91232. */
  91233. shadowsEnabled: boolean;
  91234. private _lightsEnabled;
  91235. /**
  91236. * Gets or sets a boolean indicating if lights are enabled on this scene
  91237. */
  91238. lightsEnabled: boolean;
  91239. /** All of the active cameras added to this scene. */
  91240. activeCameras: Camera[];
  91241. /** @hidden */
  91242. _activeCamera: Nullable<Camera>;
  91243. /** Gets or sets the current active camera */
  91244. activeCamera: Nullable<Camera>;
  91245. private _defaultMaterial;
  91246. /** The default material used on meshes when no material is affected */
  91247. /** The default material used on meshes when no material is affected */
  91248. defaultMaterial: Material;
  91249. private _texturesEnabled;
  91250. /**
  91251. * Gets or sets a boolean indicating if textures are enabled on this scene
  91252. */
  91253. texturesEnabled: boolean;
  91254. /**
  91255. * Gets or sets a boolean indicating if particles are enabled on this scene
  91256. */
  91257. particlesEnabled: boolean;
  91258. /**
  91259. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91260. */
  91261. spritesEnabled: boolean;
  91262. private _skeletonsEnabled;
  91263. /**
  91264. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91265. */
  91266. skeletonsEnabled: boolean;
  91267. /**
  91268. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91269. */
  91270. lensFlaresEnabled: boolean;
  91271. /**
  91272. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91274. */
  91275. collisionsEnabled: boolean;
  91276. private _collisionCoordinator;
  91277. /** @hidden */
  91278. readonly collisionCoordinator: ICollisionCoordinator;
  91279. /**
  91280. * Defines the gravity applied to this scene (used only for collisions)
  91281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91282. */
  91283. gravity: Vector3;
  91284. /**
  91285. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91286. */
  91287. postProcessesEnabled: boolean;
  91288. /**
  91289. * The list of postprocesses added to the scene
  91290. */
  91291. postProcesses: PostProcess[];
  91292. /**
  91293. * Gets the current postprocess manager
  91294. */
  91295. postProcessManager: PostProcessManager;
  91296. /**
  91297. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91298. */
  91299. renderTargetsEnabled: boolean;
  91300. /**
  91301. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91302. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91303. */
  91304. dumpNextRenderTargets: boolean;
  91305. /**
  91306. * The list of user defined render targets added to the scene
  91307. */
  91308. customRenderTargets: RenderTargetTexture[];
  91309. /**
  91310. * Defines if texture loading must be delayed
  91311. * If true, textures will only be loaded when they need to be rendered
  91312. */
  91313. useDelayedTextureLoading: boolean;
  91314. /**
  91315. * Gets the list of meshes imported to the scene through SceneLoader
  91316. */
  91317. importedMeshesFiles: String[];
  91318. /**
  91319. * Gets or sets a boolean indicating if probes are enabled on this scene
  91320. */
  91321. probesEnabled: boolean;
  91322. /**
  91323. * Gets or sets the current offline provider to use to store scene data
  91324. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91325. */
  91326. offlineProvider: IOfflineProvider;
  91327. /**
  91328. * Gets or sets the action manager associated with the scene
  91329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91330. */
  91331. actionManager: AbstractActionManager;
  91332. private _meshesForIntersections;
  91333. /**
  91334. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91335. */
  91336. proceduralTexturesEnabled: boolean;
  91337. private _engine;
  91338. private _totalVertices;
  91339. /** @hidden */
  91340. _activeIndices: PerfCounter;
  91341. /** @hidden */
  91342. _activeParticles: PerfCounter;
  91343. /** @hidden */
  91344. _activeBones: PerfCounter;
  91345. private _animationRatio;
  91346. /** @hidden */
  91347. _animationTimeLast: number;
  91348. /** @hidden */
  91349. _animationTime: number;
  91350. /**
  91351. * Gets or sets a general scale for animation speed
  91352. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91353. */
  91354. animationTimeScale: number;
  91355. /** @hidden */
  91356. _cachedMaterial: Nullable<Material>;
  91357. /** @hidden */
  91358. _cachedEffect: Nullable<Effect>;
  91359. /** @hidden */
  91360. _cachedVisibility: Nullable<number>;
  91361. private _renderId;
  91362. private _frameId;
  91363. private _executeWhenReadyTimeoutId;
  91364. private _intermediateRendering;
  91365. private _viewUpdateFlag;
  91366. private _projectionUpdateFlag;
  91367. /** @hidden */
  91368. _toBeDisposed: Nullable<IDisposable>[];
  91369. private _activeRequests;
  91370. /** @hidden */
  91371. _pendingData: any[];
  91372. private _isDisposed;
  91373. /**
  91374. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91375. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91376. */
  91377. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91378. private _activeMeshes;
  91379. private _processedMaterials;
  91380. private _renderTargets;
  91381. /** @hidden */
  91382. _activeParticleSystems: SmartArray<IParticleSystem>;
  91383. private _activeSkeletons;
  91384. private _softwareSkinnedMeshes;
  91385. private _renderingManager;
  91386. /** @hidden */
  91387. _activeAnimatables: Animatable[];
  91388. private _transformMatrix;
  91389. private _sceneUbo;
  91390. /** @hidden */
  91391. _viewMatrix: Matrix;
  91392. private _projectionMatrix;
  91393. private _wheelEventName;
  91394. /** @hidden */
  91395. _forcedViewPosition: Nullable<Vector3>;
  91396. /** @hidden */
  91397. _frustumPlanes: Plane[];
  91398. /**
  91399. * Gets the list of frustum planes (built from the active camera)
  91400. */
  91401. readonly frustumPlanes: Plane[];
  91402. /**
  91403. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91404. * This is useful if there are more lights that the maximum simulteanous authorized
  91405. */
  91406. requireLightSorting: boolean;
  91407. /** @hidden */
  91408. readonly useMaterialMeshMap: boolean;
  91409. /** @hidden */
  91410. readonly useClonedMeshhMap: boolean;
  91411. private _pointerOverMesh;
  91412. private _pickedDownMesh;
  91413. private _pickedUpMesh;
  91414. private _externalData;
  91415. private _uid;
  91416. /**
  91417. * @hidden
  91418. * Backing store of defined scene components.
  91419. */
  91420. _components: ISceneComponent[];
  91421. /**
  91422. * @hidden
  91423. * Backing store of defined scene components.
  91424. */
  91425. _serializableComponents: ISceneSerializableComponent[];
  91426. /**
  91427. * List of components to register on the next registration step.
  91428. */
  91429. private _transientComponents;
  91430. /**
  91431. * Registers the transient components if needed.
  91432. */
  91433. private _registerTransientComponents;
  91434. /**
  91435. * @hidden
  91436. * Add a component to the scene.
  91437. * Note that the ccomponent could be registered on th next frame if this is called after
  91438. * the register component stage.
  91439. * @param component Defines the component to add to the scene
  91440. */
  91441. _addComponent(component: ISceneComponent): void;
  91442. /**
  91443. * @hidden
  91444. * Gets a component from the scene.
  91445. * @param name defines the name of the component to retrieve
  91446. * @returns the component or null if not present
  91447. */
  91448. _getComponent(name: string): Nullable<ISceneComponent>;
  91449. /**
  91450. * @hidden
  91451. * Defines the actions happening before camera updates.
  91452. */
  91453. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91454. /**
  91455. * @hidden
  91456. * Defines the actions happening before clear the canvas.
  91457. */
  91458. _beforeClearStage: Stage<SimpleStageAction>;
  91459. /**
  91460. * @hidden
  91461. * Defines the actions when collecting render targets for the frame.
  91462. */
  91463. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91464. /**
  91465. * @hidden
  91466. * Defines the actions happening for one camera in the frame.
  91467. */
  91468. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91469. /**
  91470. * @hidden
  91471. * Defines the actions happening during the per mesh ready checks.
  91472. */
  91473. _isReadyForMeshStage: Stage<MeshStageAction>;
  91474. /**
  91475. * @hidden
  91476. * Defines the actions happening before evaluate active mesh checks.
  91477. */
  91478. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91479. /**
  91480. * @hidden
  91481. * Defines the actions happening during the evaluate sub mesh checks.
  91482. */
  91483. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91484. /**
  91485. * @hidden
  91486. * Defines the actions happening during the active mesh stage.
  91487. */
  91488. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91489. /**
  91490. * @hidden
  91491. * Defines the actions happening during the per camera render target step.
  91492. */
  91493. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91494. /**
  91495. * @hidden
  91496. * Defines the actions happening just before the active camera is drawing.
  91497. */
  91498. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91499. /**
  91500. * @hidden
  91501. * Defines the actions happening just before a render target is drawing.
  91502. */
  91503. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91504. /**
  91505. * @hidden
  91506. * Defines the actions happening just before a rendering group is drawing.
  91507. */
  91508. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91509. /**
  91510. * @hidden
  91511. * Defines the actions happening just before a mesh is drawing.
  91512. */
  91513. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91514. /**
  91515. * @hidden
  91516. * Defines the actions happening just after a mesh has been drawn.
  91517. */
  91518. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91519. /**
  91520. * @hidden
  91521. * Defines the actions happening just after a rendering group has been drawn.
  91522. */
  91523. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91524. /**
  91525. * @hidden
  91526. * Defines the actions happening just after the active camera has been drawn.
  91527. */
  91528. _afterCameraDrawStage: Stage<CameraStageAction>;
  91529. /**
  91530. * @hidden
  91531. * Defines the actions happening just after a render target has been drawn.
  91532. */
  91533. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91534. /**
  91535. * @hidden
  91536. * Defines the actions happening just after rendering all cameras and computing intersections.
  91537. */
  91538. _afterRenderStage: Stage<SimpleStageAction>;
  91539. /**
  91540. * @hidden
  91541. * Defines the actions happening when a pointer move event happens.
  91542. */
  91543. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91544. /**
  91545. * @hidden
  91546. * Defines the actions happening when a pointer down event happens.
  91547. */
  91548. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91549. /**
  91550. * @hidden
  91551. * Defines the actions happening when a pointer up event happens.
  91552. */
  91553. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91554. /**
  91555. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91556. */
  91557. private geometriesByUniqueId;
  91558. /**
  91559. * Creates a new Scene
  91560. * @param engine defines the engine to use to render this scene
  91561. * @param options defines the scene options
  91562. */
  91563. constructor(engine: Engine, options?: SceneOptions);
  91564. /**
  91565. * Gets a string idenfifying the name of the class
  91566. * @returns "Scene" string
  91567. */
  91568. getClassName(): string;
  91569. private _defaultMeshCandidates;
  91570. /**
  91571. * @hidden
  91572. */
  91573. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91574. private _defaultSubMeshCandidates;
  91575. /**
  91576. * @hidden
  91577. */
  91578. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91579. /**
  91580. * Sets the default candidate providers for the scene.
  91581. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91582. * and getCollidingSubMeshCandidates to their default function
  91583. */
  91584. setDefaultCandidateProviders(): void;
  91585. /**
  91586. * Gets the mesh that is currently under the pointer
  91587. */
  91588. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91589. /**
  91590. * Gets or sets the current on-screen X position of the pointer
  91591. */
  91592. pointerX: number;
  91593. /**
  91594. * Gets or sets the current on-screen Y position of the pointer
  91595. */
  91596. pointerY: number;
  91597. /**
  91598. * Gets the cached material (ie. the latest rendered one)
  91599. * @returns the cached material
  91600. */
  91601. getCachedMaterial(): Nullable<Material>;
  91602. /**
  91603. * Gets the cached effect (ie. the latest rendered one)
  91604. * @returns the cached effect
  91605. */
  91606. getCachedEffect(): Nullable<Effect>;
  91607. /**
  91608. * Gets the cached visibility state (ie. the latest rendered one)
  91609. * @returns the cached visibility state
  91610. */
  91611. getCachedVisibility(): Nullable<number>;
  91612. /**
  91613. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91614. * @param material defines the current material
  91615. * @param effect defines the current effect
  91616. * @param visibility defines the current visibility state
  91617. * @returns true if one parameter is not cached
  91618. */
  91619. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91620. /**
  91621. * Gets the engine associated with the scene
  91622. * @returns an Engine
  91623. */
  91624. getEngine(): Engine;
  91625. /**
  91626. * Gets the total number of vertices rendered per frame
  91627. * @returns the total number of vertices rendered per frame
  91628. */
  91629. getTotalVertices(): number;
  91630. /**
  91631. * Gets the performance counter for total vertices
  91632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91633. */
  91634. readonly totalVerticesPerfCounter: PerfCounter;
  91635. /**
  91636. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91637. * @returns the total number of active indices rendered per frame
  91638. */
  91639. getActiveIndices(): number;
  91640. /**
  91641. * Gets the performance counter for active indices
  91642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91643. */
  91644. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91645. /**
  91646. * Gets the total number of active particles rendered per frame
  91647. * @returns the total number of active particles rendered per frame
  91648. */
  91649. getActiveParticles(): number;
  91650. /**
  91651. * Gets the performance counter for active particles
  91652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91653. */
  91654. readonly activeParticlesPerfCounter: PerfCounter;
  91655. /**
  91656. * Gets the total number of active bones rendered per frame
  91657. * @returns the total number of active bones rendered per frame
  91658. */
  91659. getActiveBones(): number;
  91660. /**
  91661. * Gets the performance counter for active bones
  91662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91663. */
  91664. readonly activeBonesPerfCounter: PerfCounter;
  91665. /**
  91666. * Gets the array of active meshes
  91667. * @returns an array of AbstractMesh
  91668. */
  91669. getActiveMeshes(): SmartArray<AbstractMesh>;
  91670. /**
  91671. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91672. * @returns a number
  91673. */
  91674. getAnimationRatio(): number;
  91675. /**
  91676. * Gets an unique Id for the current render phase
  91677. * @returns a number
  91678. */
  91679. getRenderId(): number;
  91680. /**
  91681. * Gets an unique Id for the current frame
  91682. * @returns a number
  91683. */
  91684. getFrameId(): number;
  91685. /** Call this function if you want to manually increment the render Id*/
  91686. incrementRenderId(): void;
  91687. private _updatePointerPosition;
  91688. private _createUbo;
  91689. private _setRayOnPointerInfo;
  91690. /**
  91691. * Use this method to simulate a pointer move on a mesh
  91692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91695. * @returns the current scene
  91696. */
  91697. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91698. private _processPointerMove;
  91699. private _checkPrePointerObservable;
  91700. /**
  91701. * Use this method to simulate a pointer down on a mesh
  91702. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91703. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91704. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91705. * @returns the current scene
  91706. */
  91707. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91708. private _processPointerDown;
  91709. /**
  91710. * Use this method to simulate a pointer up on a mesh
  91711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91714. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91715. * @returns the current scene
  91716. */
  91717. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91718. private _processPointerUp;
  91719. /**
  91720. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91721. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91722. * @returns true if the pointer was captured
  91723. */
  91724. isPointerCaptured(pointerId?: number): boolean;
  91725. /** @hidden */
  91726. _isPointerSwiping(): boolean;
  91727. /**
  91728. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91729. * @param attachUp defines if you want to attach events to pointerup
  91730. * @param attachDown defines if you want to attach events to pointerdown
  91731. * @param attachMove defines if you want to attach events to pointermove
  91732. */
  91733. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91734. /** Detaches all event handlers*/
  91735. detachControl(): void;
  91736. /**
  91737. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91738. * Delay loaded resources are not taking in account
  91739. * @return true if all required resources are ready
  91740. */
  91741. isReady(): boolean;
  91742. /** Resets all cached information relative to material (including effect and visibility) */
  91743. resetCachedMaterial(): void;
  91744. /**
  91745. * Registers a function to be called before every frame render
  91746. * @param func defines the function to register
  91747. */
  91748. registerBeforeRender(func: () => void): void;
  91749. /**
  91750. * Unregisters a function called before every frame render
  91751. * @param func defines the function to unregister
  91752. */
  91753. unregisterBeforeRender(func: () => void): void;
  91754. /**
  91755. * Registers a function to be called after every frame render
  91756. * @param func defines the function to register
  91757. */
  91758. registerAfterRender(func: () => void): void;
  91759. /**
  91760. * Unregisters a function called after every frame render
  91761. * @param func defines the function to unregister
  91762. */
  91763. unregisterAfterRender(func: () => void): void;
  91764. private _executeOnceBeforeRender;
  91765. /**
  91766. * The provided function will run before render once and will be disposed afterwards.
  91767. * A timeout delay can be provided so that the function will be executed in N ms.
  91768. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  91769. * @param func The function to be executed.
  91770. * @param timeout optional delay in ms
  91771. */
  91772. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  91773. /** @hidden */
  91774. _addPendingData(data: any): void;
  91775. /** @hidden */
  91776. _removePendingData(data: any): void;
  91777. /**
  91778. * Returns the number of items waiting to be loaded
  91779. * @returns the number of items waiting to be loaded
  91780. */
  91781. getWaitingItemsCount(): number;
  91782. /**
  91783. * Returns a boolean indicating if the scene is still loading data
  91784. */
  91785. readonly isLoading: boolean;
  91786. /**
  91787. * Registers a function to be executed when the scene is ready
  91788. * @param {Function} func - the function to be executed
  91789. */
  91790. executeWhenReady(func: () => void): void;
  91791. /**
  91792. * Returns a promise that resolves when the scene is ready
  91793. * @returns A promise that resolves when the scene is ready
  91794. */
  91795. whenReadyAsync(): Promise<void>;
  91796. /** @hidden */
  91797. _checkIsReady(): void;
  91798. /**
  91799. * Gets all animatable attached to the scene
  91800. */
  91801. readonly animatables: Animatable[];
  91802. /**
  91803. * Resets the last animation time frame.
  91804. * Useful to override when animations start running when loading a scene for the first time.
  91805. */
  91806. resetLastAnimationTimeFrame(): void;
  91807. /**
  91808. * Gets the current view matrix
  91809. * @returns a Matrix
  91810. */
  91811. getViewMatrix(): Matrix;
  91812. /**
  91813. * Gets the current projection matrix
  91814. * @returns a Matrix
  91815. */
  91816. getProjectionMatrix(): Matrix;
  91817. /**
  91818. * Gets the current transform matrix
  91819. * @returns a Matrix made of View * Projection
  91820. */
  91821. getTransformMatrix(): Matrix;
  91822. /**
  91823. * Sets the current transform matrix
  91824. * @param viewL defines the View matrix to use
  91825. * @param projectionL defines the Projection matrix to use
  91826. * @param viewR defines the right View matrix to use (if provided)
  91827. * @param projectionR defines the right Projection matrix to use (if provided)
  91828. */
  91829. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  91830. /**
  91831. * Gets the uniform buffer used to store scene data
  91832. * @returns a UniformBuffer
  91833. */
  91834. getSceneUniformBuffer(): UniformBuffer;
  91835. /**
  91836. * Gets an unique (relatively to the current scene) Id
  91837. * @returns an unique number for the scene
  91838. */
  91839. getUniqueId(): number;
  91840. /**
  91841. * Add a mesh to the list of scene's meshes
  91842. * @param newMesh defines the mesh to add
  91843. * @param recursive if all child meshes should also be added to the scene
  91844. */
  91845. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91846. /**
  91847. * Remove a mesh for the list of scene's meshes
  91848. * @param toRemove defines the mesh to remove
  91849. * @param recursive if all child meshes should also be removed from the scene
  91850. * @returns the index where the mesh was in the mesh list
  91851. */
  91852. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91853. /**
  91854. * Add a transform node to the list of scene's transform nodes
  91855. * @param newTransformNode defines the transform node to add
  91856. */
  91857. addTransformNode(newTransformNode: TransformNode): void;
  91858. /**
  91859. * Remove a transform node for the list of scene's transform nodes
  91860. * @param toRemove defines the transform node to remove
  91861. * @returns the index where the transform node was in the transform node list
  91862. */
  91863. removeTransformNode(toRemove: TransformNode): number;
  91864. /**
  91865. * Remove a skeleton for the list of scene's skeletons
  91866. * @param toRemove defines the skeleton to remove
  91867. * @returns the index where the skeleton was in the skeleton list
  91868. */
  91869. removeSkeleton(toRemove: Skeleton): number;
  91870. /**
  91871. * Remove a morph target for the list of scene's morph targets
  91872. * @param toRemove defines the morph target to remove
  91873. * @returns the index where the morph target was in the morph target list
  91874. */
  91875. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91876. /**
  91877. * Remove a light for the list of scene's lights
  91878. * @param toRemove defines the light to remove
  91879. * @returns the index where the light was in the light list
  91880. */
  91881. removeLight(toRemove: Light): number;
  91882. /**
  91883. * Remove a camera for the list of scene's cameras
  91884. * @param toRemove defines the camera to remove
  91885. * @returns the index where the camera was in the camera list
  91886. */
  91887. removeCamera(toRemove: Camera): number;
  91888. /**
  91889. * Remove a particle system for the list of scene's particle systems
  91890. * @param toRemove defines the particle system to remove
  91891. * @returns the index where the particle system was in the particle system list
  91892. */
  91893. removeParticleSystem(toRemove: IParticleSystem): number;
  91894. /**
  91895. * Remove a animation for the list of scene's animations
  91896. * @param toRemove defines the animation to remove
  91897. * @returns the index where the animation was in the animation list
  91898. */
  91899. removeAnimation(toRemove: Animation): number;
  91900. /**
  91901. * Removes the given animation group from this scene.
  91902. * @param toRemove The animation group to remove
  91903. * @returns The index of the removed animation group
  91904. */
  91905. removeAnimationGroup(toRemove: AnimationGroup): number;
  91906. /**
  91907. * Removes the given multi-material from this scene.
  91908. * @param toRemove The multi-material to remove
  91909. * @returns The index of the removed multi-material
  91910. */
  91911. removeMultiMaterial(toRemove: MultiMaterial): number;
  91912. /**
  91913. * Removes the given material from this scene.
  91914. * @param toRemove The material to remove
  91915. * @returns The index of the removed material
  91916. */
  91917. removeMaterial(toRemove: Material): number;
  91918. /**
  91919. * Removes the given action manager from this scene.
  91920. * @param toRemove The action manager to remove
  91921. * @returns The index of the removed action manager
  91922. */
  91923. removeActionManager(toRemove: AbstractActionManager): number;
  91924. /**
  91925. * Removes the given texture from this scene.
  91926. * @param toRemove The texture to remove
  91927. * @returns The index of the removed texture
  91928. */
  91929. removeTexture(toRemove: BaseTexture): number;
  91930. /**
  91931. * Adds the given light to this scene
  91932. * @param newLight The light to add
  91933. */
  91934. addLight(newLight: Light): void;
  91935. /**
  91936. * Sorts the list list based on light priorities
  91937. */
  91938. sortLightsByPriority(): void;
  91939. /**
  91940. * Adds the given camera to this scene
  91941. * @param newCamera The camera to add
  91942. */
  91943. addCamera(newCamera: Camera): void;
  91944. /**
  91945. * Adds the given skeleton to this scene
  91946. * @param newSkeleton The skeleton to add
  91947. */
  91948. addSkeleton(newSkeleton: Skeleton): void;
  91949. /**
  91950. * Adds the given particle system to this scene
  91951. * @param newParticleSystem The particle system to add
  91952. */
  91953. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91954. /**
  91955. * Adds the given animation to this scene
  91956. * @param newAnimation The animation to add
  91957. */
  91958. addAnimation(newAnimation: Animation): void;
  91959. /**
  91960. * Adds the given animation group to this scene.
  91961. * @param newAnimationGroup The animation group to add
  91962. */
  91963. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91964. /**
  91965. * Adds the given multi-material to this scene
  91966. * @param newMultiMaterial The multi-material to add
  91967. */
  91968. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91969. /**
  91970. * Adds the given material to this scene
  91971. * @param newMaterial The material to add
  91972. */
  91973. addMaterial(newMaterial: Material): void;
  91974. /**
  91975. * Adds the given morph target to this scene
  91976. * @param newMorphTargetManager The morph target to add
  91977. */
  91978. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91979. /**
  91980. * Adds the given geometry to this scene
  91981. * @param newGeometry The geometry to add
  91982. */
  91983. addGeometry(newGeometry: Geometry): void;
  91984. /**
  91985. * Adds the given action manager to this scene
  91986. * @param newActionManager The action manager to add
  91987. */
  91988. addActionManager(newActionManager: AbstractActionManager): void;
  91989. /**
  91990. * Adds the given texture to this scene.
  91991. * @param newTexture The texture to add
  91992. */
  91993. addTexture(newTexture: BaseTexture): void;
  91994. /**
  91995. * Switch active camera
  91996. * @param newCamera defines the new active camera
  91997. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91998. */
  91999. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92000. /**
  92001. * sets the active camera of the scene using its ID
  92002. * @param id defines the camera's ID
  92003. * @return the new active camera or null if none found.
  92004. */
  92005. setActiveCameraByID(id: string): Nullable<Camera>;
  92006. /**
  92007. * sets the active camera of the scene using its name
  92008. * @param name defines the camera's name
  92009. * @returns the new active camera or null if none found.
  92010. */
  92011. setActiveCameraByName(name: string): Nullable<Camera>;
  92012. /**
  92013. * get an animation group using its name
  92014. * @param name defines the material's name
  92015. * @return the animation group or null if none found.
  92016. */
  92017. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92018. /**
  92019. * Get a material using its unique id
  92020. * @param uniqueId defines the material's unique id
  92021. * @return the material or null if none found.
  92022. */
  92023. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92024. /**
  92025. * get a material using its id
  92026. * @param id defines the material's ID
  92027. * @return the material or null if none found.
  92028. */
  92029. getMaterialByID(id: string): Nullable<Material>;
  92030. /**
  92031. * Gets a material using its name
  92032. * @param name defines the material's name
  92033. * @return the material or null if none found.
  92034. */
  92035. getMaterialByName(name: string): Nullable<Material>;
  92036. /**
  92037. * Gets a camera using its id
  92038. * @param id defines the id to look for
  92039. * @returns the camera or null if not found
  92040. */
  92041. getCameraByID(id: string): Nullable<Camera>;
  92042. /**
  92043. * Gets a camera using its unique id
  92044. * @param uniqueId defines the unique id to look for
  92045. * @returns the camera or null if not found
  92046. */
  92047. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92048. /**
  92049. * Gets a camera using its name
  92050. * @param name defines the camera's name
  92051. * @return the camera or null if none found.
  92052. */
  92053. getCameraByName(name: string): Nullable<Camera>;
  92054. /**
  92055. * Gets a bone using its id
  92056. * @param id defines the bone's id
  92057. * @return the bone or null if not found
  92058. */
  92059. getBoneByID(id: string): Nullable<Bone>;
  92060. /**
  92061. * Gets a bone using its id
  92062. * @param name defines the bone's name
  92063. * @return the bone or null if not found
  92064. */
  92065. getBoneByName(name: string): Nullable<Bone>;
  92066. /**
  92067. * Gets a light node using its name
  92068. * @param name defines the the light's name
  92069. * @return the light or null if none found.
  92070. */
  92071. getLightByName(name: string): Nullable<Light>;
  92072. /**
  92073. * Gets a light node using its id
  92074. * @param id defines the light's id
  92075. * @return the light or null if none found.
  92076. */
  92077. getLightByID(id: string): Nullable<Light>;
  92078. /**
  92079. * Gets a light node using its scene-generated unique ID
  92080. * @param uniqueId defines the light's unique id
  92081. * @return the light or null if none found.
  92082. */
  92083. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92084. /**
  92085. * Gets a particle system by id
  92086. * @param id defines the particle system id
  92087. * @return the corresponding system or null if none found
  92088. */
  92089. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92090. /**
  92091. * Gets a geometry using its ID
  92092. * @param id defines the geometry's id
  92093. * @return the geometry or null if none found.
  92094. */
  92095. getGeometryByID(id: string): Nullable<Geometry>;
  92096. private _getGeometryByUniqueID;
  92097. /**
  92098. * Add a new geometry to this scene
  92099. * @param geometry defines the geometry to be added to the scene.
  92100. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92101. * @return a boolean defining if the geometry was added or not
  92102. */
  92103. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92104. /**
  92105. * Removes an existing geometry
  92106. * @param geometry defines the geometry to be removed from the scene
  92107. * @return a boolean defining if the geometry was removed or not
  92108. */
  92109. removeGeometry(geometry: Geometry): boolean;
  92110. /**
  92111. * Gets the list of geometries attached to the scene
  92112. * @returns an array of Geometry
  92113. */
  92114. getGeometries(): Geometry[];
  92115. /**
  92116. * Gets the first added mesh found of a given ID
  92117. * @param id defines the id to search for
  92118. * @return the mesh found or null if not found at all
  92119. */
  92120. getMeshByID(id: string): Nullable<AbstractMesh>;
  92121. /**
  92122. * Gets a list of meshes using their id
  92123. * @param id defines the id to search for
  92124. * @returns a list of meshes
  92125. */
  92126. getMeshesByID(id: string): Array<AbstractMesh>;
  92127. /**
  92128. * Gets the first added transform node found of a given ID
  92129. * @param id defines the id to search for
  92130. * @return the found transform node or null if not found at all.
  92131. */
  92132. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92133. /**
  92134. * Gets a transform node with its auto-generated unique id
  92135. * @param uniqueId efines the unique id to search for
  92136. * @return the found transform node or null if not found at all.
  92137. */
  92138. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92139. /**
  92140. * Gets a list of transform nodes using their id
  92141. * @param id defines the id to search for
  92142. * @returns a list of transform nodes
  92143. */
  92144. getTransformNodesByID(id: string): Array<TransformNode>;
  92145. /**
  92146. * Gets a mesh with its auto-generated unique id
  92147. * @param uniqueId defines the unique id to search for
  92148. * @return the found mesh or null if not found at all.
  92149. */
  92150. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92151. /**
  92152. * Gets a the last added mesh using a given id
  92153. * @param id defines the id to search for
  92154. * @return the found mesh or null if not found at all.
  92155. */
  92156. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92157. /**
  92158. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92159. * @param id defines the id to search for
  92160. * @return the found node or null if not found at all
  92161. */
  92162. getLastEntryByID(id: string): Nullable<Node>;
  92163. /**
  92164. * Gets a node (Mesh, Camera, Light) using a given id
  92165. * @param id defines the id to search for
  92166. * @return the found node or null if not found at all
  92167. */
  92168. getNodeByID(id: string): Nullable<Node>;
  92169. /**
  92170. * Gets a node (Mesh, Camera, Light) using a given name
  92171. * @param name defines the name to search for
  92172. * @return the found node or null if not found at all.
  92173. */
  92174. getNodeByName(name: string): Nullable<Node>;
  92175. /**
  92176. * Gets a mesh using a given name
  92177. * @param name defines the name to search for
  92178. * @return the found mesh or null if not found at all.
  92179. */
  92180. getMeshByName(name: string): Nullable<AbstractMesh>;
  92181. /**
  92182. * Gets a transform node using a given name
  92183. * @param name defines the name to search for
  92184. * @return the found transform node or null if not found at all.
  92185. */
  92186. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92187. /**
  92188. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92189. * @param id defines the id to search for
  92190. * @return the found skeleton or null if not found at all.
  92191. */
  92192. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92193. /**
  92194. * Gets a skeleton using a given auto generated unique id
  92195. * @param uniqueId defines the unique id to search for
  92196. * @return the found skeleton or null if not found at all.
  92197. */
  92198. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92199. /**
  92200. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92201. * @param id defines the id to search for
  92202. * @return the found skeleton or null if not found at all.
  92203. */
  92204. getSkeletonById(id: string): Nullable<Skeleton>;
  92205. /**
  92206. * Gets a skeleton using a given name
  92207. * @param name defines the name to search for
  92208. * @return the found skeleton or null if not found at all.
  92209. */
  92210. getSkeletonByName(name: string): Nullable<Skeleton>;
  92211. /**
  92212. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92213. * @param id defines the id to search for
  92214. * @return the found morph target manager or null if not found at all.
  92215. */
  92216. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92217. /**
  92218. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92219. * @param id defines the id to search for
  92220. * @return the found morph target or null if not found at all.
  92221. */
  92222. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92223. /**
  92224. * Gets a boolean indicating if the given mesh is active
  92225. * @param mesh defines the mesh to look for
  92226. * @returns true if the mesh is in the active list
  92227. */
  92228. isActiveMesh(mesh: AbstractMesh): boolean;
  92229. /**
  92230. * Return a unique id as a string which can serve as an identifier for the scene
  92231. */
  92232. readonly uid: string;
  92233. /**
  92234. * Add an externaly attached data from its key.
  92235. * This method call will fail and return false, if such key already exists.
  92236. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92237. * @param key the unique key that identifies the data
  92238. * @param data the data object to associate to the key for this Engine instance
  92239. * @return true if no such key were already present and the data was added successfully, false otherwise
  92240. */
  92241. addExternalData<T>(key: string, data: T): boolean;
  92242. /**
  92243. * Get an externaly attached data from its key
  92244. * @param key the unique key that identifies the data
  92245. * @return the associated data, if present (can be null), or undefined if not present
  92246. */
  92247. getExternalData<T>(key: string): Nullable<T>;
  92248. /**
  92249. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92250. * @param key the unique key that identifies the data
  92251. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92252. * @return the associated data, can be null if the factory returned null.
  92253. */
  92254. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92255. /**
  92256. * Remove an externaly attached data from the Engine instance
  92257. * @param key the unique key that identifies the data
  92258. * @return true if the data was successfully removed, false if it doesn't exist
  92259. */
  92260. removeExternalData(key: string): boolean;
  92261. private _evaluateSubMesh;
  92262. /**
  92263. * Clear the processed materials smart array preventing retention point in material dispose.
  92264. */
  92265. freeProcessedMaterials(): void;
  92266. private _preventFreeActiveMeshesAndRenderingGroups;
  92267. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92268. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92269. * when disposing several meshes in a row or a hierarchy of meshes.
  92270. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92271. */
  92272. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92273. /**
  92274. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92275. */
  92276. freeActiveMeshes(): void;
  92277. /**
  92278. * Clear the info related to rendering groups preventing retention points during dispose.
  92279. */
  92280. freeRenderingGroups(): void;
  92281. /** @hidden */
  92282. _isInIntermediateRendering(): boolean;
  92283. /**
  92284. * Lambda returning the list of potentially active meshes.
  92285. */
  92286. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92287. /**
  92288. * Lambda returning the list of potentially active sub meshes.
  92289. */
  92290. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92291. /**
  92292. * Lambda returning the list of potentially intersecting sub meshes.
  92293. */
  92294. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92295. /**
  92296. * Lambda returning the list of potentially colliding sub meshes.
  92297. */
  92298. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92299. private _activeMeshesFrozen;
  92300. /**
  92301. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92302. * @returns the current scene
  92303. */
  92304. freezeActiveMeshes(): Scene;
  92305. /**
  92306. * Use this function to restart evaluating active meshes on every frame
  92307. * @returns the current scene
  92308. */
  92309. unfreezeActiveMeshes(): Scene;
  92310. private _evaluateActiveMeshes;
  92311. private _activeMesh;
  92312. /**
  92313. * Update the transform matrix to update from the current active camera
  92314. * @param force defines a boolean used to force the update even if cache is up to date
  92315. */
  92316. updateTransformMatrix(force?: boolean): void;
  92317. private _bindFrameBuffer;
  92318. /** @hidden */
  92319. _allowPostProcessClearColor: boolean;
  92320. /** @hidden */
  92321. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92322. private _processSubCameras;
  92323. private _checkIntersections;
  92324. /** @hidden */
  92325. _advancePhysicsEngineStep(step: number): void;
  92326. /**
  92327. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92328. */
  92329. getDeterministicFrameTime: () => number;
  92330. /** @hidden */
  92331. _animate(): void;
  92332. /**
  92333. * Render the scene
  92334. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92335. */
  92336. render(updateCameras?: boolean): void;
  92337. /**
  92338. * Freeze all materials
  92339. * A frozen material will not be updatable but should be faster to render
  92340. */
  92341. freezeMaterials(): void;
  92342. /**
  92343. * Unfreeze all materials
  92344. * A frozen material will not be updatable but should be faster to render
  92345. */
  92346. unfreezeMaterials(): void;
  92347. /**
  92348. * Releases all held ressources
  92349. */
  92350. dispose(): void;
  92351. /**
  92352. * Gets if the scene is already disposed
  92353. */
  92354. readonly isDisposed: boolean;
  92355. /**
  92356. * Call this function to reduce memory footprint of the scene.
  92357. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92358. */
  92359. clearCachedVertexData(): void;
  92360. /**
  92361. * This function will remove the local cached buffer data from texture.
  92362. * It will save memory but will prevent the texture from being rebuilt
  92363. */
  92364. cleanCachedTextureBuffer(): void;
  92365. /**
  92366. * Get the world extend vectors with an optional filter
  92367. *
  92368. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92369. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92370. */
  92371. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92372. min: Vector3;
  92373. max: Vector3;
  92374. };
  92375. /**
  92376. * Creates a ray that can be used to pick in the scene
  92377. * @param x defines the x coordinate of the origin (on-screen)
  92378. * @param y defines the y coordinate of the origin (on-screen)
  92379. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92380. * @param camera defines the camera to use for the picking
  92381. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92382. * @returns a Ray
  92383. */
  92384. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92385. /**
  92386. * Creates a ray that can be used to pick in the scene
  92387. * @param x defines the x coordinate of the origin (on-screen)
  92388. * @param y defines the y coordinate of the origin (on-screen)
  92389. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92390. * @param result defines the ray where to store the picking ray
  92391. * @param camera defines the camera to use for the picking
  92392. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92393. * @returns the current scene
  92394. */
  92395. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92396. /**
  92397. * Creates a ray that can be used to pick in the scene
  92398. * @param x defines the x coordinate of the origin (on-screen)
  92399. * @param y defines the y coordinate of the origin (on-screen)
  92400. * @param camera defines the camera to use for the picking
  92401. * @returns a Ray
  92402. */
  92403. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92404. /**
  92405. * Creates a ray that can be used to pick in the scene
  92406. * @param x defines the x coordinate of the origin (on-screen)
  92407. * @param y defines the y coordinate of the origin (on-screen)
  92408. * @param result defines the ray where to store the picking ray
  92409. * @param camera defines the camera to use for the picking
  92410. * @returns the current scene
  92411. */
  92412. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92413. /** Launch a ray to try to pick a mesh in the scene
  92414. * @param x position on screen
  92415. * @param y position on screen
  92416. * @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
  92417. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92418. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92420. * @returns a PickingInfo
  92421. */
  92422. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92423. /** Use the given ray to pick a mesh in the scene
  92424. * @param ray The ray to use to pick meshes
  92425. * @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
  92426. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92428. * @returns a PickingInfo
  92429. */
  92430. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92431. /**
  92432. * Launch a ray to try to pick a mesh in the scene
  92433. * @param x X position on screen
  92434. * @param y Y position on screen
  92435. * @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
  92436. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92438. * @returns an array of PickingInfo
  92439. */
  92440. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92441. /**
  92442. * Launch a ray to try to pick a mesh in the scene
  92443. * @param ray Ray to use
  92444. * @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
  92445. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92446. * @returns an array of PickingInfo
  92447. */
  92448. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92449. /**
  92450. * Force the value of meshUnderPointer
  92451. * @param mesh defines the mesh to use
  92452. */
  92453. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92454. /**
  92455. * Gets the mesh under the pointer
  92456. * @returns a Mesh or null if no mesh is under the pointer
  92457. */
  92458. getPointerOverMesh(): Nullable<AbstractMesh>;
  92459. /** @hidden */
  92460. _rebuildGeometries(): void;
  92461. /** @hidden */
  92462. _rebuildTextures(): void;
  92463. private _getByTags;
  92464. /**
  92465. * Get a list of meshes by tags
  92466. * @param tagsQuery defines the tags query to use
  92467. * @param forEach defines a predicate used to filter results
  92468. * @returns an array of Mesh
  92469. */
  92470. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92471. /**
  92472. * Get a list of cameras by tags
  92473. * @param tagsQuery defines the tags query to use
  92474. * @param forEach defines a predicate used to filter results
  92475. * @returns an array of Camera
  92476. */
  92477. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92478. /**
  92479. * Get a list of lights by tags
  92480. * @param tagsQuery defines the tags query to use
  92481. * @param forEach defines a predicate used to filter results
  92482. * @returns an array of Light
  92483. */
  92484. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92485. /**
  92486. * Get a list of materials by tags
  92487. * @param tagsQuery defines the tags query to use
  92488. * @param forEach defines a predicate used to filter results
  92489. * @returns an array of Material
  92490. */
  92491. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92492. /**
  92493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92494. * This allowed control for front to back rendering or reversly depending of the special needs.
  92495. *
  92496. * @param renderingGroupId The rendering group id corresponding to its index
  92497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92500. */
  92501. 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;
  92502. /**
  92503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92504. *
  92505. * @param renderingGroupId The rendering group id corresponding to its index
  92506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92507. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92508. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92509. */
  92510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92511. /**
  92512. * Gets the current auto clear configuration for one rendering group of the rendering
  92513. * manager.
  92514. * @param index the rendering group index to get the information for
  92515. * @returns The auto clear setup for the requested rendering group
  92516. */
  92517. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92518. private _blockMaterialDirtyMechanism;
  92519. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92520. blockMaterialDirtyMechanism: boolean;
  92521. /**
  92522. * Will flag all materials as dirty to trigger new shader compilation
  92523. * @param flag defines the flag used to specify which material part must be marked as dirty
  92524. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92525. */
  92526. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92527. /** @hidden */
  92528. _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;
  92529. /** @hidden */
  92530. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92531. }
  92532. }
  92533. declare module BABYLON {
  92534. /**
  92535. * Set of assets to keep when moving a scene into an asset container.
  92536. */
  92537. export class KeepAssets extends AbstractScene {
  92538. }
  92539. /**
  92540. * Container with a set of assets that can be added or removed from a scene.
  92541. */
  92542. export class AssetContainer extends AbstractScene {
  92543. /**
  92544. * The scene the AssetContainer belongs to.
  92545. */
  92546. scene: Scene;
  92547. /**
  92548. * Instantiates an AssetContainer.
  92549. * @param scene The scene the AssetContainer belongs to.
  92550. */
  92551. constructor(scene: Scene);
  92552. /**
  92553. * Adds all the assets from the container to the scene.
  92554. */
  92555. addAllToScene(): void;
  92556. /**
  92557. * Removes all the assets in the container from the scene
  92558. */
  92559. removeAllFromScene(): void;
  92560. /**
  92561. * Disposes all the assets in the container
  92562. */
  92563. dispose(): void;
  92564. private _moveAssets;
  92565. /**
  92566. * Removes all the assets contained in the scene and adds them to the container.
  92567. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92568. */
  92569. moveAllFromScene(keepAssets?: KeepAssets): void;
  92570. /**
  92571. * 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.
  92572. * @returns the root mesh
  92573. */
  92574. createRootMesh(): Mesh;
  92575. }
  92576. }
  92577. declare module BABYLON {
  92578. /**
  92579. * Defines how the parser contract is defined.
  92580. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92581. */
  92582. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92583. /**
  92584. * Defines how the individual parser contract is defined.
  92585. * These parser can parse an individual asset
  92586. */
  92587. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92588. /**
  92589. * Base class of the scene acting as a container for the different elements composing a scene.
  92590. * This class is dynamically extended by the different components of the scene increasing
  92591. * flexibility and reducing coupling
  92592. */
  92593. export abstract class AbstractScene {
  92594. /**
  92595. * Stores the list of available parsers in the application.
  92596. */
  92597. private static _BabylonFileParsers;
  92598. /**
  92599. * Stores the list of available individual parsers in the application.
  92600. */
  92601. private static _IndividualBabylonFileParsers;
  92602. /**
  92603. * Adds a parser in the list of available ones
  92604. * @param name Defines the name of the parser
  92605. * @param parser Defines the parser to add
  92606. */
  92607. static AddParser(name: string, parser: BabylonFileParser): void;
  92608. /**
  92609. * Gets a general parser from the list of avaialble ones
  92610. * @param name Defines the name of the parser
  92611. * @returns the requested parser or null
  92612. */
  92613. static GetParser(name: string): Nullable<BabylonFileParser>;
  92614. /**
  92615. * Adds n individual parser in the list of available ones
  92616. * @param name Defines the name of the parser
  92617. * @param parser Defines the parser to add
  92618. */
  92619. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92620. /**
  92621. * Gets an individual parser from the list of avaialble ones
  92622. * @param name Defines the name of the parser
  92623. * @returns the requested parser or null
  92624. */
  92625. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92626. /**
  92627. * Parser json data and populate both a scene and its associated container object
  92628. * @param jsonData Defines the data to parse
  92629. * @param scene Defines the scene to parse the data for
  92630. * @param container Defines the container attached to the parsing sequence
  92631. * @param rootUrl Defines the root url of the data
  92632. */
  92633. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92634. /**
  92635. * Gets the list of root nodes (ie. nodes with no parent)
  92636. */
  92637. rootNodes: Node[];
  92638. /** All of the cameras added to this scene
  92639. * @see http://doc.babylonjs.com/babylon101/cameras
  92640. */
  92641. cameras: Camera[];
  92642. /**
  92643. * All of the lights added to this scene
  92644. * @see http://doc.babylonjs.com/babylon101/lights
  92645. */
  92646. lights: Light[];
  92647. /**
  92648. * All of the (abstract) meshes added to this scene
  92649. */
  92650. meshes: AbstractMesh[];
  92651. /**
  92652. * The list of skeletons added to the scene
  92653. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92654. */
  92655. skeletons: Skeleton[];
  92656. /**
  92657. * All of the particle systems added to this scene
  92658. * @see http://doc.babylonjs.com/babylon101/particles
  92659. */
  92660. particleSystems: IParticleSystem[];
  92661. /**
  92662. * Gets a list of Animations associated with the scene
  92663. */
  92664. animations: Animation[];
  92665. /**
  92666. * All of the animation groups added to this scene
  92667. * @see http://doc.babylonjs.com/how_to/group
  92668. */
  92669. animationGroups: AnimationGroup[];
  92670. /**
  92671. * All of the multi-materials added to this scene
  92672. * @see http://doc.babylonjs.com/how_to/multi_materials
  92673. */
  92674. multiMaterials: MultiMaterial[];
  92675. /**
  92676. * All of the materials added to this scene
  92677. * In the context of a Scene, it is not supposed to be modified manually.
  92678. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92679. * Note also that the order of the Material wihin the array is not significant and might change.
  92680. * @see http://doc.babylonjs.com/babylon101/materials
  92681. */
  92682. materials: Material[];
  92683. /**
  92684. * The list of morph target managers added to the scene
  92685. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92686. */
  92687. morphTargetManagers: MorphTargetManager[];
  92688. /**
  92689. * The list of geometries used in the scene.
  92690. */
  92691. geometries: Geometry[];
  92692. /**
  92693. * All of the tranform nodes added to this scene
  92694. * In the context of a Scene, it is not supposed to be modified manually.
  92695. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92696. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92697. * @see http://doc.babylonjs.com/how_to/transformnode
  92698. */
  92699. transformNodes: TransformNode[];
  92700. /**
  92701. * ActionManagers available on the scene.
  92702. */
  92703. actionManagers: AbstractActionManager[];
  92704. /**
  92705. * Textures to keep.
  92706. */
  92707. textures: BaseTexture[];
  92708. /**
  92709. * Environment texture for the scene
  92710. */
  92711. environmentTexture: Nullable<BaseTexture>;
  92712. }
  92713. }
  92714. declare module BABYLON {
  92715. /**
  92716. * Defines a sound that can be played in the application.
  92717. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92719. */
  92720. export class Sound {
  92721. /**
  92722. * The name of the sound in the scene.
  92723. */
  92724. name: string;
  92725. /**
  92726. * Does the sound autoplay once loaded.
  92727. */
  92728. autoplay: boolean;
  92729. /**
  92730. * Does the sound loop after it finishes playing once.
  92731. */
  92732. loop: boolean;
  92733. /**
  92734. * Does the sound use a custom attenuation curve to simulate the falloff
  92735. * happening when the source gets further away from the camera.
  92736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92737. */
  92738. useCustomAttenuation: boolean;
  92739. /**
  92740. * The sound track id this sound belongs to.
  92741. */
  92742. soundTrackId: number;
  92743. /**
  92744. * Is this sound currently played.
  92745. */
  92746. isPlaying: boolean;
  92747. /**
  92748. * Is this sound currently paused.
  92749. */
  92750. isPaused: boolean;
  92751. /**
  92752. * Does this sound enables spatial sound.
  92753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92754. */
  92755. spatialSound: boolean;
  92756. /**
  92757. * Define the reference distance the sound should be heard perfectly.
  92758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92759. */
  92760. refDistance: number;
  92761. /**
  92762. * Define the roll off factor of spatial sounds.
  92763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92764. */
  92765. rolloffFactor: number;
  92766. /**
  92767. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  92768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92769. */
  92770. maxDistance: number;
  92771. /**
  92772. * Define the distance attenuation model the sound will follow.
  92773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92774. */
  92775. distanceModel: string;
  92776. /**
  92777. * @hidden
  92778. * Back Compat
  92779. **/
  92780. onended: () => any;
  92781. /**
  92782. * Observable event when the current playing sound finishes.
  92783. */
  92784. onEndedObservable: Observable<Sound>;
  92785. private _panningModel;
  92786. private _playbackRate;
  92787. private _streaming;
  92788. private _startTime;
  92789. private _startOffset;
  92790. private _position;
  92791. /** @hidden */
  92792. _positionInEmitterSpace: boolean;
  92793. private _localDirection;
  92794. private _volume;
  92795. private _isReadyToPlay;
  92796. private _isDirectional;
  92797. private _readyToPlayCallback;
  92798. private _audioBuffer;
  92799. private _soundSource;
  92800. private _streamingSource;
  92801. private _soundPanner;
  92802. private _soundGain;
  92803. private _inputAudioNode;
  92804. private _outputAudioNode;
  92805. private _coneInnerAngle;
  92806. private _coneOuterAngle;
  92807. private _coneOuterGain;
  92808. private _scene;
  92809. private _connectedTransformNode;
  92810. private _customAttenuationFunction;
  92811. private _registerFunc;
  92812. private _isOutputConnected;
  92813. private _htmlAudioElement;
  92814. private _urlType;
  92815. /** @hidden */
  92816. static _SceneComponentInitialization: (scene: Scene) => void;
  92817. /**
  92818. * Create a sound and attach it to a scene
  92819. * @param name Name of your sound
  92820. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92821. * @param scene defines the scene the sound belongs to
  92822. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92823. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92824. */
  92825. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92826. /**
  92827. * Release the sound and its associated resources
  92828. */
  92829. dispose(): void;
  92830. /**
  92831. * Gets if the sounds is ready to be played or not.
  92832. * @returns true if ready, otherwise false
  92833. */
  92834. isReady(): boolean;
  92835. private _soundLoaded;
  92836. /**
  92837. * Sets the data of the sound from an audiobuffer
  92838. * @param audioBuffer The audioBuffer containing the data
  92839. */
  92840. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92841. /**
  92842. * Updates the current sounds options such as maxdistance, loop...
  92843. * @param options A JSON object containing values named as the object properties
  92844. */
  92845. updateOptions(options: any): void;
  92846. private _createSpatialParameters;
  92847. private _updateSpatialParameters;
  92848. /**
  92849. * Switch the panning model to HRTF:
  92850. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92852. */
  92853. switchPanningModelToHRTF(): void;
  92854. /**
  92855. * Switch the panning model to Equal Power:
  92856. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92858. */
  92859. switchPanningModelToEqualPower(): void;
  92860. private _switchPanningModel;
  92861. /**
  92862. * Connect this sound to a sound track audio node like gain...
  92863. * @param soundTrackAudioNode the sound track audio node to connect to
  92864. */
  92865. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92866. /**
  92867. * Transform this sound into a directional source
  92868. * @param coneInnerAngle Size of the inner cone in degree
  92869. * @param coneOuterAngle Size of the outer cone in degree
  92870. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92871. */
  92872. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92873. /**
  92874. * Gets or sets the inner angle for the directional cone.
  92875. */
  92876. /**
  92877. * Gets or sets the inner angle for the directional cone.
  92878. */
  92879. directionalConeInnerAngle: number;
  92880. /**
  92881. * Gets or sets the outer angle for the directional cone.
  92882. */
  92883. /**
  92884. * Gets or sets the outer angle for the directional cone.
  92885. */
  92886. directionalConeOuterAngle: number;
  92887. /**
  92888. * Sets the position of the emitter if spatial sound is enabled
  92889. * @param newPosition Defines the new posisiton
  92890. */
  92891. setPosition(newPosition: Vector3): void;
  92892. /**
  92893. * Sets the local direction of the emitter if spatial sound is enabled
  92894. * @param newLocalDirection Defines the new local direction
  92895. */
  92896. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92897. private _updateDirection;
  92898. /** @hidden */
  92899. updateDistanceFromListener(): void;
  92900. /**
  92901. * Sets a new custom attenuation function for the sound.
  92902. * @param callback Defines the function used for the attenuation
  92903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92904. */
  92905. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92906. /**
  92907. * Play the sound
  92908. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92909. * @param offset (optional) Start the sound setting it at a specific time
  92910. */
  92911. play(time?: number, offset?: number): void;
  92912. private _onended;
  92913. /**
  92914. * Stop the sound
  92915. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92916. */
  92917. stop(time?: number): void;
  92918. /**
  92919. * Put the sound in pause
  92920. */
  92921. pause(): void;
  92922. /**
  92923. * Sets a dedicated volume for this sounds
  92924. * @param newVolume Define the new volume of the sound
  92925. * @param time Define in how long the sound should be at this value
  92926. */
  92927. setVolume(newVolume: number, time?: number): void;
  92928. /**
  92929. * Set the sound play back rate
  92930. * @param newPlaybackRate Define the playback rate the sound should be played at
  92931. */
  92932. setPlaybackRate(newPlaybackRate: number): void;
  92933. /**
  92934. * Gets the volume of the sound.
  92935. * @returns the volume of the sound
  92936. */
  92937. getVolume(): number;
  92938. /**
  92939. * Attach the sound to a dedicated mesh
  92940. * @param transformNode The transform node to connect the sound with
  92941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92942. */
  92943. attachToMesh(transformNode: TransformNode): void;
  92944. /**
  92945. * Detach the sound from the previously attached mesh
  92946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92947. */
  92948. detachFromMesh(): void;
  92949. private _onRegisterAfterWorldMatrixUpdate;
  92950. /**
  92951. * Clone the current sound in the scene.
  92952. * @returns the new sound clone
  92953. */
  92954. clone(): Nullable<Sound>;
  92955. /**
  92956. * Gets the current underlying audio buffer containing the data
  92957. * @returns the audio buffer
  92958. */
  92959. getAudioBuffer(): Nullable<AudioBuffer>;
  92960. /**
  92961. * Serializes the Sound in a JSON representation
  92962. * @returns the JSON representation of the sound
  92963. */
  92964. serialize(): any;
  92965. /**
  92966. * Parse a JSON representation of a sound to innstantiate in a given scene
  92967. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92968. * @param scene Define the scene the new parsed sound should be created in
  92969. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92970. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92971. * @returns the newly parsed sound
  92972. */
  92973. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92974. }
  92975. }
  92976. declare module BABYLON {
  92977. /**
  92978. * This defines an action helpful to play a defined sound on a triggered action.
  92979. */
  92980. export class PlaySoundAction extends Action {
  92981. private _sound;
  92982. /**
  92983. * Instantiate the action
  92984. * @param triggerOptions defines the trigger options
  92985. * @param sound defines the sound to play
  92986. * @param condition defines the trigger related conditions
  92987. */
  92988. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92989. /** @hidden */
  92990. _prepare(): void;
  92991. /**
  92992. * Execute the action and play the sound.
  92993. */
  92994. execute(): void;
  92995. /**
  92996. * Serializes the actions and its related information.
  92997. * @param parent defines the object to serialize in
  92998. * @returns the serialized object
  92999. */
  93000. serialize(parent: any): any;
  93001. }
  93002. /**
  93003. * This defines an action helpful to stop a defined sound on a triggered action.
  93004. */
  93005. export class StopSoundAction extends Action {
  93006. private _sound;
  93007. /**
  93008. * Instantiate the action
  93009. * @param triggerOptions defines the trigger options
  93010. * @param sound defines the sound to stop
  93011. * @param condition defines the trigger related conditions
  93012. */
  93013. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93014. /** @hidden */
  93015. _prepare(): void;
  93016. /**
  93017. * Execute the action and stop the sound.
  93018. */
  93019. execute(): void;
  93020. /**
  93021. * Serializes the actions and its related information.
  93022. * @param parent defines the object to serialize in
  93023. * @returns the serialized object
  93024. */
  93025. serialize(parent: any): any;
  93026. }
  93027. }
  93028. declare module BABYLON {
  93029. /**
  93030. * This defines an action responsible to change the value of a property
  93031. * by interpolating between its current value and the newly set one once triggered.
  93032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93033. */
  93034. export class InterpolateValueAction extends Action {
  93035. /**
  93036. * Defines the path of the property where the value should be interpolated
  93037. */
  93038. propertyPath: string;
  93039. /**
  93040. * Defines the target value at the end of the interpolation.
  93041. */
  93042. value: any;
  93043. /**
  93044. * Defines the time it will take for the property to interpolate to the value.
  93045. */
  93046. duration: number;
  93047. /**
  93048. * Defines if the other scene animations should be stopped when the action has been triggered
  93049. */
  93050. stopOtherAnimations?: boolean;
  93051. /**
  93052. * Defines a callback raised once the interpolation animation has been done.
  93053. */
  93054. onInterpolationDone?: () => void;
  93055. /**
  93056. * Observable triggered once the interpolation animation has been done.
  93057. */
  93058. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93059. private _target;
  93060. private _effectiveTarget;
  93061. private _property;
  93062. /**
  93063. * Instantiate the action
  93064. * @param triggerOptions defines the trigger options
  93065. * @param target defines the object containing the value to interpolate
  93066. * @param propertyPath defines the path to the property in the target object
  93067. * @param value defines the target value at the end of the interpolation
  93068. * @param duration deines the time it will take for the property to interpolate to the value.
  93069. * @param condition defines the trigger related conditions
  93070. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93071. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93072. */
  93073. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93074. /** @hidden */
  93075. _prepare(): void;
  93076. /**
  93077. * Execute the action starts the value interpolation.
  93078. */
  93079. execute(): void;
  93080. /**
  93081. * Serializes the actions and its related information.
  93082. * @param parent defines the object to serialize in
  93083. * @returns the serialized object
  93084. */
  93085. serialize(parent: any): any;
  93086. }
  93087. }
  93088. declare module BABYLON {
  93089. /**
  93090. * Options allowed during the creation of a sound track.
  93091. */
  93092. export interface ISoundTrackOptions {
  93093. /**
  93094. * The volume the sound track should take during creation
  93095. */
  93096. volume?: number;
  93097. /**
  93098. * Define if the sound track is the main sound track of the scene
  93099. */
  93100. mainTrack?: boolean;
  93101. }
  93102. /**
  93103. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93104. * It will be also used in a future release to apply effects on a specific track.
  93105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93106. */
  93107. export class SoundTrack {
  93108. /**
  93109. * The unique identifier of the sound track in the scene.
  93110. */
  93111. id: number;
  93112. /**
  93113. * The list of sounds included in the sound track.
  93114. */
  93115. soundCollection: Array<Sound>;
  93116. private _outputAudioNode;
  93117. private _scene;
  93118. private _isMainTrack;
  93119. private _connectedAnalyser;
  93120. private _options;
  93121. private _isInitialized;
  93122. /**
  93123. * Creates a new sound track.
  93124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93125. * @param scene Define the scene the sound track belongs to
  93126. * @param options
  93127. */
  93128. constructor(scene: Scene, options?: ISoundTrackOptions);
  93129. private _initializeSoundTrackAudioGraph;
  93130. /**
  93131. * Release the sound track and its associated resources
  93132. */
  93133. dispose(): void;
  93134. /**
  93135. * Adds a sound to this sound track
  93136. * @param sound define the cound to add
  93137. * @ignoreNaming
  93138. */
  93139. AddSound(sound: Sound): void;
  93140. /**
  93141. * Removes a sound to this sound track
  93142. * @param sound define the cound to remove
  93143. * @ignoreNaming
  93144. */
  93145. RemoveSound(sound: Sound): void;
  93146. /**
  93147. * Set a global volume for the full sound track.
  93148. * @param newVolume Define the new volume of the sound track
  93149. */
  93150. setVolume(newVolume: number): void;
  93151. /**
  93152. * Switch the panning model to HRTF:
  93153. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93155. */
  93156. switchPanningModelToHRTF(): void;
  93157. /**
  93158. * Switch the panning model to Equal Power:
  93159. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93161. */
  93162. switchPanningModelToEqualPower(): void;
  93163. /**
  93164. * Connect the sound track to an audio analyser allowing some amazing
  93165. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93167. * @param analyser The analyser to connect to the engine
  93168. */
  93169. connectToAnalyser(analyser: Analyser): void;
  93170. }
  93171. }
  93172. declare module BABYLON {
  93173. interface AbstractScene {
  93174. /**
  93175. * The list of sounds used in the scene.
  93176. */
  93177. sounds: Nullable<Array<Sound>>;
  93178. }
  93179. interface Scene {
  93180. /**
  93181. * @hidden
  93182. * Backing field
  93183. */
  93184. _mainSoundTrack: SoundTrack;
  93185. /**
  93186. * The main sound track played by the scene.
  93187. * It cotains your primary collection of sounds.
  93188. */
  93189. mainSoundTrack: SoundTrack;
  93190. /**
  93191. * The list of sound tracks added to the scene
  93192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93193. */
  93194. soundTracks: Nullable<Array<SoundTrack>>;
  93195. /**
  93196. * Gets a sound using a given name
  93197. * @param name defines the name to search for
  93198. * @return the found sound or null if not found at all.
  93199. */
  93200. getSoundByName(name: string): Nullable<Sound>;
  93201. /**
  93202. * Gets or sets if audio support is enabled
  93203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93204. */
  93205. audioEnabled: boolean;
  93206. /**
  93207. * Gets or sets if audio will be output to headphones
  93208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93209. */
  93210. headphone: boolean;
  93211. }
  93212. /**
  93213. * Defines the sound scene component responsible to manage any sounds
  93214. * in a given scene.
  93215. */
  93216. export class AudioSceneComponent implements ISceneSerializableComponent {
  93217. /**
  93218. * The component name helpfull to identify the component in the list of scene components.
  93219. */
  93220. readonly name: string;
  93221. /**
  93222. * The scene the component belongs to.
  93223. */
  93224. scene: Scene;
  93225. private _audioEnabled;
  93226. /**
  93227. * Gets whether audio is enabled or not.
  93228. * Please use related enable/disable method to switch state.
  93229. */
  93230. readonly audioEnabled: boolean;
  93231. private _headphone;
  93232. /**
  93233. * Gets whether audio is outputing to headphone or not.
  93234. * Please use the according Switch methods to change output.
  93235. */
  93236. readonly headphone: boolean;
  93237. /**
  93238. * Creates a new instance of the component for the given scene
  93239. * @param scene Defines the scene to register the component in
  93240. */
  93241. constructor(scene: Scene);
  93242. /**
  93243. * Registers the component in a given scene
  93244. */
  93245. register(): void;
  93246. /**
  93247. * Rebuilds the elements related to this component in case of
  93248. * context lost for instance.
  93249. */
  93250. rebuild(): void;
  93251. /**
  93252. * Serializes the component data to the specified json object
  93253. * @param serializationObject The object to serialize to
  93254. */
  93255. serialize(serializationObject: any): void;
  93256. /**
  93257. * Adds all the element from the container to the scene
  93258. * @param container the container holding the elements
  93259. */
  93260. addFromContainer(container: AbstractScene): void;
  93261. /**
  93262. * Removes all the elements in the container from the scene
  93263. * @param container contains the elements to remove
  93264. * @param dispose if the removed element should be disposed (default: false)
  93265. */
  93266. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93267. /**
  93268. * Disposes the component and the associated ressources.
  93269. */
  93270. dispose(): void;
  93271. /**
  93272. * Disables audio in the associated scene.
  93273. */
  93274. disableAudio(): void;
  93275. /**
  93276. * Enables audio in the associated scene.
  93277. */
  93278. enableAudio(): void;
  93279. /**
  93280. * Switch audio to headphone output.
  93281. */
  93282. switchAudioModeForHeadphones(): void;
  93283. /**
  93284. * Switch audio to normal speakers.
  93285. */
  93286. switchAudioModeForNormalSpeakers(): void;
  93287. private _afterRender;
  93288. }
  93289. }
  93290. declare module BABYLON {
  93291. /**
  93292. * Wraps one or more Sound objects and selects one with random weight for playback.
  93293. */
  93294. export class WeightedSound {
  93295. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93296. loop: boolean;
  93297. private _coneInnerAngle;
  93298. private _coneOuterAngle;
  93299. private _volume;
  93300. /** A Sound is currently playing. */
  93301. isPlaying: boolean;
  93302. /** A Sound is currently paused. */
  93303. isPaused: boolean;
  93304. private _sounds;
  93305. private _weights;
  93306. private _currentIndex?;
  93307. /**
  93308. * Creates a new WeightedSound from the list of sounds given.
  93309. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93310. * @param sounds Array of Sounds that will be selected from.
  93311. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93312. */
  93313. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93314. /**
  93315. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93316. */
  93317. /**
  93318. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93319. */
  93320. directionalConeInnerAngle: number;
  93321. /**
  93322. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93323. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93324. */
  93325. /**
  93326. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93327. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93328. */
  93329. directionalConeOuterAngle: number;
  93330. /**
  93331. * Playback volume.
  93332. */
  93333. /**
  93334. * Playback volume.
  93335. */
  93336. volume: number;
  93337. private _onended;
  93338. /**
  93339. * Suspend playback
  93340. */
  93341. pause(): void;
  93342. /**
  93343. * Stop playback
  93344. */
  93345. stop(): void;
  93346. /**
  93347. * Start playback.
  93348. * @param startOffset Position the clip head at a specific time in seconds.
  93349. */
  93350. play(startOffset?: number): void;
  93351. }
  93352. }
  93353. declare module BABYLON {
  93354. /**
  93355. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93356. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93357. */
  93358. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93359. /**
  93360. * Gets the name of the behavior.
  93361. */
  93362. readonly name: string;
  93363. /**
  93364. * The easing function used by animations
  93365. */
  93366. static EasingFunction: BackEase;
  93367. /**
  93368. * The easing mode used by animations
  93369. */
  93370. static EasingMode: number;
  93371. /**
  93372. * The duration of the animation, in milliseconds
  93373. */
  93374. transitionDuration: number;
  93375. /**
  93376. * Length of the distance animated by the transition when lower radius is reached
  93377. */
  93378. lowerRadiusTransitionRange: number;
  93379. /**
  93380. * Length of the distance animated by the transition when upper radius is reached
  93381. */
  93382. upperRadiusTransitionRange: number;
  93383. private _autoTransitionRange;
  93384. /**
  93385. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93386. */
  93387. /**
  93388. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93389. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93390. */
  93391. autoTransitionRange: boolean;
  93392. private _attachedCamera;
  93393. private _onAfterCheckInputsObserver;
  93394. private _onMeshTargetChangedObserver;
  93395. /**
  93396. * Initializes the behavior.
  93397. */
  93398. init(): void;
  93399. /**
  93400. * Attaches the behavior to its arc rotate camera.
  93401. * @param camera Defines the camera to attach the behavior to
  93402. */
  93403. attach(camera: ArcRotateCamera): void;
  93404. /**
  93405. * Detaches the behavior from its current arc rotate camera.
  93406. */
  93407. detach(): void;
  93408. private _radiusIsAnimating;
  93409. private _radiusBounceTransition;
  93410. private _animatables;
  93411. private _cachedWheelPrecision;
  93412. /**
  93413. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93414. * @param radiusLimit The limit to check against.
  93415. * @return Bool to indicate if at limit.
  93416. */
  93417. private _isRadiusAtLimit;
  93418. /**
  93419. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93420. * @param radiusDelta The delta by which to animate to. Can be negative.
  93421. */
  93422. private _applyBoundRadiusAnimation;
  93423. /**
  93424. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93425. */
  93426. protected _clearAnimationLocks(): void;
  93427. /**
  93428. * Stops and removes all animations that have been applied to the camera
  93429. */
  93430. stopAllAnimations(): void;
  93431. }
  93432. }
  93433. declare module BABYLON {
  93434. /**
  93435. * 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.
  93436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93437. */
  93438. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93439. /**
  93440. * Gets the name of the behavior.
  93441. */
  93442. readonly name: string;
  93443. private _mode;
  93444. private _radiusScale;
  93445. private _positionScale;
  93446. private _defaultElevation;
  93447. private _elevationReturnTime;
  93448. private _elevationReturnWaitTime;
  93449. private _zoomStopsAnimation;
  93450. private _framingTime;
  93451. /**
  93452. * The easing function used by animations
  93453. */
  93454. static EasingFunction: ExponentialEase;
  93455. /**
  93456. * The easing mode used by animations
  93457. */
  93458. static EasingMode: number;
  93459. /**
  93460. * Sets the current mode used by the behavior
  93461. */
  93462. /**
  93463. * Gets current mode used by the behavior.
  93464. */
  93465. mode: number;
  93466. /**
  93467. * Sets the scale applied to the radius (1 by default)
  93468. */
  93469. /**
  93470. * Gets the scale applied to the radius
  93471. */
  93472. radiusScale: number;
  93473. /**
  93474. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93475. */
  93476. /**
  93477. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93478. */
  93479. positionScale: number;
  93480. /**
  93481. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93482. * behaviour is triggered, in radians.
  93483. */
  93484. /**
  93485. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93486. * behaviour is triggered, in radians.
  93487. */
  93488. defaultElevation: number;
  93489. /**
  93490. * Sets the time (in milliseconds) taken to return to the default beta position.
  93491. * Negative value indicates camera should not return to default.
  93492. */
  93493. /**
  93494. * Gets the time (in milliseconds) taken to return to the default beta position.
  93495. * Negative value indicates camera should not return to default.
  93496. */
  93497. elevationReturnTime: number;
  93498. /**
  93499. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93500. */
  93501. /**
  93502. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93503. */
  93504. elevationReturnWaitTime: number;
  93505. /**
  93506. * Sets the flag that indicates if user zooming should stop animation.
  93507. */
  93508. /**
  93509. * Gets the flag that indicates if user zooming should stop animation.
  93510. */
  93511. zoomStopsAnimation: boolean;
  93512. /**
  93513. * Sets the transition time when framing the mesh, in milliseconds
  93514. */
  93515. /**
  93516. * Gets the transition time when framing the mesh, in milliseconds
  93517. */
  93518. framingTime: number;
  93519. /**
  93520. * Define if the behavior should automatically change the configured
  93521. * camera limits and sensibilities.
  93522. */
  93523. autoCorrectCameraLimitsAndSensibility: boolean;
  93524. private _onPrePointerObservableObserver;
  93525. private _onAfterCheckInputsObserver;
  93526. private _onMeshTargetChangedObserver;
  93527. private _attachedCamera;
  93528. private _isPointerDown;
  93529. private _lastInteractionTime;
  93530. /**
  93531. * Initializes the behavior.
  93532. */
  93533. init(): void;
  93534. /**
  93535. * Attaches the behavior to its arc rotate camera.
  93536. * @param camera Defines the camera to attach the behavior to
  93537. */
  93538. attach(camera: ArcRotateCamera): void;
  93539. /**
  93540. * Detaches the behavior from its current arc rotate camera.
  93541. */
  93542. detach(): void;
  93543. private _animatables;
  93544. private _betaIsAnimating;
  93545. private _betaTransition;
  93546. private _radiusTransition;
  93547. private _vectorTransition;
  93548. /**
  93549. * Targets the given mesh and updates zoom level accordingly.
  93550. * @param mesh The mesh to target.
  93551. * @param radius Optional. If a cached radius position already exists, overrides default.
  93552. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93555. */
  93556. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93557. /**
  93558. * Targets the given mesh with its children and updates zoom level accordingly.
  93559. * @param mesh The mesh to target.
  93560. * @param radius Optional. If a cached radius position already exists, overrides default.
  93561. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93562. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93563. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93564. */
  93565. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93566. /**
  93567. * Targets the given meshes with their children and updates zoom level accordingly.
  93568. * @param meshes The mesh to target.
  93569. * @param radius Optional. If a cached radius position already exists, overrides default.
  93570. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93571. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93572. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93573. */
  93574. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93575. /**
  93576. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93577. * @param minimumWorld Determines the smaller position of the bounding box extend
  93578. * @param maximumWorld Determines the bigger position of the bounding box extend
  93579. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93580. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93581. */
  93582. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93583. /**
  93584. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93585. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93586. * frustum width.
  93587. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93588. * to fully enclose the mesh in the viewing frustum.
  93589. */
  93590. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93591. /**
  93592. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93593. * is automatically returned to its default position (expected to be above ground plane).
  93594. */
  93595. private _maintainCameraAboveGround;
  93596. /**
  93597. * Returns the frustum slope based on the canvas ratio and camera FOV
  93598. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93599. */
  93600. private _getFrustumSlope;
  93601. /**
  93602. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93603. */
  93604. private _clearAnimationLocks;
  93605. /**
  93606. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93607. */
  93608. private _applyUserInteraction;
  93609. /**
  93610. * Stops and removes all animations that have been applied to the camera
  93611. */
  93612. stopAllAnimations(): void;
  93613. /**
  93614. * Gets a value indicating if the user is moving the camera
  93615. */
  93616. readonly isUserIsMoving: boolean;
  93617. /**
  93618. * The camera can move all the way towards the mesh.
  93619. */
  93620. static IgnoreBoundsSizeMode: number;
  93621. /**
  93622. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93623. */
  93624. static FitFrustumSidesMode: number;
  93625. }
  93626. }
  93627. declare module BABYLON {
  93628. /**
  93629. * Base class for Camera Pointer Inputs.
  93630. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93631. * for example usage.
  93632. */
  93633. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93634. /**
  93635. * Defines the camera the input is attached to.
  93636. */
  93637. abstract camera: Camera;
  93638. /**
  93639. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93640. */
  93641. protected _altKey: boolean;
  93642. protected _ctrlKey: boolean;
  93643. protected _metaKey: boolean;
  93644. protected _shiftKey: boolean;
  93645. /**
  93646. * Which mouse buttons were pressed at time of last mouse event.
  93647. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93648. */
  93649. protected _buttonsPressed: number;
  93650. /**
  93651. * Defines the buttons associated with the input to handle camera move.
  93652. */
  93653. buttons: number[];
  93654. /**
  93655. * Attach the input controls to a specific dom element to get the input from.
  93656. * @param element Defines the element the controls should be listened from
  93657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93658. */
  93659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93660. /**
  93661. * Detach the current controls from the specified dom element.
  93662. * @param element Defines the element to stop listening the inputs from
  93663. */
  93664. detachControl(element: Nullable<HTMLElement>): void;
  93665. /**
  93666. * Gets the class name of the current input.
  93667. * @returns the class name
  93668. */
  93669. getClassName(): string;
  93670. /**
  93671. * Get the friendly name associated with the input class.
  93672. * @returns the input friendly name
  93673. */
  93674. getSimpleName(): string;
  93675. /**
  93676. * Called on pointer POINTERDOUBLETAP event.
  93677. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93678. */
  93679. protected onDoubleTap(type: string): void;
  93680. /**
  93681. * Called on pointer POINTERMOVE event if only a single touch is active.
  93682. * Override this method to provide functionality.
  93683. */
  93684. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93685. /**
  93686. * Called on pointer POINTERMOVE event if multiple touches are active.
  93687. * Override this method to provide functionality.
  93688. */
  93689. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93690. /**
  93691. * Called on JS contextmenu event.
  93692. * Override this method to provide functionality.
  93693. */
  93694. protected onContextMenu(evt: PointerEvent): void;
  93695. /**
  93696. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93697. * press.
  93698. * Override this method to provide functionality.
  93699. */
  93700. protected onButtonDown(evt: PointerEvent): void;
  93701. /**
  93702. * Called each time a new POINTERUP event occurs. Ie, for each button
  93703. * release.
  93704. * Override this method to provide functionality.
  93705. */
  93706. protected onButtonUp(evt: PointerEvent): void;
  93707. /**
  93708. * Called when window becomes inactive.
  93709. * Override this method to provide functionality.
  93710. */
  93711. protected onLostFocus(): void;
  93712. private _pointerInput;
  93713. private _observer;
  93714. private _onLostFocus;
  93715. private pointA;
  93716. private pointB;
  93717. }
  93718. }
  93719. declare module BABYLON {
  93720. /**
  93721. * Manage the pointers inputs to control an arc rotate camera.
  93722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93723. */
  93724. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93725. /**
  93726. * Defines the camera the input is attached to.
  93727. */
  93728. camera: ArcRotateCamera;
  93729. /**
  93730. * Gets the class name of the current input.
  93731. * @returns the class name
  93732. */
  93733. getClassName(): string;
  93734. /**
  93735. * Defines the buttons associated with the input to handle camera move.
  93736. */
  93737. buttons: number[];
  93738. /**
  93739. * Defines the pointer angular sensibility along the X axis or how fast is
  93740. * the camera rotating.
  93741. */
  93742. angularSensibilityX: number;
  93743. /**
  93744. * Defines the pointer angular sensibility along the Y axis or how fast is
  93745. * the camera rotating.
  93746. */
  93747. angularSensibilityY: number;
  93748. /**
  93749. * Defines the pointer pinch precision or how fast is the camera zooming.
  93750. */
  93751. pinchPrecision: number;
  93752. /**
  93753. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93754. * from 0.
  93755. * It defines the percentage of current camera.radius to use as delta when
  93756. * pinch zoom is used.
  93757. */
  93758. pinchDeltaPercentage: number;
  93759. /**
  93760. * Defines the pointer panning sensibility or how fast is the camera moving.
  93761. */
  93762. panningSensibility: number;
  93763. /**
  93764. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  93765. */
  93766. multiTouchPanning: boolean;
  93767. /**
  93768. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  93769. * zoom (pinch) through multitouch.
  93770. */
  93771. multiTouchPanAndZoom: boolean;
  93772. /**
  93773. * Revers pinch action direction.
  93774. */
  93775. pinchInwards: boolean;
  93776. private _isPanClick;
  93777. private _twoFingerActivityCount;
  93778. private _isPinching;
  93779. /**
  93780. * Called on pointer POINTERMOVE event if only a single touch is active.
  93781. */
  93782. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93783. /**
  93784. * Called on pointer POINTERDOUBLETAP event.
  93785. */
  93786. protected onDoubleTap(type: string): void;
  93787. /**
  93788. * Called on pointer POINTERMOVE event if multiple touches are active.
  93789. */
  93790. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93791. /**
  93792. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93793. * press.
  93794. */
  93795. protected onButtonDown(evt: PointerEvent): void;
  93796. /**
  93797. * Called each time a new POINTERUP event occurs. Ie, for each button
  93798. * release.
  93799. */
  93800. protected onButtonUp(evt: PointerEvent): void;
  93801. /**
  93802. * Called when window becomes inactive.
  93803. */
  93804. protected onLostFocus(): void;
  93805. }
  93806. }
  93807. declare module BABYLON {
  93808. /**
  93809. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93811. */
  93812. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93813. /**
  93814. * Defines the camera the input is attached to.
  93815. */
  93816. camera: ArcRotateCamera;
  93817. /**
  93818. * Defines the list of key codes associated with the up action (increase alpha)
  93819. */
  93820. keysUp: number[];
  93821. /**
  93822. * Defines the list of key codes associated with the down action (decrease alpha)
  93823. */
  93824. keysDown: number[];
  93825. /**
  93826. * Defines the list of key codes associated with the left action (increase beta)
  93827. */
  93828. keysLeft: number[];
  93829. /**
  93830. * Defines the list of key codes associated with the right action (decrease beta)
  93831. */
  93832. keysRight: number[];
  93833. /**
  93834. * Defines the list of key codes associated with the reset action.
  93835. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93836. */
  93837. keysReset: number[];
  93838. /**
  93839. * Defines the panning sensibility of the inputs.
  93840. * (How fast is the camera paning)
  93841. */
  93842. panningSensibility: number;
  93843. /**
  93844. * Defines the zooming sensibility of the inputs.
  93845. * (How fast is the camera zooming)
  93846. */
  93847. zoomingSensibility: number;
  93848. /**
  93849. * Defines wether maintaining the alt key down switch the movement mode from
  93850. * orientation to zoom.
  93851. */
  93852. useAltToZoom: boolean;
  93853. /**
  93854. * Rotation speed of the camera
  93855. */
  93856. angularSpeed: number;
  93857. private _keys;
  93858. private _ctrlPressed;
  93859. private _altPressed;
  93860. private _onCanvasBlurObserver;
  93861. private _onKeyboardObserver;
  93862. private _engine;
  93863. private _scene;
  93864. /**
  93865. * Attach the input controls to a specific dom element to get the input from.
  93866. * @param element Defines the element the controls should be listened from
  93867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93868. */
  93869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93870. /**
  93871. * Detach the current controls from the specified dom element.
  93872. * @param element Defines the element to stop listening the inputs from
  93873. */
  93874. detachControl(element: Nullable<HTMLElement>): void;
  93875. /**
  93876. * Update the current camera state depending on the inputs that have been used this frame.
  93877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93878. */
  93879. checkInputs(): void;
  93880. /**
  93881. * Gets the class name of the current intput.
  93882. * @returns the class name
  93883. */
  93884. getClassName(): string;
  93885. /**
  93886. * Get the friendly name associated with the input class.
  93887. * @returns the input friendly name
  93888. */
  93889. getSimpleName(): string;
  93890. }
  93891. }
  93892. declare module BABYLON {
  93893. /**
  93894. * Manage the mouse wheel inputs to control an arc rotate camera.
  93895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93896. */
  93897. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93898. /**
  93899. * Defines the camera the input is attached to.
  93900. */
  93901. camera: ArcRotateCamera;
  93902. /**
  93903. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93904. */
  93905. wheelPrecision: number;
  93906. /**
  93907. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93908. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93909. */
  93910. wheelDeltaPercentage: number;
  93911. private _wheel;
  93912. private _observer;
  93913. /**
  93914. * Attach the input controls to a specific dom element to get the input from.
  93915. * @param element Defines the element the controls should be listened from
  93916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93917. */
  93918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93919. /**
  93920. * Detach the current controls from the specified dom element.
  93921. * @param element Defines the element to stop listening the inputs from
  93922. */
  93923. detachControl(element: Nullable<HTMLElement>): void;
  93924. /**
  93925. * Gets the class name of the current intput.
  93926. * @returns the class name
  93927. */
  93928. getClassName(): string;
  93929. /**
  93930. * Get the friendly name associated with the input class.
  93931. * @returns the input friendly name
  93932. */
  93933. getSimpleName(): string;
  93934. }
  93935. }
  93936. declare module BABYLON {
  93937. /**
  93938. * Default Inputs manager for the ArcRotateCamera.
  93939. * It groups all the default supported inputs for ease of use.
  93940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93941. */
  93942. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93943. /**
  93944. * Instantiates a new ArcRotateCameraInputsManager.
  93945. * @param camera Defines the camera the inputs belong to
  93946. */
  93947. constructor(camera: ArcRotateCamera);
  93948. /**
  93949. * Add mouse wheel input support to the input manager.
  93950. * @returns the current input manager
  93951. */
  93952. addMouseWheel(): ArcRotateCameraInputsManager;
  93953. /**
  93954. * Add pointers input support to the input manager.
  93955. * @returns the current input manager
  93956. */
  93957. addPointers(): ArcRotateCameraInputsManager;
  93958. /**
  93959. * Add keyboard input support to the input manager.
  93960. * @returns the current input manager
  93961. */
  93962. addKeyboard(): ArcRotateCameraInputsManager;
  93963. }
  93964. }
  93965. declare module BABYLON {
  93966. /**
  93967. * This represents an orbital type of camera.
  93968. *
  93969. * 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.
  93970. * 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.
  93971. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93972. */
  93973. export class ArcRotateCamera extends TargetCamera {
  93974. /**
  93975. * Defines the rotation angle of the camera along the longitudinal axis.
  93976. */
  93977. alpha: number;
  93978. /**
  93979. * Defines the rotation angle of the camera along the latitudinal axis.
  93980. */
  93981. beta: number;
  93982. /**
  93983. * Defines the radius of the camera from it s target point.
  93984. */
  93985. radius: number;
  93986. protected _target: Vector3;
  93987. protected _targetHost: Nullable<AbstractMesh>;
  93988. /**
  93989. * Defines the target point of the camera.
  93990. * The camera looks towards it form the radius distance.
  93991. */
  93992. target: Vector3;
  93993. /**
  93994. * Define the current local position of the camera in the scene
  93995. */
  93996. position: Vector3;
  93997. /**
  93998. * Current inertia value on the longitudinal axis.
  93999. * The bigger this number the longer it will take for the camera to stop.
  94000. */
  94001. inertialAlphaOffset: number;
  94002. /**
  94003. * Current inertia value on the latitudinal axis.
  94004. * The bigger this number the longer it will take for the camera to stop.
  94005. */
  94006. inertialBetaOffset: number;
  94007. /**
  94008. * Current inertia value on the radius axis.
  94009. * The bigger this number the longer it will take for the camera to stop.
  94010. */
  94011. inertialRadiusOffset: number;
  94012. /**
  94013. * Minimum allowed angle on the longitudinal axis.
  94014. * This can help limiting how the Camera is able to move in the scene.
  94015. */
  94016. lowerAlphaLimit: Nullable<number>;
  94017. /**
  94018. * Maximum allowed angle on the longitudinal axis.
  94019. * This can help limiting how the Camera is able to move in the scene.
  94020. */
  94021. upperAlphaLimit: Nullable<number>;
  94022. /**
  94023. * Minimum allowed angle on the latitudinal axis.
  94024. * This can help limiting how the Camera is able to move in the scene.
  94025. */
  94026. lowerBetaLimit: number;
  94027. /**
  94028. * Maximum allowed angle on the latitudinal axis.
  94029. * This can help limiting how the Camera is able to move in the scene.
  94030. */
  94031. upperBetaLimit: number;
  94032. /**
  94033. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94034. * This can help limiting how the Camera is able to move in the scene.
  94035. */
  94036. lowerRadiusLimit: Nullable<number>;
  94037. /**
  94038. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94039. * This can help limiting how the Camera is able to move in the scene.
  94040. */
  94041. upperRadiusLimit: Nullable<number>;
  94042. /**
  94043. * Defines the current inertia value used during panning of the camera along the X axis.
  94044. */
  94045. inertialPanningX: number;
  94046. /**
  94047. * Defines the current inertia value used during panning of the camera along the Y axis.
  94048. */
  94049. inertialPanningY: number;
  94050. /**
  94051. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94052. * Basically if your fingers moves away from more than this distance you will be considered
  94053. * in pinch mode.
  94054. */
  94055. pinchToPanMaxDistance: number;
  94056. /**
  94057. * Defines the maximum distance the camera can pan.
  94058. * This could help keeping the cammera always in your scene.
  94059. */
  94060. panningDistanceLimit: Nullable<number>;
  94061. /**
  94062. * Defines the target of the camera before paning.
  94063. */
  94064. panningOriginTarget: Vector3;
  94065. /**
  94066. * Defines the value of the inertia used during panning.
  94067. * 0 would mean stop inertia and one would mean no decelleration at all.
  94068. */
  94069. panningInertia: number;
  94070. /**
  94071. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94072. */
  94073. angularSensibilityX: number;
  94074. /**
  94075. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94076. */
  94077. angularSensibilityY: number;
  94078. /**
  94079. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94080. */
  94081. pinchPrecision: number;
  94082. /**
  94083. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94084. * It will be used instead of pinchDeltaPrecision if different from 0.
  94085. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94086. */
  94087. pinchDeltaPercentage: number;
  94088. /**
  94089. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94090. */
  94091. panningSensibility: number;
  94092. /**
  94093. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94094. */
  94095. keysUp: number[];
  94096. /**
  94097. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94098. */
  94099. keysDown: number[];
  94100. /**
  94101. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94102. */
  94103. keysLeft: number[];
  94104. /**
  94105. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94106. */
  94107. keysRight: number[];
  94108. /**
  94109. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94110. */
  94111. wheelPrecision: number;
  94112. /**
  94113. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94114. * It will be used instead of pinchDeltaPrecision if different from 0.
  94115. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94116. */
  94117. wheelDeltaPercentage: number;
  94118. /**
  94119. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94120. */
  94121. zoomOnFactor: number;
  94122. /**
  94123. * Defines a screen offset for the camera position.
  94124. */
  94125. targetScreenOffset: Vector2;
  94126. /**
  94127. * Allows the camera to be completely reversed.
  94128. * If false the camera can not arrive upside down.
  94129. */
  94130. allowUpsideDown: boolean;
  94131. /**
  94132. * Define if double tap/click is used to restore the previously saved state of the camera.
  94133. */
  94134. useInputToRestoreState: boolean;
  94135. /** @hidden */
  94136. _viewMatrix: Matrix;
  94137. /** @hidden */
  94138. _useCtrlForPanning: boolean;
  94139. /** @hidden */
  94140. _panningMouseButton: number;
  94141. /**
  94142. * Defines the input associated to the camera.
  94143. */
  94144. inputs: ArcRotateCameraInputsManager;
  94145. /** @hidden */
  94146. _reset: () => void;
  94147. /**
  94148. * Defines the allowed panning axis.
  94149. */
  94150. panningAxis: Vector3;
  94151. protected _localDirection: Vector3;
  94152. protected _transformedDirection: Vector3;
  94153. private _bouncingBehavior;
  94154. /**
  94155. * Gets the bouncing behavior of the camera if it has been enabled.
  94156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94157. */
  94158. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94159. /**
  94160. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94162. */
  94163. useBouncingBehavior: boolean;
  94164. private _framingBehavior;
  94165. /**
  94166. * Gets the framing behavior of the camera if it has been enabled.
  94167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94168. */
  94169. readonly framingBehavior: Nullable<FramingBehavior>;
  94170. /**
  94171. * Defines if the framing behavior of the camera is enabled on the camera.
  94172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94173. */
  94174. useFramingBehavior: boolean;
  94175. private _autoRotationBehavior;
  94176. /**
  94177. * Gets the auto rotation behavior of the camera if it has been enabled.
  94178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94179. */
  94180. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94181. /**
  94182. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94184. */
  94185. useAutoRotationBehavior: boolean;
  94186. /**
  94187. * Observable triggered when the mesh target has been changed on the camera.
  94188. */
  94189. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94190. /**
  94191. * Event raised when the camera is colliding with a mesh.
  94192. */
  94193. onCollide: (collidedMesh: AbstractMesh) => void;
  94194. /**
  94195. * Defines whether the camera should check collision with the objects oh the scene.
  94196. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94197. */
  94198. checkCollisions: boolean;
  94199. /**
  94200. * Defines the collision radius of the camera.
  94201. * This simulates a sphere around the camera.
  94202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94203. */
  94204. collisionRadius: Vector3;
  94205. protected _collider: Collider;
  94206. protected _previousPosition: Vector3;
  94207. protected _collisionVelocity: Vector3;
  94208. protected _newPosition: Vector3;
  94209. protected _previousAlpha: number;
  94210. protected _previousBeta: number;
  94211. protected _previousRadius: number;
  94212. protected _collisionTriggered: boolean;
  94213. protected _targetBoundingCenter: Nullable<Vector3>;
  94214. private _computationVector;
  94215. private _tempAxisVector;
  94216. private _tempAxisRotationMatrix;
  94217. /**
  94218. * Instantiates a new ArcRotateCamera in a given scene
  94219. * @param name Defines the name of the camera
  94220. * @param alpha Defines the camera rotation along the logitudinal axis
  94221. * @param beta Defines the camera rotation along the latitudinal axis
  94222. * @param radius Defines the camera distance from its target
  94223. * @param target Defines the camera target
  94224. * @param scene Defines the scene the camera belongs to
  94225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94226. */
  94227. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94228. /** @hidden */
  94229. _initCache(): void;
  94230. /** @hidden */
  94231. _updateCache(ignoreParentClass?: boolean): void;
  94232. protected _getTargetPosition(): Vector3;
  94233. private _storedAlpha;
  94234. private _storedBeta;
  94235. private _storedRadius;
  94236. private _storedTarget;
  94237. /**
  94238. * Stores the current state of the camera (alpha, beta, radius and target)
  94239. * @returns the camera itself
  94240. */
  94241. storeState(): Camera;
  94242. /**
  94243. * @hidden
  94244. * Restored camera state. You must call storeState() first
  94245. */
  94246. _restoreStateValues(): boolean;
  94247. /** @hidden */
  94248. _isSynchronizedViewMatrix(): boolean;
  94249. /**
  94250. * Attached controls to the current camera.
  94251. * @param element Defines the element the controls should be listened from
  94252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94253. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94254. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94255. */
  94256. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94257. /**
  94258. * Detach the current controls from the camera.
  94259. * The camera will stop reacting to inputs.
  94260. * @param element Defines the element to stop listening the inputs from
  94261. */
  94262. detachControl(element: HTMLElement): void;
  94263. /** @hidden */
  94264. _checkInputs(): void;
  94265. protected _checkLimits(): void;
  94266. /**
  94267. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94268. */
  94269. rebuildAnglesAndRadius(): void;
  94270. /**
  94271. * Use a position to define the current camera related information like aplha, beta and radius
  94272. * @param position Defines the position to set the camera at
  94273. */
  94274. setPosition(position: Vector3): void;
  94275. /**
  94276. * Defines the target the camera should look at.
  94277. * This will automatically adapt alpha beta and radius to fit within the new target.
  94278. * @param target Defines the new target as a Vector or a mesh
  94279. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94280. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94281. */
  94282. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94283. /** @hidden */
  94284. _getViewMatrix(): Matrix;
  94285. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94286. /**
  94287. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94288. * @param meshes Defines the mesh to zoom on
  94289. * @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)
  94290. */
  94291. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94292. /**
  94293. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94294. * The target will be changed but the radius
  94295. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94296. * @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)
  94297. */
  94298. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94299. min: Vector3;
  94300. max: Vector3;
  94301. distance: number;
  94302. }, doNotUpdateMaxZ?: boolean): void;
  94303. /**
  94304. * @override
  94305. * Override Camera.createRigCamera
  94306. */
  94307. createRigCamera(name: string, cameraIndex: number): Camera;
  94308. /**
  94309. * @hidden
  94310. * @override
  94311. * Override Camera._updateRigCameras
  94312. */
  94313. _updateRigCameras(): void;
  94314. /**
  94315. * Destroy the camera and release the current resources hold by it.
  94316. */
  94317. dispose(): void;
  94318. /**
  94319. * Gets the current object class name.
  94320. * @return the class name
  94321. */
  94322. getClassName(): string;
  94323. }
  94324. }
  94325. declare module BABYLON {
  94326. /**
  94327. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94329. */
  94330. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94331. /**
  94332. * Gets the name of the behavior.
  94333. */
  94334. readonly name: string;
  94335. private _zoomStopsAnimation;
  94336. private _idleRotationSpeed;
  94337. private _idleRotationWaitTime;
  94338. private _idleRotationSpinupTime;
  94339. /**
  94340. * Sets the flag that indicates if user zooming should stop animation.
  94341. */
  94342. /**
  94343. * Gets the flag that indicates if user zooming should stop animation.
  94344. */
  94345. zoomStopsAnimation: boolean;
  94346. /**
  94347. * Sets the default speed at which the camera rotates around the model.
  94348. */
  94349. /**
  94350. * Gets the default speed at which the camera rotates around the model.
  94351. */
  94352. idleRotationSpeed: number;
  94353. /**
  94354. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94355. */
  94356. /**
  94357. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94358. */
  94359. idleRotationWaitTime: number;
  94360. /**
  94361. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94362. */
  94363. /**
  94364. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94365. */
  94366. idleRotationSpinupTime: number;
  94367. /**
  94368. * Gets a value indicating if the camera is currently rotating because of this behavior
  94369. */
  94370. readonly rotationInProgress: boolean;
  94371. private _onPrePointerObservableObserver;
  94372. private _onAfterCheckInputsObserver;
  94373. private _attachedCamera;
  94374. private _isPointerDown;
  94375. private _lastFrameTime;
  94376. private _lastInteractionTime;
  94377. private _cameraRotationSpeed;
  94378. /**
  94379. * Initializes the behavior.
  94380. */
  94381. init(): void;
  94382. /**
  94383. * Attaches the behavior to its arc rotate camera.
  94384. * @param camera Defines the camera to attach the behavior to
  94385. */
  94386. attach(camera: ArcRotateCamera): void;
  94387. /**
  94388. * Detaches the behavior from its current arc rotate camera.
  94389. */
  94390. detach(): void;
  94391. /**
  94392. * Returns true if user is scrolling.
  94393. * @return true if user is scrolling.
  94394. */
  94395. private _userIsZooming;
  94396. private _lastFrameRadius;
  94397. private _shouldAnimationStopForInteraction;
  94398. /**
  94399. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94400. */
  94401. private _applyUserInteraction;
  94402. private _userIsMoving;
  94403. }
  94404. }
  94405. declare module BABYLON {
  94406. /**
  94407. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94408. */
  94409. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94410. private ui;
  94411. /**
  94412. * The name of the behavior
  94413. */
  94414. name: string;
  94415. /**
  94416. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94417. */
  94418. distanceAwayFromFace: number;
  94419. /**
  94420. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94421. */
  94422. distanceAwayFromBottomOfFace: number;
  94423. private _faceVectors;
  94424. private _target;
  94425. private _scene;
  94426. private _onRenderObserver;
  94427. private _tmpMatrix;
  94428. private _tmpVector;
  94429. /**
  94430. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94431. * @param ui The transform node that should be attched to the mesh
  94432. */
  94433. constructor(ui: TransformNode);
  94434. /**
  94435. * Initializes the behavior
  94436. */
  94437. init(): void;
  94438. private _closestFace;
  94439. private _zeroVector;
  94440. private _lookAtTmpMatrix;
  94441. private _lookAtToRef;
  94442. /**
  94443. * Attaches the AttachToBoxBehavior to the passed in mesh
  94444. * @param target The mesh that the specified node will be attached to
  94445. */
  94446. attach(target: Mesh): void;
  94447. /**
  94448. * Detaches the behavior from the mesh
  94449. */
  94450. detach(): void;
  94451. }
  94452. }
  94453. declare module BABYLON {
  94454. /**
  94455. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94456. */
  94457. export class FadeInOutBehavior implements Behavior<Mesh> {
  94458. /**
  94459. * Time in milliseconds to delay before fading in (Default: 0)
  94460. */
  94461. delay: number;
  94462. /**
  94463. * Time in milliseconds for the mesh to fade in (Default: 300)
  94464. */
  94465. fadeInTime: number;
  94466. private _millisecondsPerFrame;
  94467. private _hovered;
  94468. private _hoverValue;
  94469. private _ownerNode;
  94470. /**
  94471. * Instatiates the FadeInOutBehavior
  94472. */
  94473. constructor();
  94474. /**
  94475. * The name of the behavior
  94476. */
  94477. readonly name: string;
  94478. /**
  94479. * Initializes the behavior
  94480. */
  94481. init(): void;
  94482. /**
  94483. * Attaches the fade behavior on the passed in mesh
  94484. * @param ownerNode The mesh that will be faded in/out once attached
  94485. */
  94486. attach(ownerNode: Mesh): void;
  94487. /**
  94488. * Detaches the behavior from the mesh
  94489. */
  94490. detach(): void;
  94491. /**
  94492. * Triggers the mesh to begin fading in or out
  94493. * @param value if the object should fade in or out (true to fade in)
  94494. */
  94495. fadeIn(value: boolean): void;
  94496. private _update;
  94497. private _setAllVisibility;
  94498. }
  94499. }
  94500. declare module BABYLON {
  94501. /**
  94502. * Class containing a set of static utilities functions for managing Pivots
  94503. * @hidden
  94504. */
  94505. export class PivotTools {
  94506. private static _PivotCached;
  94507. private static _OldPivotPoint;
  94508. private static _PivotTranslation;
  94509. private static _PivotTmpVector;
  94510. /** @hidden */
  94511. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94512. /** @hidden */
  94513. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94514. }
  94515. }
  94516. declare module BABYLON {
  94517. /**
  94518. * Class containing static functions to help procedurally build meshes
  94519. */
  94520. export class PlaneBuilder {
  94521. /**
  94522. * Creates a plane mesh
  94523. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94524. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94525. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94529. * @param name defines the name of the mesh
  94530. * @param options defines the options used to create the mesh
  94531. * @param scene defines the hosting scene
  94532. * @returns the plane mesh
  94533. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94534. */
  94535. static CreatePlane(name: string, options: {
  94536. size?: number;
  94537. width?: number;
  94538. height?: number;
  94539. sideOrientation?: number;
  94540. frontUVs?: Vector4;
  94541. backUVs?: Vector4;
  94542. updatable?: boolean;
  94543. sourcePlane?: Plane;
  94544. }, scene: Scene): Mesh;
  94545. }
  94546. }
  94547. declare module BABYLON {
  94548. /**
  94549. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94550. */
  94551. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94552. private static _AnyMouseID;
  94553. private _attachedNode;
  94554. private _dragPlane;
  94555. private _scene;
  94556. private _pointerObserver;
  94557. private _beforeRenderObserver;
  94558. private static _planeScene;
  94559. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94560. /**
  94561. * 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)
  94562. */
  94563. maxDragAngle: number;
  94564. /**
  94565. * @hidden
  94566. */
  94567. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94568. /**
  94569. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94570. */
  94571. currentDraggingPointerID: number;
  94572. /**
  94573. * The last position where the pointer hit the drag plane in world space
  94574. */
  94575. lastDragPosition: Vector3;
  94576. /**
  94577. * If the behavior is currently in a dragging state
  94578. */
  94579. dragging: boolean;
  94580. /**
  94581. * 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)
  94582. */
  94583. dragDeltaRatio: number;
  94584. /**
  94585. * If the drag plane orientation should be updated during the dragging (Default: true)
  94586. */
  94587. updateDragPlane: boolean;
  94588. private _debugMode;
  94589. private _moving;
  94590. /**
  94591. * Fires each time the attached mesh is dragged with the pointer
  94592. * * delta between last drag position and current drag position in world space
  94593. * * dragDistance along the drag axis
  94594. * * dragPlaneNormal normal of the current drag plane used during the drag
  94595. * * dragPlanePoint in world space where the drag intersects the drag plane
  94596. */
  94597. onDragObservable: Observable<{
  94598. delta: Vector3;
  94599. dragPlanePoint: Vector3;
  94600. dragPlaneNormal: Vector3;
  94601. dragDistance: number;
  94602. pointerId: number;
  94603. }>;
  94604. /**
  94605. * Fires each time a drag begins (eg. mouse down on mesh)
  94606. */
  94607. onDragStartObservable: Observable<{
  94608. dragPlanePoint: Vector3;
  94609. pointerId: number;
  94610. }>;
  94611. /**
  94612. * Fires each time a drag ends (eg. mouse release after drag)
  94613. */
  94614. onDragEndObservable: Observable<{
  94615. dragPlanePoint: Vector3;
  94616. pointerId: number;
  94617. }>;
  94618. /**
  94619. * If the attached mesh should be moved when dragged
  94620. */
  94621. moveAttached: boolean;
  94622. /**
  94623. * If the drag behavior will react to drag events (Default: true)
  94624. */
  94625. enabled: boolean;
  94626. /**
  94627. * If camera controls should be detached during the drag
  94628. */
  94629. detachCameraControls: boolean;
  94630. /**
  94631. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94632. */
  94633. useObjectOrienationForDragging: boolean;
  94634. private _options;
  94635. /**
  94636. * Creates a pointer drag behavior that can be attached to a mesh
  94637. * @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)
  94638. */
  94639. constructor(options?: {
  94640. dragAxis?: Vector3;
  94641. dragPlaneNormal?: Vector3;
  94642. });
  94643. /**
  94644. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94645. */
  94646. validateDrag: (targetPosition: Vector3) => boolean;
  94647. /**
  94648. * The name of the behavior
  94649. */
  94650. readonly name: string;
  94651. /**
  94652. * Initializes the behavior
  94653. */
  94654. init(): void;
  94655. private _tmpVector;
  94656. private _alternatePickedPoint;
  94657. private _worldDragAxis;
  94658. private _targetPosition;
  94659. private _attachedElement;
  94660. /**
  94661. * Attaches the drag behavior the passed in mesh
  94662. * @param ownerNode The mesh that will be dragged around once attached
  94663. */
  94664. attach(ownerNode: AbstractMesh): void;
  94665. /**
  94666. * Force relase the drag action by code.
  94667. */
  94668. releaseDrag(): void;
  94669. private _startDragRay;
  94670. private _lastPointerRay;
  94671. /**
  94672. * Simulates the start of a pointer drag event on the behavior
  94673. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94674. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94675. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94676. */
  94677. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94678. private _startDrag;
  94679. private _dragDelta;
  94680. private _moveDrag;
  94681. private _pickWithRayOnDragPlane;
  94682. private _pointA;
  94683. private _pointB;
  94684. private _pointC;
  94685. private _lineA;
  94686. private _lineB;
  94687. private _localAxis;
  94688. private _lookAt;
  94689. private _updateDragPlanePosition;
  94690. /**
  94691. * Detaches the behavior from the mesh
  94692. */
  94693. detach(): void;
  94694. }
  94695. }
  94696. declare module BABYLON {
  94697. /**
  94698. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94699. */
  94700. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94701. private _dragBehaviorA;
  94702. private _dragBehaviorB;
  94703. private _startDistance;
  94704. private _initialScale;
  94705. private _targetScale;
  94706. private _ownerNode;
  94707. private _sceneRenderObserver;
  94708. /**
  94709. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94710. */
  94711. constructor();
  94712. /**
  94713. * The name of the behavior
  94714. */
  94715. readonly name: string;
  94716. /**
  94717. * Initializes the behavior
  94718. */
  94719. init(): void;
  94720. private _getCurrentDistance;
  94721. /**
  94722. * Attaches the scale behavior the passed in mesh
  94723. * @param ownerNode The mesh that will be scaled around once attached
  94724. */
  94725. attach(ownerNode: Mesh): void;
  94726. /**
  94727. * Detaches the behavior from the mesh
  94728. */
  94729. detach(): void;
  94730. }
  94731. }
  94732. declare module BABYLON {
  94733. /**
  94734. * 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
  94735. */
  94736. export class SixDofDragBehavior implements Behavior<Mesh> {
  94737. private static _virtualScene;
  94738. private _ownerNode;
  94739. private _sceneRenderObserver;
  94740. private _scene;
  94741. private _targetPosition;
  94742. private _virtualOriginMesh;
  94743. private _virtualDragMesh;
  94744. private _pointerObserver;
  94745. private _moving;
  94746. private _startingOrientation;
  94747. /**
  94748. * 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)
  94749. */
  94750. private zDragFactor;
  94751. /**
  94752. * If the object should rotate to face the drag origin
  94753. */
  94754. rotateDraggedObject: boolean;
  94755. /**
  94756. * If the behavior is currently in a dragging state
  94757. */
  94758. dragging: boolean;
  94759. /**
  94760. * 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)
  94761. */
  94762. dragDeltaRatio: number;
  94763. /**
  94764. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94765. */
  94766. currentDraggingPointerID: number;
  94767. /**
  94768. * If camera controls should be detached during the drag
  94769. */
  94770. detachCameraControls: boolean;
  94771. /**
  94772. * Fires each time a drag starts
  94773. */
  94774. onDragStartObservable: Observable<{}>;
  94775. /**
  94776. * Fires each time a drag ends (eg. mouse release after drag)
  94777. */
  94778. onDragEndObservable: Observable<{}>;
  94779. /**
  94780. * 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
  94781. */
  94782. constructor();
  94783. /**
  94784. * The name of the behavior
  94785. */
  94786. readonly name: string;
  94787. /**
  94788. * Initializes the behavior
  94789. */
  94790. init(): void;
  94791. /**
  94792. * Attaches the scale behavior the passed in mesh
  94793. * @param ownerNode The mesh that will be scaled around once attached
  94794. */
  94795. attach(ownerNode: Mesh): void;
  94796. /**
  94797. * Detaches the behavior from the mesh
  94798. */
  94799. detach(): void;
  94800. }
  94801. }
  94802. declare module BABYLON {
  94803. /**
  94804. * Class used to apply inverse kinematics to bones
  94805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94806. */
  94807. export class BoneIKController {
  94808. private static _tmpVecs;
  94809. private static _tmpQuat;
  94810. private static _tmpMats;
  94811. /**
  94812. * Gets or sets the target mesh
  94813. */
  94814. targetMesh: AbstractMesh;
  94815. /** Gets or sets the mesh used as pole */
  94816. poleTargetMesh: AbstractMesh;
  94817. /**
  94818. * Gets or sets the bone used as pole
  94819. */
  94820. poleTargetBone: Nullable<Bone>;
  94821. /**
  94822. * Gets or sets the target position
  94823. */
  94824. targetPosition: Vector3;
  94825. /**
  94826. * Gets or sets the pole target position
  94827. */
  94828. poleTargetPosition: Vector3;
  94829. /**
  94830. * Gets or sets the pole target local offset
  94831. */
  94832. poleTargetLocalOffset: Vector3;
  94833. /**
  94834. * Gets or sets the pole angle
  94835. */
  94836. poleAngle: number;
  94837. /**
  94838. * Gets or sets the mesh associated with the controller
  94839. */
  94840. mesh: AbstractMesh;
  94841. /**
  94842. * 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)
  94843. */
  94844. slerpAmount: number;
  94845. private _bone1Quat;
  94846. private _bone1Mat;
  94847. private _bone2Ang;
  94848. private _bone1;
  94849. private _bone2;
  94850. private _bone1Length;
  94851. private _bone2Length;
  94852. private _maxAngle;
  94853. private _maxReach;
  94854. private _rightHandedSystem;
  94855. private _bendAxis;
  94856. private _slerping;
  94857. private _adjustRoll;
  94858. /**
  94859. * Gets or sets maximum allowed angle
  94860. */
  94861. maxAngle: number;
  94862. /**
  94863. * Creates a new BoneIKController
  94864. * @param mesh defines the mesh to control
  94865. * @param bone defines the bone to control
  94866. * @param options defines options to set up the controller
  94867. */
  94868. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94869. targetMesh?: AbstractMesh;
  94870. poleTargetMesh?: AbstractMesh;
  94871. poleTargetBone?: Bone;
  94872. poleTargetLocalOffset?: Vector3;
  94873. poleAngle?: number;
  94874. bendAxis?: Vector3;
  94875. maxAngle?: number;
  94876. slerpAmount?: number;
  94877. });
  94878. private _setMaxAngle;
  94879. /**
  94880. * Force the controller to update the bones
  94881. */
  94882. update(): void;
  94883. }
  94884. }
  94885. declare module BABYLON {
  94886. /**
  94887. * Class used to make a bone look toward a point in space
  94888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94889. */
  94890. export class BoneLookController {
  94891. private static _tmpVecs;
  94892. private static _tmpQuat;
  94893. private static _tmpMats;
  94894. /**
  94895. * The target Vector3 that the bone will look at
  94896. */
  94897. target: Vector3;
  94898. /**
  94899. * The mesh that the bone is attached to
  94900. */
  94901. mesh: AbstractMesh;
  94902. /**
  94903. * The bone that will be looking to the target
  94904. */
  94905. bone: Bone;
  94906. /**
  94907. * The up axis of the coordinate system that is used when the bone is rotated
  94908. */
  94909. upAxis: Vector3;
  94910. /**
  94911. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94912. */
  94913. upAxisSpace: Space;
  94914. /**
  94915. * Used to make an adjustment to the yaw of the bone
  94916. */
  94917. adjustYaw: number;
  94918. /**
  94919. * Used to make an adjustment to the pitch of the bone
  94920. */
  94921. adjustPitch: number;
  94922. /**
  94923. * Used to make an adjustment to the roll of the bone
  94924. */
  94925. adjustRoll: number;
  94926. /**
  94927. * 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)
  94928. */
  94929. slerpAmount: number;
  94930. private _minYaw;
  94931. private _maxYaw;
  94932. private _minPitch;
  94933. private _maxPitch;
  94934. private _minYawSin;
  94935. private _minYawCos;
  94936. private _maxYawSin;
  94937. private _maxYawCos;
  94938. private _midYawConstraint;
  94939. private _minPitchTan;
  94940. private _maxPitchTan;
  94941. private _boneQuat;
  94942. private _slerping;
  94943. private _transformYawPitch;
  94944. private _transformYawPitchInv;
  94945. private _firstFrameSkipped;
  94946. private _yawRange;
  94947. private _fowardAxis;
  94948. /**
  94949. * Gets or sets the minimum yaw angle that the bone can look to
  94950. */
  94951. minYaw: number;
  94952. /**
  94953. * Gets or sets the maximum yaw angle that the bone can look to
  94954. */
  94955. maxYaw: number;
  94956. /**
  94957. * Gets or sets the minimum pitch angle that the bone can look to
  94958. */
  94959. minPitch: number;
  94960. /**
  94961. * Gets or sets the maximum pitch angle that the bone can look to
  94962. */
  94963. maxPitch: number;
  94964. /**
  94965. * Create a BoneLookController
  94966. * @param mesh the mesh that the bone belongs to
  94967. * @param bone the bone that will be looking to the target
  94968. * @param target the target Vector3 to look at
  94969. * @param options optional settings:
  94970. * * maxYaw: the maximum angle the bone will yaw to
  94971. * * minYaw: the minimum angle the bone will yaw to
  94972. * * maxPitch: the maximum angle the bone will pitch to
  94973. * * minPitch: the minimum angle the bone will yaw to
  94974. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94975. * * upAxis: the up axis of the coordinate system
  94976. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94977. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94978. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94979. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94980. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94981. * * adjustRoll: used to make an adjustment to the roll of the bone
  94982. **/
  94983. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94984. maxYaw?: number;
  94985. minYaw?: number;
  94986. maxPitch?: number;
  94987. minPitch?: number;
  94988. slerpAmount?: number;
  94989. upAxis?: Vector3;
  94990. upAxisSpace?: Space;
  94991. yawAxis?: Vector3;
  94992. pitchAxis?: Vector3;
  94993. adjustYaw?: number;
  94994. adjustPitch?: number;
  94995. adjustRoll?: number;
  94996. });
  94997. /**
  94998. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94999. */
  95000. update(): void;
  95001. private _getAngleDiff;
  95002. private _getAngleBetween;
  95003. private _isAngleBetween;
  95004. }
  95005. }
  95006. declare module BABYLON {
  95007. /**
  95008. * Manage the gamepad inputs to control an arc rotate camera.
  95009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95010. */
  95011. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95012. /**
  95013. * Defines the camera the input is attached to.
  95014. */
  95015. camera: ArcRotateCamera;
  95016. /**
  95017. * Defines the gamepad the input is gathering event from.
  95018. */
  95019. gamepad: Nullable<Gamepad>;
  95020. /**
  95021. * Defines the gamepad rotation sensiblity.
  95022. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95023. */
  95024. gamepadRotationSensibility: number;
  95025. /**
  95026. * Defines the gamepad move sensiblity.
  95027. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95028. */
  95029. gamepadMoveSensibility: number;
  95030. private _onGamepadConnectedObserver;
  95031. private _onGamepadDisconnectedObserver;
  95032. /**
  95033. * Attach the input controls to a specific dom element to get the input from.
  95034. * @param element Defines the element the controls should be listened from
  95035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95036. */
  95037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95038. /**
  95039. * Detach the current controls from the specified dom element.
  95040. * @param element Defines the element to stop listening the inputs from
  95041. */
  95042. detachControl(element: Nullable<HTMLElement>): void;
  95043. /**
  95044. * Update the current camera state depending on the inputs that have been used this frame.
  95045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95046. */
  95047. checkInputs(): void;
  95048. /**
  95049. * Gets the class name of the current intput.
  95050. * @returns the class name
  95051. */
  95052. getClassName(): string;
  95053. /**
  95054. * Get the friendly name associated with the input class.
  95055. * @returns the input friendly name
  95056. */
  95057. getSimpleName(): string;
  95058. }
  95059. }
  95060. declare module BABYLON {
  95061. interface ArcRotateCameraInputsManager {
  95062. /**
  95063. * Add orientation input support to the input manager.
  95064. * @returns the current input manager
  95065. */
  95066. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95067. }
  95068. /**
  95069. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95071. */
  95072. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95073. /**
  95074. * Defines the camera the input is attached to.
  95075. */
  95076. camera: ArcRotateCamera;
  95077. /**
  95078. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95079. */
  95080. alphaCorrection: number;
  95081. /**
  95082. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95083. */
  95084. gammaCorrection: number;
  95085. private _alpha;
  95086. private _gamma;
  95087. private _dirty;
  95088. private _deviceOrientationHandler;
  95089. /**
  95090. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95091. */
  95092. constructor();
  95093. /**
  95094. * Attach the input controls to a specific dom element to get the input from.
  95095. * @param element Defines the element the controls should be listened from
  95096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95097. */
  95098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95099. /** @hidden */
  95100. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95101. /**
  95102. * Update the current camera state depending on the inputs that have been used this frame.
  95103. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95104. */
  95105. checkInputs(): void;
  95106. /**
  95107. * Detach the current controls from the specified dom element.
  95108. * @param element Defines the element to stop listening the inputs from
  95109. */
  95110. detachControl(element: Nullable<HTMLElement>): void;
  95111. /**
  95112. * Gets the class name of the current intput.
  95113. * @returns the class name
  95114. */
  95115. getClassName(): string;
  95116. /**
  95117. * Get the friendly name associated with the input class.
  95118. * @returns the input friendly name
  95119. */
  95120. getSimpleName(): string;
  95121. }
  95122. }
  95123. declare module BABYLON {
  95124. /**
  95125. * Listen to mouse events to control the camera.
  95126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95127. */
  95128. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95129. /**
  95130. * Defines the camera the input is attached to.
  95131. */
  95132. camera: FlyCamera;
  95133. /**
  95134. * Defines if touch is enabled. (Default is true.)
  95135. */
  95136. touchEnabled: boolean;
  95137. /**
  95138. * Defines the buttons associated with the input to handle camera rotation.
  95139. */
  95140. buttons: number[];
  95141. /**
  95142. * Assign buttons for Yaw control.
  95143. */
  95144. buttonsYaw: number[];
  95145. /**
  95146. * Assign buttons for Pitch control.
  95147. */
  95148. buttonsPitch: number[];
  95149. /**
  95150. * Assign buttons for Roll control.
  95151. */
  95152. buttonsRoll: number[];
  95153. /**
  95154. * Detect if any button is being pressed while mouse is moved.
  95155. * -1 = Mouse locked.
  95156. * 0 = Left button.
  95157. * 1 = Middle Button.
  95158. * 2 = Right Button.
  95159. */
  95160. activeButton: number;
  95161. /**
  95162. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95163. * Higher values reduce its sensitivity.
  95164. */
  95165. angularSensibility: number;
  95166. private _mousemoveCallback;
  95167. private _observer;
  95168. private _rollObserver;
  95169. private previousPosition;
  95170. private noPreventDefault;
  95171. private element;
  95172. /**
  95173. * Listen to mouse events to control the camera.
  95174. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95176. */
  95177. constructor(touchEnabled?: boolean);
  95178. /**
  95179. * Attach the mouse control to the HTML DOM element.
  95180. * @param element Defines the element that listens to the input events.
  95181. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95182. */
  95183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95184. /**
  95185. * Detach the current controls from the specified dom element.
  95186. * @param element Defines the element to stop listening the inputs from
  95187. */
  95188. detachControl(element: Nullable<HTMLElement>): void;
  95189. /**
  95190. * Gets the class name of the current input.
  95191. * @returns the class name.
  95192. */
  95193. getClassName(): string;
  95194. /**
  95195. * Get the friendly name associated with the input class.
  95196. * @returns the input's friendly name.
  95197. */
  95198. getSimpleName(): string;
  95199. private _pointerInput;
  95200. private _onMouseMove;
  95201. /**
  95202. * Rotate camera by mouse offset.
  95203. */
  95204. private rotateCamera;
  95205. }
  95206. }
  95207. declare module BABYLON {
  95208. /**
  95209. * Default Inputs manager for the FlyCamera.
  95210. * It groups all the default supported inputs for ease of use.
  95211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95212. */
  95213. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95214. /**
  95215. * Instantiates a new FlyCameraInputsManager.
  95216. * @param camera Defines the camera the inputs belong to.
  95217. */
  95218. constructor(camera: FlyCamera);
  95219. /**
  95220. * Add keyboard input support to the input manager.
  95221. * @returns the new FlyCameraKeyboardMoveInput().
  95222. */
  95223. addKeyboard(): FlyCameraInputsManager;
  95224. /**
  95225. * Add mouse input support to the input manager.
  95226. * @param touchEnabled Enable touch screen support.
  95227. * @returns the new FlyCameraMouseInput().
  95228. */
  95229. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95230. }
  95231. }
  95232. declare module BABYLON {
  95233. /**
  95234. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95235. * such as in a 3D Space Shooter or a Flight Simulator.
  95236. */
  95237. export class FlyCamera extends TargetCamera {
  95238. /**
  95239. * Define the collision ellipsoid of the camera.
  95240. * This is helpful for simulating a camera body, like a player's body.
  95241. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95242. */
  95243. ellipsoid: Vector3;
  95244. /**
  95245. * Define an offset for the position of the ellipsoid around the camera.
  95246. * This can be helpful if the camera is attached away from the player's body center,
  95247. * such as at its head.
  95248. */
  95249. ellipsoidOffset: Vector3;
  95250. /**
  95251. * Enable or disable collisions of the camera with the rest of the scene objects.
  95252. */
  95253. checkCollisions: boolean;
  95254. /**
  95255. * Enable or disable gravity on the camera.
  95256. */
  95257. applyGravity: boolean;
  95258. /**
  95259. * Define the current direction the camera is moving to.
  95260. */
  95261. cameraDirection: Vector3;
  95262. /**
  95263. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95264. * This overrides and empties cameraRotation.
  95265. */
  95266. rotationQuaternion: Quaternion;
  95267. /**
  95268. * Track Roll to maintain the wanted Rolling when looking around.
  95269. */
  95270. _trackRoll: number;
  95271. /**
  95272. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95273. */
  95274. rollCorrect: number;
  95275. /**
  95276. * Mimic a banked turn, Rolling the camera when Yawing.
  95277. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95278. */
  95279. bankedTurn: boolean;
  95280. /**
  95281. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95282. */
  95283. bankedTurnLimit: number;
  95284. /**
  95285. * Value of 0 disables the banked Roll.
  95286. * Value of 1 is equal to the Yaw angle in radians.
  95287. */
  95288. bankedTurnMultiplier: number;
  95289. /**
  95290. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95291. */
  95292. inputs: FlyCameraInputsManager;
  95293. /**
  95294. * Gets the input sensibility for mouse input.
  95295. * Higher values reduce sensitivity.
  95296. */
  95297. /**
  95298. * Sets the input sensibility for a mouse input.
  95299. * Higher values reduce sensitivity.
  95300. */
  95301. angularSensibility: number;
  95302. /**
  95303. * Get the keys for camera movement forward.
  95304. */
  95305. /**
  95306. * Set the keys for camera movement forward.
  95307. */
  95308. keysForward: number[];
  95309. /**
  95310. * Get the keys for camera movement backward.
  95311. */
  95312. keysBackward: number[];
  95313. /**
  95314. * Get the keys for camera movement up.
  95315. */
  95316. /**
  95317. * Set the keys for camera movement up.
  95318. */
  95319. keysUp: number[];
  95320. /**
  95321. * Get the keys for camera movement down.
  95322. */
  95323. /**
  95324. * Set the keys for camera movement down.
  95325. */
  95326. keysDown: number[];
  95327. /**
  95328. * Get the keys for camera movement left.
  95329. */
  95330. /**
  95331. * Set the keys for camera movement left.
  95332. */
  95333. keysLeft: number[];
  95334. /**
  95335. * Set the keys for camera movement right.
  95336. */
  95337. /**
  95338. * Set the keys for camera movement right.
  95339. */
  95340. keysRight: number[];
  95341. /**
  95342. * Event raised when the camera collides with a mesh in the scene.
  95343. */
  95344. onCollide: (collidedMesh: AbstractMesh) => void;
  95345. private _collider;
  95346. private _needMoveForGravity;
  95347. private _oldPosition;
  95348. private _diffPosition;
  95349. private _newPosition;
  95350. /** @hidden */
  95351. _localDirection: Vector3;
  95352. /** @hidden */
  95353. _transformedDirection: Vector3;
  95354. /**
  95355. * Instantiates a FlyCamera.
  95356. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95357. * such as in a 3D Space Shooter or a Flight Simulator.
  95358. * @param name Define the name of the camera in the scene.
  95359. * @param position Define the starting position of the camera in the scene.
  95360. * @param scene Define the scene the camera belongs to.
  95361. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95362. */
  95363. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95364. /**
  95365. * Attach a control to the HTML DOM element.
  95366. * @param element Defines the element that listens to the input events.
  95367. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95368. */
  95369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95370. /**
  95371. * Detach a control from the HTML DOM element.
  95372. * The camera will stop reacting to that input.
  95373. * @param element Defines the element that listens to the input events.
  95374. */
  95375. detachControl(element: HTMLElement): void;
  95376. private _collisionMask;
  95377. /**
  95378. * Get the mask that the camera ignores in collision events.
  95379. */
  95380. /**
  95381. * Set the mask that the camera ignores in collision events.
  95382. */
  95383. collisionMask: number;
  95384. /** @hidden */
  95385. _collideWithWorld(displacement: Vector3): void;
  95386. /** @hidden */
  95387. private _onCollisionPositionChange;
  95388. /** @hidden */
  95389. _checkInputs(): void;
  95390. /** @hidden */
  95391. _decideIfNeedsToMove(): boolean;
  95392. /** @hidden */
  95393. _updatePosition(): void;
  95394. /**
  95395. * Restore the Roll to its target value at the rate specified.
  95396. * @param rate - Higher means slower restoring.
  95397. * @hidden
  95398. */
  95399. restoreRoll(rate: number): void;
  95400. /**
  95401. * Destroy the camera and release the current resources held by it.
  95402. */
  95403. dispose(): void;
  95404. /**
  95405. * Get the current object class name.
  95406. * @returns the class name.
  95407. */
  95408. getClassName(): string;
  95409. }
  95410. }
  95411. declare module BABYLON {
  95412. /**
  95413. * Listen to keyboard events to control the camera.
  95414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95415. */
  95416. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95417. /**
  95418. * Defines the camera the input is attached to.
  95419. */
  95420. camera: FlyCamera;
  95421. /**
  95422. * The list of keyboard keys used to control the forward move of the camera.
  95423. */
  95424. keysForward: number[];
  95425. /**
  95426. * The list of keyboard keys used to control the backward move of the camera.
  95427. */
  95428. keysBackward: number[];
  95429. /**
  95430. * The list of keyboard keys used to control the forward move of the camera.
  95431. */
  95432. keysUp: number[];
  95433. /**
  95434. * The list of keyboard keys used to control the backward move of the camera.
  95435. */
  95436. keysDown: number[];
  95437. /**
  95438. * The list of keyboard keys used to control the right strafe move of the camera.
  95439. */
  95440. keysRight: number[];
  95441. /**
  95442. * The list of keyboard keys used to control the left strafe move of the camera.
  95443. */
  95444. keysLeft: number[];
  95445. private _keys;
  95446. private _onCanvasBlurObserver;
  95447. private _onKeyboardObserver;
  95448. private _engine;
  95449. private _scene;
  95450. /**
  95451. * Attach the input controls to a specific dom element to get the input from.
  95452. * @param element Defines the element the controls should be listened from
  95453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95454. */
  95455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95456. /**
  95457. * Detach the current controls from the specified dom element.
  95458. * @param element Defines the element to stop listening the inputs from
  95459. */
  95460. detachControl(element: Nullable<HTMLElement>): void;
  95461. /**
  95462. * Gets the class name of the current intput.
  95463. * @returns the class name
  95464. */
  95465. getClassName(): string;
  95466. /** @hidden */
  95467. _onLostFocus(e: FocusEvent): void;
  95468. /**
  95469. * Get the friendly name associated with the input class.
  95470. * @returns the input friendly name
  95471. */
  95472. getSimpleName(): string;
  95473. /**
  95474. * Update the current camera state depending on the inputs that have been used this frame.
  95475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95476. */
  95477. checkInputs(): void;
  95478. }
  95479. }
  95480. declare module BABYLON {
  95481. /**
  95482. * Manage the mouse wheel inputs to control a follow camera.
  95483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95484. */
  95485. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95486. /**
  95487. * Defines the camera the input is attached to.
  95488. */
  95489. camera: FollowCamera;
  95490. /**
  95491. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95492. */
  95493. axisControlRadius: boolean;
  95494. /**
  95495. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95496. */
  95497. axisControlHeight: boolean;
  95498. /**
  95499. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95500. */
  95501. axisControlRotation: boolean;
  95502. /**
  95503. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95504. * relation to mouseWheel events.
  95505. */
  95506. wheelPrecision: number;
  95507. /**
  95508. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95509. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95510. */
  95511. wheelDeltaPercentage: number;
  95512. private _wheel;
  95513. private _observer;
  95514. /**
  95515. * Attach the input controls to a specific dom element to get the input from.
  95516. * @param element Defines the element the controls should be listened from
  95517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95518. */
  95519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95520. /**
  95521. * Detach the current controls from the specified dom element.
  95522. * @param element Defines the element to stop listening the inputs from
  95523. */
  95524. detachControl(element: Nullable<HTMLElement>): void;
  95525. /**
  95526. * Gets the class name of the current intput.
  95527. * @returns the class name
  95528. */
  95529. getClassName(): string;
  95530. /**
  95531. * Get the friendly name associated with the input class.
  95532. * @returns the input friendly name
  95533. */
  95534. getSimpleName(): string;
  95535. }
  95536. }
  95537. declare module BABYLON {
  95538. /**
  95539. * Manage the pointers inputs to control an follow camera.
  95540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95541. */
  95542. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95543. /**
  95544. * Defines the camera the input is attached to.
  95545. */
  95546. camera: FollowCamera;
  95547. /**
  95548. * Gets the class name of the current input.
  95549. * @returns the class name
  95550. */
  95551. getClassName(): string;
  95552. /**
  95553. * Defines the pointer angular sensibility along the X axis or how fast is
  95554. * the camera rotating.
  95555. * A negative number will reverse the axis direction.
  95556. */
  95557. angularSensibilityX: number;
  95558. /**
  95559. * Defines the pointer angular sensibility along the Y axis or how fast is
  95560. * the camera rotating.
  95561. * A negative number will reverse the axis direction.
  95562. */
  95563. angularSensibilityY: number;
  95564. /**
  95565. * Defines the pointer pinch precision or how fast is the camera zooming.
  95566. * A negative number will reverse the axis direction.
  95567. */
  95568. pinchPrecision: number;
  95569. /**
  95570. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95571. * from 0.
  95572. * It defines the percentage of current camera.radius to use as delta when
  95573. * pinch zoom is used.
  95574. */
  95575. pinchDeltaPercentage: number;
  95576. /**
  95577. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95578. */
  95579. axisXControlRadius: boolean;
  95580. /**
  95581. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95582. */
  95583. axisXControlHeight: boolean;
  95584. /**
  95585. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95586. */
  95587. axisXControlRotation: boolean;
  95588. /**
  95589. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95590. */
  95591. axisYControlRadius: boolean;
  95592. /**
  95593. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95594. */
  95595. axisYControlHeight: boolean;
  95596. /**
  95597. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95598. */
  95599. axisYControlRotation: boolean;
  95600. /**
  95601. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95602. */
  95603. axisPinchControlRadius: boolean;
  95604. /**
  95605. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95606. */
  95607. axisPinchControlHeight: boolean;
  95608. /**
  95609. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95610. */
  95611. axisPinchControlRotation: boolean;
  95612. /**
  95613. * Log error messages if basic misconfiguration has occurred.
  95614. */
  95615. warningEnable: boolean;
  95616. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95617. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95618. private _warningCounter;
  95619. private _warning;
  95620. }
  95621. }
  95622. declare module BABYLON {
  95623. /**
  95624. * Default Inputs manager for the FollowCamera.
  95625. * It groups all the default supported inputs for ease of use.
  95626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95627. */
  95628. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95629. /**
  95630. * Instantiates a new FollowCameraInputsManager.
  95631. * @param camera Defines the camera the inputs belong to
  95632. */
  95633. constructor(camera: FollowCamera);
  95634. /**
  95635. * Add keyboard input support to the input manager.
  95636. * @returns the current input manager
  95637. */
  95638. addKeyboard(): FollowCameraInputsManager;
  95639. /**
  95640. * Add mouse wheel input support to the input manager.
  95641. * @returns the current input manager
  95642. */
  95643. addMouseWheel(): FollowCameraInputsManager;
  95644. /**
  95645. * Add pointers input support to the input manager.
  95646. * @returns the current input manager
  95647. */
  95648. addPointers(): FollowCameraInputsManager;
  95649. /**
  95650. * Add orientation input support to the input manager.
  95651. * @returns the current input manager
  95652. */
  95653. addVRDeviceOrientation(): FollowCameraInputsManager;
  95654. }
  95655. }
  95656. declare module BABYLON {
  95657. /**
  95658. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95659. * an arc rotate version arcFollowCamera are available.
  95660. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95661. */
  95662. export class FollowCamera extends TargetCamera {
  95663. /**
  95664. * Distance the follow camera should follow an object at
  95665. */
  95666. radius: number;
  95667. /**
  95668. * Minimum allowed distance of the camera to the axis of rotation
  95669. * (The camera can not get closer).
  95670. * This can help limiting how the Camera is able to move in the scene.
  95671. */
  95672. lowerRadiusLimit: Nullable<number>;
  95673. /**
  95674. * Maximum allowed distance of the camera to the axis of rotation
  95675. * (The camera can not get further).
  95676. * This can help limiting how the Camera is able to move in the scene.
  95677. */
  95678. upperRadiusLimit: Nullable<number>;
  95679. /**
  95680. * Define a rotation offset between the camera and the object it follows
  95681. */
  95682. rotationOffset: number;
  95683. /**
  95684. * Minimum allowed angle to camera position relative to target object.
  95685. * This can help limiting how the Camera is able to move in the scene.
  95686. */
  95687. lowerRotationOffsetLimit: Nullable<number>;
  95688. /**
  95689. * Maximum allowed angle to camera position relative to target object.
  95690. * This can help limiting how the Camera is able to move in the scene.
  95691. */
  95692. upperRotationOffsetLimit: Nullable<number>;
  95693. /**
  95694. * Define a height offset between the camera and the object it follows.
  95695. * It can help following an object from the top (like a car chaing a plane)
  95696. */
  95697. heightOffset: number;
  95698. /**
  95699. * Minimum allowed height of camera position relative to target object.
  95700. * This can help limiting how the Camera is able to move in the scene.
  95701. */
  95702. lowerHeightOffsetLimit: Nullable<number>;
  95703. /**
  95704. * Maximum allowed height of camera position relative to target object.
  95705. * This can help limiting how the Camera is able to move in the scene.
  95706. */
  95707. upperHeightOffsetLimit: Nullable<number>;
  95708. /**
  95709. * Define how fast the camera can accelerate to follow it s target.
  95710. */
  95711. cameraAcceleration: number;
  95712. /**
  95713. * Define the speed limit of the camera following an object.
  95714. */
  95715. maxCameraSpeed: number;
  95716. /**
  95717. * Define the target of the camera.
  95718. */
  95719. lockedTarget: Nullable<AbstractMesh>;
  95720. /**
  95721. * Defines the input associated with the camera.
  95722. */
  95723. inputs: FollowCameraInputsManager;
  95724. /**
  95725. * Instantiates the follow camera.
  95726. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95727. * @param name Define the name of the camera in the scene
  95728. * @param position Define the position of the camera
  95729. * @param scene Define the scene the camera belong to
  95730. * @param lockedTarget Define the target of the camera
  95731. */
  95732. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95733. private _follow;
  95734. /**
  95735. * Attached controls to the current camera.
  95736. * @param element Defines the element the controls should be listened from
  95737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95738. */
  95739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95740. /**
  95741. * Detach the current controls from the camera.
  95742. * The camera will stop reacting to inputs.
  95743. * @param element Defines the element to stop listening the inputs from
  95744. */
  95745. detachControl(element: HTMLElement): void;
  95746. /** @hidden */
  95747. _checkInputs(): void;
  95748. private _checkLimits;
  95749. /**
  95750. * Gets the camera class name.
  95751. * @returns the class name
  95752. */
  95753. getClassName(): string;
  95754. }
  95755. /**
  95756. * Arc Rotate version of the follow camera.
  95757. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  95758. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95759. */
  95760. export class ArcFollowCamera extends TargetCamera {
  95761. /** The longitudinal angle of the camera */
  95762. alpha: number;
  95763. /** The latitudinal angle of the camera */
  95764. beta: number;
  95765. /** The radius of the camera from its target */
  95766. radius: number;
  95767. /** Define the camera target (the messh it should follow) */
  95768. target: Nullable<AbstractMesh>;
  95769. private _cartesianCoordinates;
  95770. /**
  95771. * Instantiates a new ArcFollowCamera
  95772. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95773. * @param name Define the name of the camera
  95774. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  95775. * @param beta Define the rotation angle of the camera around the elevation axis
  95776. * @param radius Define the radius of the camera from its target point
  95777. * @param target Define the target of the camera
  95778. * @param scene Define the scene the camera belongs to
  95779. */
  95780. constructor(name: string,
  95781. /** The longitudinal angle of the camera */
  95782. alpha: number,
  95783. /** The latitudinal angle of the camera */
  95784. beta: number,
  95785. /** The radius of the camera from its target */
  95786. radius: number,
  95787. /** Define the camera target (the messh it should follow) */
  95788. target: Nullable<AbstractMesh>, scene: Scene);
  95789. private _follow;
  95790. /** @hidden */
  95791. _checkInputs(): void;
  95792. /**
  95793. * Returns the class name of the object.
  95794. * It is mostly used internally for serialization purposes.
  95795. */
  95796. getClassName(): string;
  95797. }
  95798. }
  95799. declare module BABYLON {
  95800. /**
  95801. * Manage the keyboard inputs to control the movement of a follow camera.
  95802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95803. */
  95804. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95805. /**
  95806. * Defines the camera the input is attached to.
  95807. */
  95808. camera: FollowCamera;
  95809. /**
  95810. * Defines the list of key codes associated with the up action (increase heightOffset)
  95811. */
  95812. keysHeightOffsetIncr: number[];
  95813. /**
  95814. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95815. */
  95816. keysHeightOffsetDecr: number[];
  95817. /**
  95818. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95819. */
  95820. keysHeightOffsetModifierAlt: boolean;
  95821. /**
  95822. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95823. */
  95824. keysHeightOffsetModifierCtrl: boolean;
  95825. /**
  95826. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95827. */
  95828. keysHeightOffsetModifierShift: boolean;
  95829. /**
  95830. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95831. */
  95832. keysRotationOffsetIncr: number[];
  95833. /**
  95834. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95835. */
  95836. keysRotationOffsetDecr: number[];
  95837. /**
  95838. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95839. */
  95840. keysRotationOffsetModifierAlt: boolean;
  95841. /**
  95842. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95843. */
  95844. keysRotationOffsetModifierCtrl: boolean;
  95845. /**
  95846. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95847. */
  95848. keysRotationOffsetModifierShift: boolean;
  95849. /**
  95850. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95851. */
  95852. keysRadiusIncr: number[];
  95853. /**
  95854. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95855. */
  95856. keysRadiusDecr: number[];
  95857. /**
  95858. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95859. */
  95860. keysRadiusModifierAlt: boolean;
  95861. /**
  95862. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95863. */
  95864. keysRadiusModifierCtrl: boolean;
  95865. /**
  95866. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95867. */
  95868. keysRadiusModifierShift: boolean;
  95869. /**
  95870. * Defines the rate of change of heightOffset.
  95871. */
  95872. heightSensibility: number;
  95873. /**
  95874. * Defines the rate of change of rotationOffset.
  95875. */
  95876. rotationSensibility: number;
  95877. /**
  95878. * Defines the rate of change of radius.
  95879. */
  95880. radiusSensibility: number;
  95881. private _keys;
  95882. private _ctrlPressed;
  95883. private _altPressed;
  95884. private _shiftPressed;
  95885. private _onCanvasBlurObserver;
  95886. private _onKeyboardObserver;
  95887. private _engine;
  95888. private _scene;
  95889. /**
  95890. * Attach the input controls to a specific dom element to get the input from.
  95891. * @param element Defines the element the controls should be listened from
  95892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95893. */
  95894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95895. /**
  95896. * Detach the current controls from the specified dom element.
  95897. * @param element Defines the element to stop listening the inputs from
  95898. */
  95899. detachControl(element: Nullable<HTMLElement>): void;
  95900. /**
  95901. * Update the current camera state depending on the inputs that have been used this frame.
  95902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95903. */
  95904. checkInputs(): void;
  95905. /**
  95906. * Gets the class name of the current input.
  95907. * @returns the class name
  95908. */
  95909. getClassName(): string;
  95910. /**
  95911. * Get the friendly name associated with the input class.
  95912. * @returns the input friendly name
  95913. */
  95914. getSimpleName(): string;
  95915. /**
  95916. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95917. * allow modification of the heightOffset value.
  95918. */
  95919. private _modifierHeightOffset;
  95920. /**
  95921. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95922. * allow modification of the rotationOffset value.
  95923. */
  95924. private _modifierRotationOffset;
  95925. /**
  95926. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95927. * allow modification of the radius value.
  95928. */
  95929. private _modifierRadius;
  95930. }
  95931. }
  95932. declare module BABYLON {
  95933. interface FreeCameraInputsManager {
  95934. /**
  95935. * @hidden
  95936. */
  95937. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  95938. /**
  95939. * Add orientation input support to the input manager.
  95940. * @returns the current input manager
  95941. */
  95942. addDeviceOrientation(): FreeCameraInputsManager;
  95943. }
  95944. /**
  95945. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95946. * Screen rotation is taken into account.
  95947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95948. */
  95949. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95950. private _camera;
  95951. private _screenOrientationAngle;
  95952. private _constantTranform;
  95953. private _screenQuaternion;
  95954. private _alpha;
  95955. private _beta;
  95956. private _gamma;
  95957. /**
  95958. * @hidden
  95959. */
  95960. _onDeviceOrientationChangedObservable: Observable<void>;
  95961. /**
  95962. * Instantiates a new input
  95963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95964. */
  95965. constructor();
  95966. /**
  95967. * Define the camera controlled by the input.
  95968. */
  95969. camera: FreeCamera;
  95970. /**
  95971. * Attach the input controls to a specific dom element to get the input from.
  95972. * @param element Defines the element the controls should be listened from
  95973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95974. */
  95975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95976. private _orientationChanged;
  95977. private _deviceOrientation;
  95978. /**
  95979. * Detach the current controls from the specified dom element.
  95980. * @param element Defines the element to stop listening the inputs from
  95981. */
  95982. detachControl(element: Nullable<HTMLElement>): void;
  95983. /**
  95984. * Update the current camera state depending on the inputs that have been used this frame.
  95985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95986. */
  95987. checkInputs(): void;
  95988. /**
  95989. * Gets the class name of the current intput.
  95990. * @returns the class name
  95991. */
  95992. getClassName(): string;
  95993. /**
  95994. * Get the friendly name associated with the input class.
  95995. * @returns the input friendly name
  95996. */
  95997. getSimpleName(): string;
  95998. }
  95999. }
  96000. declare module BABYLON {
  96001. /**
  96002. * Manage the gamepad inputs to control a free camera.
  96003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96004. */
  96005. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96006. /**
  96007. * Define the camera the input is attached to.
  96008. */
  96009. camera: FreeCamera;
  96010. /**
  96011. * Define the Gamepad controlling the input
  96012. */
  96013. gamepad: Nullable<Gamepad>;
  96014. /**
  96015. * Defines the gamepad rotation sensiblity.
  96016. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96017. */
  96018. gamepadAngularSensibility: number;
  96019. /**
  96020. * Defines the gamepad move sensiblity.
  96021. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96022. */
  96023. gamepadMoveSensibility: number;
  96024. private _onGamepadConnectedObserver;
  96025. private _onGamepadDisconnectedObserver;
  96026. private _cameraTransform;
  96027. private _deltaTransform;
  96028. private _vector3;
  96029. private _vector2;
  96030. /**
  96031. * Attach the input controls to a specific dom element to get the input from.
  96032. * @param element Defines the element the controls should be listened from
  96033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96034. */
  96035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96036. /**
  96037. * Detach the current controls from the specified dom element.
  96038. * @param element Defines the element to stop listening the inputs from
  96039. */
  96040. detachControl(element: Nullable<HTMLElement>): void;
  96041. /**
  96042. * Update the current camera state depending on the inputs that have been used this frame.
  96043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96044. */
  96045. checkInputs(): void;
  96046. /**
  96047. * Gets the class name of the current intput.
  96048. * @returns the class name
  96049. */
  96050. getClassName(): string;
  96051. /**
  96052. * Get the friendly name associated with the input class.
  96053. * @returns the input friendly name
  96054. */
  96055. getSimpleName(): string;
  96056. }
  96057. }
  96058. declare module BABYLON {
  96059. /**
  96060. * Defines the potential axis of a Joystick
  96061. */
  96062. export enum JoystickAxis {
  96063. /** X axis */
  96064. X = 0,
  96065. /** Y axis */
  96066. Y = 1,
  96067. /** Z axis */
  96068. Z = 2
  96069. }
  96070. /**
  96071. * Class used to define virtual joystick (used in touch mode)
  96072. */
  96073. export class VirtualJoystick {
  96074. /**
  96075. * Gets or sets a boolean indicating that left and right values must be inverted
  96076. */
  96077. reverseLeftRight: boolean;
  96078. /**
  96079. * Gets or sets a boolean indicating that up and down values must be inverted
  96080. */
  96081. reverseUpDown: boolean;
  96082. /**
  96083. * Gets the offset value for the position (ie. the change of the position value)
  96084. */
  96085. deltaPosition: Vector3;
  96086. /**
  96087. * Gets a boolean indicating if the virtual joystick was pressed
  96088. */
  96089. pressed: boolean;
  96090. /**
  96091. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96092. */
  96093. static Canvas: Nullable<HTMLCanvasElement>;
  96094. private static _globalJoystickIndex;
  96095. private static vjCanvasContext;
  96096. private static vjCanvasWidth;
  96097. private static vjCanvasHeight;
  96098. private static halfWidth;
  96099. private _action;
  96100. private _axisTargetedByLeftAndRight;
  96101. private _axisTargetedByUpAndDown;
  96102. private _joystickSensibility;
  96103. private _inversedSensibility;
  96104. private _joystickPointerID;
  96105. private _joystickColor;
  96106. private _joystickPointerPos;
  96107. private _joystickPreviousPointerPos;
  96108. private _joystickPointerStartPos;
  96109. private _deltaJoystickVector;
  96110. private _leftJoystick;
  96111. private _touches;
  96112. private _onPointerDownHandlerRef;
  96113. private _onPointerMoveHandlerRef;
  96114. private _onPointerUpHandlerRef;
  96115. private _onResize;
  96116. /**
  96117. * Creates a new virtual joystick
  96118. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96119. */
  96120. constructor(leftJoystick?: boolean);
  96121. /**
  96122. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96123. * @param newJoystickSensibility defines the new sensibility
  96124. */
  96125. setJoystickSensibility(newJoystickSensibility: number): void;
  96126. private _onPointerDown;
  96127. private _onPointerMove;
  96128. private _onPointerUp;
  96129. /**
  96130. * Change the color of the virtual joystick
  96131. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96132. */
  96133. setJoystickColor(newColor: string): void;
  96134. /**
  96135. * Defines a callback to call when the joystick is touched
  96136. * @param action defines the callback
  96137. */
  96138. setActionOnTouch(action: () => any): void;
  96139. /**
  96140. * Defines which axis you'd like to control for left & right
  96141. * @param axis defines the axis to use
  96142. */
  96143. setAxisForLeftRight(axis: JoystickAxis): void;
  96144. /**
  96145. * Defines which axis you'd like to control for up & down
  96146. * @param axis defines the axis to use
  96147. */
  96148. setAxisForUpDown(axis: JoystickAxis): void;
  96149. private _drawVirtualJoystick;
  96150. /**
  96151. * Release internal HTML canvas
  96152. */
  96153. releaseCanvas(): void;
  96154. }
  96155. }
  96156. declare module BABYLON {
  96157. interface FreeCameraInputsManager {
  96158. /**
  96159. * Add virtual joystick input support to the input manager.
  96160. * @returns the current input manager
  96161. */
  96162. addVirtualJoystick(): FreeCameraInputsManager;
  96163. }
  96164. /**
  96165. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96167. */
  96168. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96169. /**
  96170. * Defines the camera the input is attached to.
  96171. */
  96172. camera: FreeCamera;
  96173. private _leftjoystick;
  96174. private _rightjoystick;
  96175. /**
  96176. * Gets the left stick of the virtual joystick.
  96177. * @returns The virtual Joystick
  96178. */
  96179. getLeftJoystick(): VirtualJoystick;
  96180. /**
  96181. * Gets the right stick of the virtual joystick.
  96182. * @returns The virtual Joystick
  96183. */
  96184. getRightJoystick(): VirtualJoystick;
  96185. /**
  96186. * Update the current camera state depending on the inputs that have been used this frame.
  96187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96188. */
  96189. checkInputs(): void;
  96190. /**
  96191. * Attach the input controls to a specific dom element to get the input from.
  96192. * @param element Defines the element the controls should be listened from
  96193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96194. */
  96195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96196. /**
  96197. * Detach the current controls from the specified dom element.
  96198. * @param element Defines the element to stop listening the inputs from
  96199. */
  96200. detachControl(element: Nullable<HTMLElement>): void;
  96201. /**
  96202. * Gets the class name of the current intput.
  96203. * @returns the class name
  96204. */
  96205. getClassName(): string;
  96206. /**
  96207. * Get the friendly name associated with the input class.
  96208. * @returns the input friendly name
  96209. */
  96210. getSimpleName(): string;
  96211. }
  96212. }
  96213. declare module BABYLON {
  96214. /**
  96215. * This represents a FPS type of camera controlled by touch.
  96216. * This is like a universal camera minus the Gamepad controls.
  96217. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96218. */
  96219. export class TouchCamera extends FreeCamera {
  96220. /**
  96221. * Defines the touch sensibility for rotation.
  96222. * The higher the faster.
  96223. */
  96224. touchAngularSensibility: number;
  96225. /**
  96226. * Defines the touch sensibility for move.
  96227. * The higher the faster.
  96228. */
  96229. touchMoveSensibility: number;
  96230. /**
  96231. * Instantiates a new touch camera.
  96232. * This represents a FPS type of camera controlled by touch.
  96233. * This is like a universal camera minus the Gamepad controls.
  96234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96235. * @param name Define the name of the camera in the scene
  96236. * @param position Define the start position of the camera in the scene
  96237. * @param scene Define the scene the camera belongs to
  96238. */
  96239. constructor(name: string, position: Vector3, scene: Scene);
  96240. /**
  96241. * Gets the current object class name.
  96242. * @return the class name
  96243. */
  96244. getClassName(): string;
  96245. /** @hidden */
  96246. _setupInputs(): void;
  96247. }
  96248. }
  96249. declare module BABYLON {
  96250. /**
  96251. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96252. * being tilted forward or back and left or right.
  96253. */
  96254. export class DeviceOrientationCamera extends FreeCamera {
  96255. private _initialQuaternion;
  96256. private _quaternionCache;
  96257. private _tmpDragQuaternion;
  96258. /**
  96259. * Creates a new device orientation camera
  96260. * @param name The name of the camera
  96261. * @param position The start position camera
  96262. * @param scene The scene the camera belongs to
  96263. */
  96264. constructor(name: string, position: Vector3, scene: Scene);
  96265. /**
  96266. * Disabled pointer input on first orientation sensor update (Default: true)
  96267. */
  96268. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96269. private _dragFactor;
  96270. /**
  96271. * Enabled turning on the y axis when the orientation sensor is active
  96272. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96273. */
  96274. enableHorizontalDragging(dragFactor?: number): void;
  96275. /**
  96276. * Gets the current instance class name ("DeviceOrientationCamera").
  96277. * This helps avoiding instanceof at run time.
  96278. * @returns the class name
  96279. */
  96280. getClassName(): string;
  96281. /**
  96282. * @hidden
  96283. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96284. */
  96285. _checkInputs(): void;
  96286. /**
  96287. * Reset the camera to its default orientation on the specified axis only.
  96288. * @param axis The axis to reset
  96289. */
  96290. resetToCurrentRotation(axis?: Axis): void;
  96291. }
  96292. }
  96293. declare module BABYLON {
  96294. /**
  96295. * 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,
  96296. * which still works and will still be found in many Playgrounds.
  96297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96298. */
  96299. export class UniversalCamera extends TouchCamera {
  96300. /**
  96301. * Defines the gamepad rotation sensiblity.
  96302. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96303. */
  96304. gamepadAngularSensibility: number;
  96305. /**
  96306. * Defines the gamepad move sensiblity.
  96307. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96308. */
  96309. gamepadMoveSensibility: number;
  96310. /**
  96311. * 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,
  96312. * which still works and will still be found in many Playgrounds.
  96313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96314. * @param name Define the name of the camera in the scene
  96315. * @param position Define the start position of the camera in the scene
  96316. * @param scene Define the scene the camera belongs to
  96317. */
  96318. constructor(name: string, position: Vector3, scene: Scene);
  96319. /**
  96320. * Gets the current object class name.
  96321. * @return the class name
  96322. */
  96323. getClassName(): string;
  96324. }
  96325. }
  96326. declare module BABYLON {
  96327. /**
  96328. * This represents a FPS type of camera. This is only here for back compat purpose.
  96329. * Please use the UniversalCamera instead as both are identical.
  96330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96331. */
  96332. export class GamepadCamera extends UniversalCamera {
  96333. /**
  96334. * Instantiates a new Gamepad Camera
  96335. * This represents a FPS type of camera. This is only here for back compat purpose.
  96336. * Please use the UniversalCamera instead as both are identical.
  96337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96338. * @param name Define the name of the camera in the scene
  96339. * @param position Define the start position of the camera in the scene
  96340. * @param scene Define the scene the camera belongs to
  96341. */
  96342. constructor(name: string, position: Vector3, scene: Scene);
  96343. /**
  96344. * Gets the current object class name.
  96345. * @return the class name
  96346. */
  96347. getClassName(): string;
  96348. }
  96349. }
  96350. declare module BABYLON {
  96351. /** @hidden */
  96352. export var passPixelShader: {
  96353. name: string;
  96354. shader: string;
  96355. };
  96356. }
  96357. declare module BABYLON {
  96358. /** @hidden */
  96359. export var passCubePixelShader: {
  96360. name: string;
  96361. shader: string;
  96362. };
  96363. }
  96364. declare module BABYLON {
  96365. /**
  96366. * PassPostProcess which produces an output the same as it's input
  96367. */
  96368. export class PassPostProcess extends PostProcess {
  96369. /**
  96370. * Creates the PassPostProcess
  96371. * @param name The name of the effect.
  96372. * @param options The required width/height ratio to downsize to before computing the render pass.
  96373. * @param camera The camera to apply the render pass to.
  96374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96375. * @param engine The engine which the post process will be applied. (default: current engine)
  96376. * @param reusable If the post process can be reused on the same frame. (default: false)
  96377. * @param textureType The type of texture to be used when performing the post processing.
  96378. * @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)
  96379. */
  96380. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96381. }
  96382. /**
  96383. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96384. */
  96385. export class PassCubePostProcess extends PostProcess {
  96386. private _face;
  96387. /**
  96388. * Gets or sets the cube face to display.
  96389. * * 0 is +X
  96390. * * 1 is -X
  96391. * * 2 is +Y
  96392. * * 3 is -Y
  96393. * * 4 is +Z
  96394. * * 5 is -Z
  96395. */
  96396. face: number;
  96397. /**
  96398. * Creates the PassCubePostProcess
  96399. * @param name The name of the effect.
  96400. * @param options The required width/height ratio to downsize to before computing the render pass.
  96401. * @param camera The camera to apply the render pass to.
  96402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96403. * @param engine The engine which the post process will be applied. (default: current engine)
  96404. * @param reusable If the post process can be reused on the same frame. (default: false)
  96405. * @param textureType The type of texture to be used when performing the post processing.
  96406. * @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)
  96407. */
  96408. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96409. }
  96410. }
  96411. declare module BABYLON {
  96412. /** @hidden */
  96413. export var anaglyphPixelShader: {
  96414. name: string;
  96415. shader: string;
  96416. };
  96417. }
  96418. declare module BABYLON {
  96419. /**
  96420. * Postprocess used to generate anaglyphic rendering
  96421. */
  96422. export class AnaglyphPostProcess extends PostProcess {
  96423. private _passedProcess;
  96424. /**
  96425. * Creates a new AnaglyphPostProcess
  96426. * @param name defines postprocess name
  96427. * @param options defines creation options or target ratio scale
  96428. * @param rigCameras defines cameras using this postprocess
  96429. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96430. * @param engine defines hosting engine
  96431. * @param reusable defines if the postprocess will be reused multiple times per frame
  96432. */
  96433. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96434. }
  96435. }
  96436. declare module BABYLON {
  96437. /**
  96438. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96440. */
  96441. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96442. /**
  96443. * Creates a new AnaglyphArcRotateCamera
  96444. * @param name defines camera name
  96445. * @param alpha defines alpha angle (in radians)
  96446. * @param beta defines beta angle (in radians)
  96447. * @param radius defines radius
  96448. * @param target defines camera target
  96449. * @param interaxialDistance defines distance between each color axis
  96450. * @param scene defines the hosting scene
  96451. */
  96452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96453. /**
  96454. * Gets camera class name
  96455. * @returns AnaglyphArcRotateCamera
  96456. */
  96457. getClassName(): string;
  96458. }
  96459. }
  96460. declare module BABYLON {
  96461. /**
  96462. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96463. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96464. */
  96465. export class AnaglyphFreeCamera extends FreeCamera {
  96466. /**
  96467. * Creates a new AnaglyphFreeCamera
  96468. * @param name defines camera name
  96469. * @param position defines initial position
  96470. * @param interaxialDistance defines distance between each color axis
  96471. * @param scene defines the hosting scene
  96472. */
  96473. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96474. /**
  96475. * Gets camera class name
  96476. * @returns AnaglyphFreeCamera
  96477. */
  96478. getClassName(): string;
  96479. }
  96480. }
  96481. declare module BABYLON {
  96482. /**
  96483. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96484. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96485. */
  96486. export class AnaglyphGamepadCamera extends GamepadCamera {
  96487. /**
  96488. * Creates a new AnaglyphGamepadCamera
  96489. * @param name defines camera name
  96490. * @param position defines initial position
  96491. * @param interaxialDistance defines distance between each color axis
  96492. * @param scene defines the hosting scene
  96493. */
  96494. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96495. /**
  96496. * Gets camera class name
  96497. * @returns AnaglyphGamepadCamera
  96498. */
  96499. getClassName(): string;
  96500. }
  96501. }
  96502. declare module BABYLON {
  96503. /**
  96504. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96505. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96506. */
  96507. export class AnaglyphUniversalCamera extends UniversalCamera {
  96508. /**
  96509. * Creates a new AnaglyphUniversalCamera
  96510. * @param name defines camera name
  96511. * @param position defines initial position
  96512. * @param interaxialDistance defines distance between each color axis
  96513. * @param scene defines the hosting scene
  96514. */
  96515. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96516. /**
  96517. * Gets camera class name
  96518. * @returns AnaglyphUniversalCamera
  96519. */
  96520. getClassName(): string;
  96521. }
  96522. }
  96523. declare module BABYLON {
  96524. /** @hidden */
  96525. export var stereoscopicInterlacePixelShader: {
  96526. name: string;
  96527. shader: string;
  96528. };
  96529. }
  96530. declare module BABYLON {
  96531. /**
  96532. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96533. */
  96534. export class StereoscopicInterlacePostProcess extends PostProcess {
  96535. private _stepSize;
  96536. private _passedProcess;
  96537. /**
  96538. * Initializes a StereoscopicInterlacePostProcess
  96539. * @param name The name of the effect.
  96540. * @param rigCameras The rig cameras to be appled to the post process
  96541. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96543. * @param engine The engine which the post process will be applied. (default: current engine)
  96544. * @param reusable If the post process can be reused on the same frame. (default: false)
  96545. */
  96546. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96547. }
  96548. }
  96549. declare module BABYLON {
  96550. /**
  96551. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96552. * @see http://doc.babylonjs.com/features/cameras
  96553. */
  96554. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96555. /**
  96556. * Creates a new StereoscopicArcRotateCamera
  96557. * @param name defines camera name
  96558. * @param alpha defines alpha angle (in radians)
  96559. * @param beta defines beta angle (in radians)
  96560. * @param radius defines radius
  96561. * @param target defines camera target
  96562. * @param interaxialDistance defines distance between each color axis
  96563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96564. * @param scene defines the hosting scene
  96565. */
  96566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96567. /**
  96568. * Gets camera class name
  96569. * @returns StereoscopicArcRotateCamera
  96570. */
  96571. getClassName(): string;
  96572. }
  96573. }
  96574. declare module BABYLON {
  96575. /**
  96576. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96577. * @see http://doc.babylonjs.com/features/cameras
  96578. */
  96579. export class StereoscopicFreeCamera extends FreeCamera {
  96580. /**
  96581. * Creates a new StereoscopicFreeCamera
  96582. * @param name defines camera name
  96583. * @param position defines initial position
  96584. * @param interaxialDistance defines distance between each color axis
  96585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96586. * @param scene defines the hosting scene
  96587. */
  96588. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96589. /**
  96590. * Gets camera class name
  96591. * @returns StereoscopicFreeCamera
  96592. */
  96593. getClassName(): string;
  96594. }
  96595. }
  96596. declare module BABYLON {
  96597. /**
  96598. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96599. * @see http://doc.babylonjs.com/features/cameras
  96600. */
  96601. export class StereoscopicGamepadCamera extends GamepadCamera {
  96602. /**
  96603. * Creates a new StereoscopicGamepadCamera
  96604. * @param name defines camera name
  96605. * @param position defines initial position
  96606. * @param interaxialDistance defines distance between each color axis
  96607. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96608. * @param scene defines the hosting scene
  96609. */
  96610. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96611. /**
  96612. * Gets camera class name
  96613. * @returns StereoscopicGamepadCamera
  96614. */
  96615. getClassName(): string;
  96616. }
  96617. }
  96618. declare module BABYLON {
  96619. /**
  96620. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96621. * @see http://doc.babylonjs.com/features/cameras
  96622. */
  96623. export class StereoscopicUniversalCamera extends UniversalCamera {
  96624. /**
  96625. * Creates a new StereoscopicUniversalCamera
  96626. * @param name defines camera name
  96627. * @param position defines initial position
  96628. * @param interaxialDistance defines distance between each color axis
  96629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96630. * @param scene defines the hosting scene
  96631. */
  96632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96633. /**
  96634. * Gets camera class name
  96635. * @returns StereoscopicUniversalCamera
  96636. */
  96637. getClassName(): string;
  96638. }
  96639. }
  96640. declare module BABYLON {
  96641. /**
  96642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96643. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96644. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96645. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96646. */
  96647. export class VirtualJoysticksCamera extends FreeCamera {
  96648. /**
  96649. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96650. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96651. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96652. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96653. * @param name Define the name of the camera in the scene
  96654. * @param position Define the start position of the camera in the scene
  96655. * @param scene Define the scene the camera belongs to
  96656. */
  96657. constructor(name: string, position: Vector3, scene: Scene);
  96658. /**
  96659. * Gets the current object class name.
  96660. * @return the class name
  96661. */
  96662. getClassName(): string;
  96663. }
  96664. }
  96665. declare module BABYLON {
  96666. /**
  96667. * This represents all the required metrics to create a VR camera.
  96668. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96669. */
  96670. export class VRCameraMetrics {
  96671. /**
  96672. * Define the horizontal resolution off the screen.
  96673. */
  96674. hResolution: number;
  96675. /**
  96676. * Define the vertical resolution off the screen.
  96677. */
  96678. vResolution: number;
  96679. /**
  96680. * Define the horizontal screen size.
  96681. */
  96682. hScreenSize: number;
  96683. /**
  96684. * Define the vertical screen size.
  96685. */
  96686. vScreenSize: number;
  96687. /**
  96688. * Define the vertical screen center position.
  96689. */
  96690. vScreenCenter: number;
  96691. /**
  96692. * Define the distance of the eyes to the screen.
  96693. */
  96694. eyeToScreenDistance: number;
  96695. /**
  96696. * Define the distance between both lenses
  96697. */
  96698. lensSeparationDistance: number;
  96699. /**
  96700. * Define the distance between both viewer's eyes.
  96701. */
  96702. interpupillaryDistance: number;
  96703. /**
  96704. * Define the distortion factor of the VR postprocess.
  96705. * Please, touch with care.
  96706. */
  96707. distortionK: number[];
  96708. /**
  96709. * Define the chromatic aberration correction factors for the VR post process.
  96710. */
  96711. chromaAbCorrection: number[];
  96712. /**
  96713. * Define the scale factor of the post process.
  96714. * The smaller the better but the slower.
  96715. */
  96716. postProcessScaleFactor: number;
  96717. /**
  96718. * Define an offset for the lens center.
  96719. */
  96720. lensCenterOffset: number;
  96721. /**
  96722. * Define if the current vr camera should compensate the distortion of the lense or not.
  96723. */
  96724. compensateDistortion: boolean;
  96725. /**
  96726. * Defines if multiview should be enabled when rendering (Default: false)
  96727. */
  96728. multiviewEnabled: boolean;
  96729. /**
  96730. * Gets the rendering aspect ratio based on the provided resolutions.
  96731. */
  96732. readonly aspectRatio: number;
  96733. /**
  96734. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  96735. */
  96736. readonly aspectRatioFov: number;
  96737. /**
  96738. * @hidden
  96739. */
  96740. readonly leftHMatrix: Matrix;
  96741. /**
  96742. * @hidden
  96743. */
  96744. readonly rightHMatrix: Matrix;
  96745. /**
  96746. * @hidden
  96747. */
  96748. readonly leftPreViewMatrix: Matrix;
  96749. /**
  96750. * @hidden
  96751. */
  96752. readonly rightPreViewMatrix: Matrix;
  96753. /**
  96754. * Get the default VRMetrics based on the most generic setup.
  96755. * @returns the default vr metrics
  96756. */
  96757. static GetDefault(): VRCameraMetrics;
  96758. }
  96759. }
  96760. declare module BABYLON {
  96761. /** @hidden */
  96762. export var vrDistortionCorrectionPixelShader: {
  96763. name: string;
  96764. shader: string;
  96765. };
  96766. }
  96767. declare module BABYLON {
  96768. /**
  96769. * VRDistortionCorrectionPostProcess used for mobile VR
  96770. */
  96771. export class VRDistortionCorrectionPostProcess extends PostProcess {
  96772. private _isRightEye;
  96773. private _distortionFactors;
  96774. private _postProcessScaleFactor;
  96775. private _lensCenterOffset;
  96776. private _scaleIn;
  96777. private _scaleFactor;
  96778. private _lensCenter;
  96779. /**
  96780. * Initializes the VRDistortionCorrectionPostProcess
  96781. * @param name The name of the effect.
  96782. * @param camera The camera to apply the render pass to.
  96783. * @param isRightEye If this is for the right eye distortion
  96784. * @param vrMetrics All the required metrics for the VR camera
  96785. */
  96786. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  96787. }
  96788. }
  96789. declare module BABYLON {
  96790. /**
  96791. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  96792. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96793. */
  96794. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  96795. /**
  96796. * Creates a new VRDeviceOrientationArcRotateCamera
  96797. * @param name defines camera name
  96798. * @param alpha defines the camera rotation along the logitudinal axis
  96799. * @param beta defines the camera rotation along the latitudinal axis
  96800. * @param radius defines the camera distance from its target
  96801. * @param target defines the camera target
  96802. * @param scene defines the scene the camera belongs to
  96803. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96804. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96805. */
  96806. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96807. /**
  96808. * Gets camera class name
  96809. * @returns VRDeviceOrientationArcRotateCamera
  96810. */
  96811. getClassName(): string;
  96812. }
  96813. }
  96814. declare module BABYLON {
  96815. /**
  96816. * Camera used to simulate VR rendering (based on FreeCamera)
  96817. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96818. */
  96819. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96820. /**
  96821. * Creates a new VRDeviceOrientationFreeCamera
  96822. * @param name defines camera name
  96823. * @param position defines the start position of the camera
  96824. * @param scene defines the scene the camera belongs to
  96825. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96826. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96827. */
  96828. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96829. /**
  96830. * Gets camera class name
  96831. * @returns VRDeviceOrientationFreeCamera
  96832. */
  96833. getClassName(): string;
  96834. }
  96835. }
  96836. declare module BABYLON {
  96837. /**
  96838. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96839. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96840. */
  96841. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96842. /**
  96843. * Creates a new VRDeviceOrientationGamepadCamera
  96844. * @param name defines camera name
  96845. * @param position defines the start position of the camera
  96846. * @param scene defines the scene the camera belongs to
  96847. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96848. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96849. */
  96850. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96851. /**
  96852. * Gets camera class name
  96853. * @returns VRDeviceOrientationGamepadCamera
  96854. */
  96855. getClassName(): string;
  96856. }
  96857. }
  96858. declare module BABYLON {
  96859. /**
  96860. * Defines supported buttons for XBox360 compatible gamepads
  96861. */
  96862. export enum Xbox360Button {
  96863. /** A */
  96864. A = 0,
  96865. /** B */
  96866. B = 1,
  96867. /** X */
  96868. X = 2,
  96869. /** Y */
  96870. Y = 3,
  96871. /** Start */
  96872. Start = 4,
  96873. /** Back */
  96874. Back = 5,
  96875. /** Left button */
  96876. LB = 6,
  96877. /** Right button */
  96878. RB = 7,
  96879. /** Left stick */
  96880. LeftStick = 8,
  96881. /** Right stick */
  96882. RightStick = 9
  96883. }
  96884. /** Defines values for XBox360 DPad */
  96885. export enum Xbox360Dpad {
  96886. /** Up */
  96887. Up = 0,
  96888. /** Down */
  96889. Down = 1,
  96890. /** Left */
  96891. Left = 2,
  96892. /** Right */
  96893. Right = 3
  96894. }
  96895. /**
  96896. * Defines a XBox360 gamepad
  96897. */
  96898. export class Xbox360Pad extends Gamepad {
  96899. private _leftTrigger;
  96900. private _rightTrigger;
  96901. private _onlefttriggerchanged;
  96902. private _onrighttriggerchanged;
  96903. private _onbuttondown;
  96904. private _onbuttonup;
  96905. private _ondpaddown;
  96906. private _ondpadup;
  96907. /** Observable raised when a button is pressed */
  96908. onButtonDownObservable: Observable<Xbox360Button>;
  96909. /** Observable raised when a button is released */
  96910. onButtonUpObservable: Observable<Xbox360Button>;
  96911. /** Observable raised when a pad is pressed */
  96912. onPadDownObservable: Observable<Xbox360Dpad>;
  96913. /** Observable raised when a pad is released */
  96914. onPadUpObservable: Observable<Xbox360Dpad>;
  96915. private _buttonA;
  96916. private _buttonB;
  96917. private _buttonX;
  96918. private _buttonY;
  96919. private _buttonBack;
  96920. private _buttonStart;
  96921. private _buttonLB;
  96922. private _buttonRB;
  96923. private _buttonLeftStick;
  96924. private _buttonRightStick;
  96925. private _dPadUp;
  96926. private _dPadDown;
  96927. private _dPadLeft;
  96928. private _dPadRight;
  96929. private _isXboxOnePad;
  96930. /**
  96931. * Creates a new XBox360 gamepad object
  96932. * @param id defines the id of this gamepad
  96933. * @param index defines its index
  96934. * @param gamepad defines the internal HTML gamepad object
  96935. * @param xboxOne defines if it is a XBox One gamepad
  96936. */
  96937. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96938. /**
  96939. * Defines the callback to call when left trigger is pressed
  96940. * @param callback defines the callback to use
  96941. */
  96942. onlefttriggerchanged(callback: (value: number) => void): void;
  96943. /**
  96944. * Defines the callback to call when right trigger is pressed
  96945. * @param callback defines the callback to use
  96946. */
  96947. onrighttriggerchanged(callback: (value: number) => void): void;
  96948. /**
  96949. * Gets the left trigger value
  96950. */
  96951. /**
  96952. * Sets the left trigger value
  96953. */
  96954. leftTrigger: number;
  96955. /**
  96956. * Gets the right trigger value
  96957. */
  96958. /**
  96959. * Sets the right trigger value
  96960. */
  96961. rightTrigger: number;
  96962. /**
  96963. * Defines the callback to call when a button is pressed
  96964. * @param callback defines the callback to use
  96965. */
  96966. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96967. /**
  96968. * Defines the callback to call when a button is released
  96969. * @param callback defines the callback to use
  96970. */
  96971. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96972. /**
  96973. * Defines the callback to call when a pad is pressed
  96974. * @param callback defines the callback to use
  96975. */
  96976. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96977. /**
  96978. * Defines the callback to call when a pad is released
  96979. * @param callback defines the callback to use
  96980. */
  96981. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96982. private _setButtonValue;
  96983. private _setDPadValue;
  96984. /**
  96985. * Gets the value of the `A` button
  96986. */
  96987. /**
  96988. * Sets the value of the `A` button
  96989. */
  96990. buttonA: number;
  96991. /**
  96992. * Gets the value of the `B` button
  96993. */
  96994. /**
  96995. * Sets the value of the `B` button
  96996. */
  96997. buttonB: number;
  96998. /**
  96999. * Gets the value of the `X` button
  97000. */
  97001. /**
  97002. * Sets the value of the `X` button
  97003. */
  97004. buttonX: number;
  97005. /**
  97006. * Gets the value of the `Y` button
  97007. */
  97008. /**
  97009. * Sets the value of the `Y` button
  97010. */
  97011. buttonY: number;
  97012. /**
  97013. * Gets the value of the `Start` button
  97014. */
  97015. /**
  97016. * Sets the value of the `Start` button
  97017. */
  97018. buttonStart: number;
  97019. /**
  97020. * Gets the value of the `Back` button
  97021. */
  97022. /**
  97023. * Sets the value of the `Back` button
  97024. */
  97025. buttonBack: number;
  97026. /**
  97027. * Gets the value of the `Left` button
  97028. */
  97029. /**
  97030. * Sets the value of the `Left` button
  97031. */
  97032. buttonLB: number;
  97033. /**
  97034. * Gets the value of the `Right` button
  97035. */
  97036. /**
  97037. * Sets the value of the `Right` button
  97038. */
  97039. buttonRB: number;
  97040. /**
  97041. * Gets the value of the Left joystick
  97042. */
  97043. /**
  97044. * Sets the value of the Left joystick
  97045. */
  97046. buttonLeftStick: number;
  97047. /**
  97048. * Gets the value of the Right joystick
  97049. */
  97050. /**
  97051. * Sets the value of the Right joystick
  97052. */
  97053. buttonRightStick: number;
  97054. /**
  97055. * Gets the value of D-pad up
  97056. */
  97057. /**
  97058. * Sets the value of D-pad up
  97059. */
  97060. dPadUp: number;
  97061. /**
  97062. * Gets the value of D-pad down
  97063. */
  97064. /**
  97065. * Sets the value of D-pad down
  97066. */
  97067. dPadDown: number;
  97068. /**
  97069. * Gets the value of D-pad left
  97070. */
  97071. /**
  97072. * Sets the value of D-pad left
  97073. */
  97074. dPadLeft: number;
  97075. /**
  97076. * Gets the value of D-pad right
  97077. */
  97078. /**
  97079. * Sets the value of D-pad right
  97080. */
  97081. dPadRight: number;
  97082. /**
  97083. * Force the gamepad to synchronize with device values
  97084. */
  97085. update(): void;
  97086. /**
  97087. * Disposes the gamepad
  97088. */
  97089. dispose(): void;
  97090. }
  97091. }
  97092. declare module BABYLON {
  97093. /**
  97094. * Base class of materials working in push mode in babylon JS
  97095. * @hidden
  97096. */
  97097. export class PushMaterial extends Material {
  97098. protected _activeEffect: Effect;
  97099. protected _normalMatrix: Matrix;
  97100. /**
  97101. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97102. * This means that the material can keep using a previous shader while a new one is being compiled.
  97103. * This is mostly used when shader parallel compilation is supported (true by default)
  97104. */
  97105. allowShaderHotSwapping: boolean;
  97106. constructor(name: string, scene: Scene);
  97107. getEffect(): Effect;
  97108. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97109. /**
  97110. * Binds the given world matrix to the active effect
  97111. *
  97112. * @param world the matrix to bind
  97113. */
  97114. bindOnlyWorldMatrix(world: Matrix): void;
  97115. /**
  97116. * Binds the given normal matrix to the active effect
  97117. *
  97118. * @param normalMatrix the matrix to bind
  97119. */
  97120. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97121. bind(world: Matrix, mesh?: Mesh): void;
  97122. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97123. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97124. }
  97125. }
  97126. declare module BABYLON {
  97127. /**
  97128. * This groups all the flags used to control the materials channel.
  97129. */
  97130. export class MaterialFlags {
  97131. private static _DiffuseTextureEnabled;
  97132. /**
  97133. * Are diffuse textures enabled in the application.
  97134. */
  97135. static DiffuseTextureEnabled: boolean;
  97136. private static _AmbientTextureEnabled;
  97137. /**
  97138. * Are ambient textures enabled in the application.
  97139. */
  97140. static AmbientTextureEnabled: boolean;
  97141. private static _OpacityTextureEnabled;
  97142. /**
  97143. * Are opacity textures enabled in the application.
  97144. */
  97145. static OpacityTextureEnabled: boolean;
  97146. private static _ReflectionTextureEnabled;
  97147. /**
  97148. * Are reflection textures enabled in the application.
  97149. */
  97150. static ReflectionTextureEnabled: boolean;
  97151. private static _EmissiveTextureEnabled;
  97152. /**
  97153. * Are emissive textures enabled in the application.
  97154. */
  97155. static EmissiveTextureEnabled: boolean;
  97156. private static _SpecularTextureEnabled;
  97157. /**
  97158. * Are specular textures enabled in the application.
  97159. */
  97160. static SpecularTextureEnabled: boolean;
  97161. private static _BumpTextureEnabled;
  97162. /**
  97163. * Are bump textures enabled in the application.
  97164. */
  97165. static BumpTextureEnabled: boolean;
  97166. private static _LightmapTextureEnabled;
  97167. /**
  97168. * Are lightmap textures enabled in the application.
  97169. */
  97170. static LightmapTextureEnabled: boolean;
  97171. private static _RefractionTextureEnabled;
  97172. /**
  97173. * Are refraction textures enabled in the application.
  97174. */
  97175. static RefractionTextureEnabled: boolean;
  97176. private static _ColorGradingTextureEnabled;
  97177. /**
  97178. * Are color grading textures enabled in the application.
  97179. */
  97180. static ColorGradingTextureEnabled: boolean;
  97181. private static _FresnelEnabled;
  97182. /**
  97183. * Are fresnels enabled in the application.
  97184. */
  97185. static FresnelEnabled: boolean;
  97186. private static _ClearCoatTextureEnabled;
  97187. /**
  97188. * Are clear coat textures enabled in the application.
  97189. */
  97190. static ClearCoatTextureEnabled: boolean;
  97191. private static _ClearCoatBumpTextureEnabled;
  97192. /**
  97193. * Are clear coat bump textures enabled in the application.
  97194. */
  97195. static ClearCoatBumpTextureEnabled: boolean;
  97196. private static _ClearCoatTintTextureEnabled;
  97197. /**
  97198. * Are clear coat tint textures enabled in the application.
  97199. */
  97200. static ClearCoatTintTextureEnabled: boolean;
  97201. private static _SheenTextureEnabled;
  97202. /**
  97203. * Are sheen textures enabled in the application.
  97204. */
  97205. static SheenTextureEnabled: boolean;
  97206. private static _AnisotropicTextureEnabled;
  97207. /**
  97208. * Are anisotropic textures enabled in the application.
  97209. */
  97210. static AnisotropicTextureEnabled: boolean;
  97211. }
  97212. }
  97213. declare module BABYLON {
  97214. /** @hidden */
  97215. export var defaultFragmentDeclaration: {
  97216. name: string;
  97217. shader: string;
  97218. };
  97219. }
  97220. declare module BABYLON {
  97221. /** @hidden */
  97222. export var defaultUboDeclaration: {
  97223. name: string;
  97224. shader: string;
  97225. };
  97226. }
  97227. declare module BABYLON {
  97228. /** @hidden */
  97229. export var lightFragmentDeclaration: {
  97230. name: string;
  97231. shader: string;
  97232. };
  97233. }
  97234. declare module BABYLON {
  97235. /** @hidden */
  97236. export var lightUboDeclaration: {
  97237. name: string;
  97238. shader: string;
  97239. };
  97240. }
  97241. declare module BABYLON {
  97242. /** @hidden */
  97243. export var lightsFragmentFunctions: {
  97244. name: string;
  97245. shader: string;
  97246. };
  97247. }
  97248. declare module BABYLON {
  97249. /** @hidden */
  97250. export var shadowsFragmentFunctions: {
  97251. name: string;
  97252. shader: string;
  97253. };
  97254. }
  97255. declare module BABYLON {
  97256. /** @hidden */
  97257. export var fresnelFunction: {
  97258. name: string;
  97259. shader: string;
  97260. };
  97261. }
  97262. declare module BABYLON {
  97263. /** @hidden */
  97264. export var reflectionFunction: {
  97265. name: string;
  97266. shader: string;
  97267. };
  97268. }
  97269. declare module BABYLON {
  97270. /** @hidden */
  97271. export var bumpFragmentFunctions: {
  97272. name: string;
  97273. shader: string;
  97274. };
  97275. }
  97276. declare module BABYLON {
  97277. /** @hidden */
  97278. export var logDepthDeclaration: {
  97279. name: string;
  97280. shader: string;
  97281. };
  97282. }
  97283. declare module BABYLON {
  97284. /** @hidden */
  97285. export var bumpFragment: {
  97286. name: string;
  97287. shader: string;
  97288. };
  97289. }
  97290. declare module BABYLON {
  97291. /** @hidden */
  97292. export var depthPrePass: {
  97293. name: string;
  97294. shader: string;
  97295. };
  97296. }
  97297. declare module BABYLON {
  97298. /** @hidden */
  97299. export var lightFragment: {
  97300. name: string;
  97301. shader: string;
  97302. };
  97303. }
  97304. declare module BABYLON {
  97305. /** @hidden */
  97306. export var logDepthFragment: {
  97307. name: string;
  97308. shader: string;
  97309. };
  97310. }
  97311. declare module BABYLON {
  97312. /** @hidden */
  97313. export var defaultPixelShader: {
  97314. name: string;
  97315. shader: string;
  97316. };
  97317. }
  97318. declare module BABYLON {
  97319. /** @hidden */
  97320. export var defaultVertexDeclaration: {
  97321. name: string;
  97322. shader: string;
  97323. };
  97324. }
  97325. declare module BABYLON {
  97326. /** @hidden */
  97327. export var bumpVertexDeclaration: {
  97328. name: string;
  97329. shader: string;
  97330. };
  97331. }
  97332. declare module BABYLON {
  97333. /** @hidden */
  97334. export var bumpVertex: {
  97335. name: string;
  97336. shader: string;
  97337. };
  97338. }
  97339. declare module BABYLON {
  97340. /** @hidden */
  97341. export var fogVertex: {
  97342. name: string;
  97343. shader: string;
  97344. };
  97345. }
  97346. declare module BABYLON {
  97347. /** @hidden */
  97348. export var shadowsVertex: {
  97349. name: string;
  97350. shader: string;
  97351. };
  97352. }
  97353. declare module BABYLON {
  97354. /** @hidden */
  97355. export var pointCloudVertex: {
  97356. name: string;
  97357. shader: string;
  97358. };
  97359. }
  97360. declare module BABYLON {
  97361. /** @hidden */
  97362. export var logDepthVertex: {
  97363. name: string;
  97364. shader: string;
  97365. };
  97366. }
  97367. declare module BABYLON {
  97368. /** @hidden */
  97369. export var defaultVertexShader: {
  97370. name: string;
  97371. shader: string;
  97372. };
  97373. }
  97374. declare module BABYLON {
  97375. /** @hidden */
  97376. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97377. MAINUV1: boolean;
  97378. MAINUV2: boolean;
  97379. DIFFUSE: boolean;
  97380. DIFFUSEDIRECTUV: number;
  97381. AMBIENT: boolean;
  97382. AMBIENTDIRECTUV: number;
  97383. OPACITY: boolean;
  97384. OPACITYDIRECTUV: number;
  97385. OPACITYRGB: boolean;
  97386. REFLECTION: boolean;
  97387. EMISSIVE: boolean;
  97388. EMISSIVEDIRECTUV: number;
  97389. SPECULAR: boolean;
  97390. SPECULARDIRECTUV: number;
  97391. BUMP: boolean;
  97392. BUMPDIRECTUV: number;
  97393. PARALLAX: boolean;
  97394. PARALLAXOCCLUSION: boolean;
  97395. SPECULAROVERALPHA: boolean;
  97396. CLIPPLANE: boolean;
  97397. CLIPPLANE2: boolean;
  97398. CLIPPLANE3: boolean;
  97399. CLIPPLANE4: boolean;
  97400. ALPHATEST: boolean;
  97401. DEPTHPREPASS: boolean;
  97402. ALPHAFROMDIFFUSE: boolean;
  97403. POINTSIZE: boolean;
  97404. FOG: boolean;
  97405. SPECULARTERM: boolean;
  97406. DIFFUSEFRESNEL: boolean;
  97407. OPACITYFRESNEL: boolean;
  97408. REFLECTIONFRESNEL: boolean;
  97409. REFRACTIONFRESNEL: boolean;
  97410. EMISSIVEFRESNEL: boolean;
  97411. FRESNEL: boolean;
  97412. NORMAL: boolean;
  97413. UV1: boolean;
  97414. UV2: boolean;
  97415. VERTEXCOLOR: boolean;
  97416. VERTEXALPHA: boolean;
  97417. NUM_BONE_INFLUENCERS: number;
  97418. BonesPerMesh: number;
  97419. BONETEXTURE: boolean;
  97420. INSTANCES: boolean;
  97421. GLOSSINESS: boolean;
  97422. ROUGHNESS: boolean;
  97423. EMISSIVEASILLUMINATION: boolean;
  97424. LINKEMISSIVEWITHDIFFUSE: boolean;
  97425. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97426. LIGHTMAP: boolean;
  97427. LIGHTMAPDIRECTUV: number;
  97428. OBJECTSPACE_NORMALMAP: boolean;
  97429. USELIGHTMAPASSHADOWMAP: boolean;
  97430. REFLECTIONMAP_3D: boolean;
  97431. REFLECTIONMAP_SPHERICAL: boolean;
  97432. REFLECTIONMAP_PLANAR: boolean;
  97433. REFLECTIONMAP_CUBIC: boolean;
  97434. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97435. REFLECTIONMAP_PROJECTION: boolean;
  97436. REFLECTIONMAP_SKYBOX: boolean;
  97437. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97438. REFLECTIONMAP_EXPLICIT: boolean;
  97439. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97440. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97441. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97442. INVERTCUBICMAP: boolean;
  97443. LOGARITHMICDEPTH: boolean;
  97444. REFRACTION: boolean;
  97445. REFRACTIONMAP_3D: boolean;
  97446. REFLECTIONOVERALPHA: boolean;
  97447. TWOSIDEDLIGHTING: boolean;
  97448. SHADOWFLOAT: boolean;
  97449. MORPHTARGETS: boolean;
  97450. MORPHTARGETS_NORMAL: boolean;
  97451. MORPHTARGETS_TANGENT: boolean;
  97452. NUM_MORPH_INFLUENCERS: number;
  97453. NONUNIFORMSCALING: boolean;
  97454. PREMULTIPLYALPHA: boolean;
  97455. IMAGEPROCESSING: boolean;
  97456. VIGNETTE: boolean;
  97457. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97458. VIGNETTEBLENDMODEOPAQUE: boolean;
  97459. TONEMAPPING: boolean;
  97460. TONEMAPPING_ACES: boolean;
  97461. CONTRAST: boolean;
  97462. COLORCURVES: boolean;
  97463. COLORGRADING: boolean;
  97464. COLORGRADING3D: boolean;
  97465. SAMPLER3DGREENDEPTH: boolean;
  97466. SAMPLER3DBGRMAP: boolean;
  97467. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97468. MULTIVIEW: boolean;
  97469. /**
  97470. * If the reflection texture on this material is in linear color space
  97471. * @hidden
  97472. */
  97473. IS_REFLECTION_LINEAR: boolean;
  97474. /**
  97475. * If the refraction texture on this material is in linear color space
  97476. * @hidden
  97477. */
  97478. IS_REFRACTION_LINEAR: boolean;
  97479. EXPOSURE: boolean;
  97480. constructor();
  97481. setReflectionMode(modeToEnable: string): void;
  97482. }
  97483. /**
  97484. * This is the default material used in Babylon. It is the best trade off between quality
  97485. * and performances.
  97486. * @see http://doc.babylonjs.com/babylon101/materials
  97487. */
  97488. export class StandardMaterial extends PushMaterial {
  97489. private _diffuseTexture;
  97490. /**
  97491. * The basic texture of the material as viewed under a light.
  97492. */
  97493. diffuseTexture: Nullable<BaseTexture>;
  97494. private _ambientTexture;
  97495. /**
  97496. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97497. */
  97498. ambientTexture: Nullable<BaseTexture>;
  97499. private _opacityTexture;
  97500. /**
  97501. * Define the transparency of the material from a texture.
  97502. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97503. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97504. */
  97505. opacityTexture: Nullable<BaseTexture>;
  97506. private _reflectionTexture;
  97507. /**
  97508. * Define the texture used to display the reflection.
  97509. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97510. */
  97511. reflectionTexture: Nullable<BaseTexture>;
  97512. private _emissiveTexture;
  97513. /**
  97514. * Define texture of the material as if self lit.
  97515. * This will be mixed in the final result even in the absence of light.
  97516. */
  97517. emissiveTexture: Nullable<BaseTexture>;
  97518. private _specularTexture;
  97519. /**
  97520. * Define how the color and intensity of the highlight given by the light in the material.
  97521. */
  97522. specularTexture: Nullable<BaseTexture>;
  97523. private _bumpTexture;
  97524. /**
  97525. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97526. * 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.
  97527. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97528. */
  97529. bumpTexture: Nullable<BaseTexture>;
  97530. private _lightmapTexture;
  97531. /**
  97532. * Complex lighting can be computationally expensive to compute at runtime.
  97533. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97534. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97535. */
  97536. lightmapTexture: Nullable<BaseTexture>;
  97537. private _refractionTexture;
  97538. /**
  97539. * Define the texture used to display the refraction.
  97540. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97541. */
  97542. refractionTexture: Nullable<BaseTexture>;
  97543. /**
  97544. * The color of the material lit by the environmental background lighting.
  97545. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97546. */
  97547. ambientColor: Color3;
  97548. /**
  97549. * The basic color of the material as viewed under a light.
  97550. */
  97551. diffuseColor: Color3;
  97552. /**
  97553. * Define how the color and intensity of the highlight given by the light in the material.
  97554. */
  97555. specularColor: Color3;
  97556. /**
  97557. * Define the color of the material as if self lit.
  97558. * This will be mixed in the final result even in the absence of light.
  97559. */
  97560. emissiveColor: Color3;
  97561. /**
  97562. * Defines how sharp are the highlights in the material.
  97563. * The bigger the value the sharper giving a more glossy feeling to the result.
  97564. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97565. */
  97566. specularPower: number;
  97567. private _useAlphaFromDiffuseTexture;
  97568. /**
  97569. * Does the transparency come from the diffuse texture alpha channel.
  97570. */
  97571. useAlphaFromDiffuseTexture: boolean;
  97572. private _useEmissiveAsIllumination;
  97573. /**
  97574. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97575. */
  97576. useEmissiveAsIllumination: boolean;
  97577. private _linkEmissiveWithDiffuse;
  97578. /**
  97579. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97580. * the emissive level when the final color is close to one.
  97581. */
  97582. linkEmissiveWithDiffuse: boolean;
  97583. private _useSpecularOverAlpha;
  97584. /**
  97585. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97586. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97587. */
  97588. useSpecularOverAlpha: boolean;
  97589. private _useReflectionOverAlpha;
  97590. /**
  97591. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97592. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97593. */
  97594. useReflectionOverAlpha: boolean;
  97595. private _disableLighting;
  97596. /**
  97597. * Does lights from the scene impacts this material.
  97598. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97599. */
  97600. disableLighting: boolean;
  97601. private _useObjectSpaceNormalMap;
  97602. /**
  97603. * Allows using an object space normal map (instead of tangent space).
  97604. */
  97605. useObjectSpaceNormalMap: boolean;
  97606. private _useParallax;
  97607. /**
  97608. * Is parallax enabled or not.
  97609. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97610. */
  97611. useParallax: boolean;
  97612. private _useParallaxOcclusion;
  97613. /**
  97614. * Is parallax occlusion enabled or not.
  97615. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97616. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97617. */
  97618. useParallaxOcclusion: boolean;
  97619. /**
  97620. * 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.
  97621. */
  97622. parallaxScaleBias: number;
  97623. private _roughness;
  97624. /**
  97625. * Helps to define how blurry the reflections should appears in the material.
  97626. */
  97627. roughness: number;
  97628. /**
  97629. * In case of refraction, define the value of the indice of refraction.
  97630. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97631. */
  97632. indexOfRefraction: number;
  97633. /**
  97634. * Invert the refraction texture alongside the y axis.
  97635. * It can be useful with procedural textures or probe for instance.
  97636. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97637. */
  97638. invertRefractionY: boolean;
  97639. /**
  97640. * Defines the alpha limits in alpha test mode.
  97641. */
  97642. alphaCutOff: number;
  97643. private _useLightmapAsShadowmap;
  97644. /**
  97645. * In case of light mapping, define whether the map contains light or shadow informations.
  97646. */
  97647. useLightmapAsShadowmap: boolean;
  97648. private _diffuseFresnelParameters;
  97649. /**
  97650. * Define the diffuse fresnel parameters of the material.
  97651. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97652. */
  97653. diffuseFresnelParameters: FresnelParameters;
  97654. private _opacityFresnelParameters;
  97655. /**
  97656. * Define the opacity fresnel parameters of the material.
  97657. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97658. */
  97659. opacityFresnelParameters: FresnelParameters;
  97660. private _reflectionFresnelParameters;
  97661. /**
  97662. * Define the reflection fresnel parameters of the material.
  97663. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97664. */
  97665. reflectionFresnelParameters: FresnelParameters;
  97666. private _refractionFresnelParameters;
  97667. /**
  97668. * Define the refraction fresnel parameters of the material.
  97669. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97670. */
  97671. refractionFresnelParameters: FresnelParameters;
  97672. private _emissiveFresnelParameters;
  97673. /**
  97674. * Define the emissive fresnel parameters of the material.
  97675. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97676. */
  97677. emissiveFresnelParameters: FresnelParameters;
  97678. private _useReflectionFresnelFromSpecular;
  97679. /**
  97680. * If true automatically deducts the fresnels values from the material specularity.
  97681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97682. */
  97683. useReflectionFresnelFromSpecular: boolean;
  97684. private _useGlossinessFromSpecularMapAlpha;
  97685. /**
  97686. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97687. */
  97688. useGlossinessFromSpecularMapAlpha: boolean;
  97689. private _maxSimultaneousLights;
  97690. /**
  97691. * Defines the maximum number of lights that can be used in the material
  97692. */
  97693. maxSimultaneousLights: number;
  97694. private _invertNormalMapX;
  97695. /**
  97696. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97697. */
  97698. invertNormalMapX: boolean;
  97699. private _invertNormalMapY;
  97700. /**
  97701. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97702. */
  97703. invertNormalMapY: boolean;
  97704. private _twoSidedLighting;
  97705. /**
  97706. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97707. */
  97708. twoSidedLighting: boolean;
  97709. /**
  97710. * Default configuration related to image processing available in the standard Material.
  97711. */
  97712. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97713. /**
  97714. * Gets the image processing configuration used either in this material.
  97715. */
  97716. /**
  97717. * Sets the Default image processing configuration used either in the this material.
  97718. *
  97719. * If sets to null, the scene one is in use.
  97720. */
  97721. imageProcessingConfiguration: ImageProcessingConfiguration;
  97722. /**
  97723. * Keep track of the image processing observer to allow dispose and replace.
  97724. */
  97725. private _imageProcessingObserver;
  97726. /**
  97727. * Attaches a new image processing configuration to the Standard Material.
  97728. * @param configuration
  97729. */
  97730. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97731. /**
  97732. * Gets wether the color curves effect is enabled.
  97733. */
  97734. /**
  97735. * Sets wether the color curves effect is enabled.
  97736. */
  97737. cameraColorCurvesEnabled: boolean;
  97738. /**
  97739. * Gets wether the color grading effect is enabled.
  97740. */
  97741. /**
  97742. * Gets wether the color grading effect is enabled.
  97743. */
  97744. cameraColorGradingEnabled: boolean;
  97745. /**
  97746. * Gets wether tonemapping is enabled or not.
  97747. */
  97748. /**
  97749. * Sets wether tonemapping is enabled or not
  97750. */
  97751. cameraToneMappingEnabled: boolean;
  97752. /**
  97753. * The camera exposure used on this material.
  97754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97755. * This corresponds to a photographic exposure.
  97756. */
  97757. /**
  97758. * The camera exposure used on this material.
  97759. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97760. * This corresponds to a photographic exposure.
  97761. */
  97762. cameraExposure: number;
  97763. /**
  97764. * Gets The camera contrast used on this material.
  97765. */
  97766. /**
  97767. * Sets The camera contrast used on this material.
  97768. */
  97769. cameraContrast: number;
  97770. /**
  97771. * Gets the Color Grading 2D Lookup Texture.
  97772. */
  97773. /**
  97774. * Sets the Color Grading 2D Lookup Texture.
  97775. */
  97776. cameraColorGradingTexture: Nullable<BaseTexture>;
  97777. /**
  97778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97780. * 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;
  97781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97782. */
  97783. /**
  97784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97786. * 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;
  97787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97788. */
  97789. cameraColorCurves: Nullable<ColorCurves>;
  97790. /**
  97791. * Custom callback helping to override the default shader used in the material.
  97792. */
  97793. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97794. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97795. protected _worldViewProjectionMatrix: Matrix;
  97796. protected _globalAmbientColor: Color3;
  97797. protected _useLogarithmicDepth: boolean;
  97798. /**
  97799. * Instantiates a new standard material.
  97800. * This is the default material used in Babylon. It is the best trade off between quality
  97801. * and performances.
  97802. * @see http://doc.babylonjs.com/babylon101/materials
  97803. * @param name Define the name of the material in the scene
  97804. * @param scene Define the scene the material belong to
  97805. */
  97806. constructor(name: string, scene: Scene);
  97807. /**
  97808. * Gets a boolean indicating that current material needs to register RTT
  97809. */
  97810. readonly hasRenderTargetTextures: boolean;
  97811. /**
  97812. * Gets the current class name of the material e.g. "StandardMaterial"
  97813. * Mainly use in serialization.
  97814. * @returns the class name
  97815. */
  97816. getClassName(): string;
  97817. /**
  97818. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97819. * You can try switching to logarithmic depth.
  97820. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97821. */
  97822. useLogarithmicDepth: boolean;
  97823. /**
  97824. * Specifies if the material will require alpha blending
  97825. * @returns a boolean specifying if alpha blending is needed
  97826. */
  97827. needAlphaBlending(): boolean;
  97828. /**
  97829. * Specifies if this material should be rendered in alpha test mode
  97830. * @returns a boolean specifying if an alpha test is needed.
  97831. */
  97832. needAlphaTesting(): boolean;
  97833. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97834. /**
  97835. * Get the texture used for alpha test purpose.
  97836. * @returns the diffuse texture in case of the standard material.
  97837. */
  97838. getAlphaTestTexture(): Nullable<BaseTexture>;
  97839. /**
  97840. * Get if the submesh is ready to be used and all its information available.
  97841. * Child classes can use it to update shaders
  97842. * @param mesh defines the mesh to check
  97843. * @param subMesh defines which submesh to check
  97844. * @param useInstances specifies that instances should be used
  97845. * @returns a boolean indicating that the submesh is ready or not
  97846. */
  97847. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97848. /**
  97849. * Builds the material UBO layouts.
  97850. * Used internally during the effect preparation.
  97851. */
  97852. buildUniformLayout(): void;
  97853. /**
  97854. * Unbinds the material from the mesh
  97855. */
  97856. unbind(): void;
  97857. /**
  97858. * Binds the submesh to this material by preparing the effect and shader to draw
  97859. * @param world defines the world transformation matrix
  97860. * @param mesh defines the mesh containing the submesh
  97861. * @param subMesh defines the submesh to bind the material to
  97862. */
  97863. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97864. /**
  97865. * Get the list of animatables in the material.
  97866. * @returns the list of animatables object used in the material
  97867. */
  97868. getAnimatables(): IAnimatable[];
  97869. /**
  97870. * Gets the active textures from the material
  97871. * @returns an array of textures
  97872. */
  97873. getActiveTextures(): BaseTexture[];
  97874. /**
  97875. * Specifies if the material uses a texture
  97876. * @param texture defines the texture to check against the material
  97877. * @returns a boolean specifying if the material uses the texture
  97878. */
  97879. hasTexture(texture: BaseTexture): boolean;
  97880. /**
  97881. * Disposes the material
  97882. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97883. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97884. */
  97885. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97886. /**
  97887. * Makes a duplicate of the material, and gives it a new name
  97888. * @param name defines the new name for the duplicated material
  97889. * @returns the cloned material
  97890. */
  97891. clone(name: string): StandardMaterial;
  97892. /**
  97893. * Serializes this material in a JSON representation
  97894. * @returns the serialized material object
  97895. */
  97896. serialize(): any;
  97897. /**
  97898. * Creates a standard material from parsed material data
  97899. * @param source defines the JSON representation of the material
  97900. * @param scene defines the hosting scene
  97901. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97902. * @returns a new standard material
  97903. */
  97904. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97905. /**
  97906. * Are diffuse textures enabled in the application.
  97907. */
  97908. static DiffuseTextureEnabled: boolean;
  97909. /**
  97910. * Are ambient textures enabled in the application.
  97911. */
  97912. static AmbientTextureEnabled: boolean;
  97913. /**
  97914. * Are opacity textures enabled in the application.
  97915. */
  97916. static OpacityTextureEnabled: boolean;
  97917. /**
  97918. * Are reflection textures enabled in the application.
  97919. */
  97920. static ReflectionTextureEnabled: boolean;
  97921. /**
  97922. * Are emissive textures enabled in the application.
  97923. */
  97924. static EmissiveTextureEnabled: boolean;
  97925. /**
  97926. * Are specular textures enabled in the application.
  97927. */
  97928. static SpecularTextureEnabled: boolean;
  97929. /**
  97930. * Are bump textures enabled in the application.
  97931. */
  97932. static BumpTextureEnabled: boolean;
  97933. /**
  97934. * Are lightmap textures enabled in the application.
  97935. */
  97936. static LightmapTextureEnabled: boolean;
  97937. /**
  97938. * Are refraction textures enabled in the application.
  97939. */
  97940. static RefractionTextureEnabled: boolean;
  97941. /**
  97942. * Are color grading textures enabled in the application.
  97943. */
  97944. static ColorGradingTextureEnabled: boolean;
  97945. /**
  97946. * Are fresnels enabled in the application.
  97947. */
  97948. static FresnelEnabled: boolean;
  97949. }
  97950. }
  97951. declare module BABYLON {
  97952. /**
  97953. * A class extending Texture allowing drawing on a texture
  97954. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97955. */
  97956. export class DynamicTexture extends Texture {
  97957. private _generateMipMaps;
  97958. private _canvas;
  97959. private _context;
  97960. private _engine;
  97961. /**
  97962. * Creates a DynamicTexture
  97963. * @param name defines the name of the texture
  97964. * @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
  97965. * @param scene defines the scene where you want the texture
  97966. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97967. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97968. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97969. */
  97970. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97971. /**
  97972. * Get the current class name of the texture useful for serialization or dynamic coding.
  97973. * @returns "DynamicTexture"
  97974. */
  97975. getClassName(): string;
  97976. /**
  97977. * Gets the current state of canRescale
  97978. */
  97979. readonly canRescale: boolean;
  97980. private _recreate;
  97981. /**
  97982. * Scales the texture
  97983. * @param ratio the scale factor to apply to both width and height
  97984. */
  97985. scale(ratio: number): void;
  97986. /**
  97987. * Resizes the texture
  97988. * @param width the new width
  97989. * @param height the new height
  97990. */
  97991. scaleTo(width: number, height: number): void;
  97992. /**
  97993. * Gets the context of the canvas used by the texture
  97994. * @returns the canvas context of the dynamic texture
  97995. */
  97996. getContext(): CanvasRenderingContext2D;
  97997. /**
  97998. * Clears the texture
  97999. */
  98000. clear(): void;
  98001. /**
  98002. * Updates the texture
  98003. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98004. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98005. */
  98006. update(invertY?: boolean, premulAlpha?: boolean): void;
  98007. /**
  98008. * Draws text onto the texture
  98009. * @param text defines the text to be drawn
  98010. * @param x defines the placement of the text from the left
  98011. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98012. * @param font defines the font to be used with font-style, font-size, font-name
  98013. * @param color defines the color used for the text
  98014. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98015. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98016. * @param update defines whether texture is immediately update (default is true)
  98017. */
  98018. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98019. /**
  98020. * Clones the texture
  98021. * @returns the clone of the texture.
  98022. */
  98023. clone(): DynamicTexture;
  98024. /**
  98025. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98026. * @returns a serialized dynamic texture object
  98027. */
  98028. serialize(): any;
  98029. /** @hidden */
  98030. _rebuild(): void;
  98031. }
  98032. }
  98033. declare module BABYLON {
  98034. /** @hidden */
  98035. export var imageProcessingPixelShader: {
  98036. name: string;
  98037. shader: string;
  98038. };
  98039. }
  98040. declare module BABYLON {
  98041. /**
  98042. * ImageProcessingPostProcess
  98043. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98044. */
  98045. export class ImageProcessingPostProcess extends PostProcess {
  98046. /**
  98047. * Default configuration related to image processing available in the PBR Material.
  98048. */
  98049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98050. /**
  98051. * Gets the image processing configuration used either in this material.
  98052. */
  98053. /**
  98054. * Sets the Default image processing configuration used either in the this material.
  98055. *
  98056. * If sets to null, the scene one is in use.
  98057. */
  98058. imageProcessingConfiguration: ImageProcessingConfiguration;
  98059. /**
  98060. * Keep track of the image processing observer to allow dispose and replace.
  98061. */
  98062. private _imageProcessingObserver;
  98063. /**
  98064. * Attaches a new image processing configuration to the PBR Material.
  98065. * @param configuration
  98066. */
  98067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98068. /**
  98069. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98070. */
  98071. /**
  98072. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98073. */
  98074. colorCurves: Nullable<ColorCurves>;
  98075. /**
  98076. * Gets wether the color curves effect is enabled.
  98077. */
  98078. /**
  98079. * Sets wether the color curves effect is enabled.
  98080. */
  98081. colorCurvesEnabled: boolean;
  98082. /**
  98083. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98084. */
  98085. /**
  98086. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98087. */
  98088. colorGradingTexture: Nullable<BaseTexture>;
  98089. /**
  98090. * Gets wether the color grading effect is enabled.
  98091. */
  98092. /**
  98093. * Gets wether the color grading effect is enabled.
  98094. */
  98095. colorGradingEnabled: boolean;
  98096. /**
  98097. * Gets exposure used in the effect.
  98098. */
  98099. /**
  98100. * Sets exposure used in the effect.
  98101. */
  98102. exposure: number;
  98103. /**
  98104. * Gets wether tonemapping is enabled or not.
  98105. */
  98106. /**
  98107. * Sets wether tonemapping is enabled or not
  98108. */
  98109. toneMappingEnabled: boolean;
  98110. /**
  98111. * Gets the type of tone mapping effect.
  98112. */
  98113. /**
  98114. * Sets the type of tone mapping effect.
  98115. */
  98116. toneMappingType: number;
  98117. /**
  98118. * Gets contrast used in the effect.
  98119. */
  98120. /**
  98121. * Sets contrast used in the effect.
  98122. */
  98123. contrast: number;
  98124. /**
  98125. * Gets Vignette stretch size.
  98126. */
  98127. /**
  98128. * Sets Vignette stretch size.
  98129. */
  98130. vignetteStretch: number;
  98131. /**
  98132. * Gets Vignette centre X Offset.
  98133. */
  98134. /**
  98135. * Sets Vignette centre X Offset.
  98136. */
  98137. vignetteCentreX: number;
  98138. /**
  98139. * Gets Vignette centre Y Offset.
  98140. */
  98141. /**
  98142. * Sets Vignette centre Y Offset.
  98143. */
  98144. vignetteCentreY: number;
  98145. /**
  98146. * Gets Vignette weight or intensity of the vignette effect.
  98147. */
  98148. /**
  98149. * Sets Vignette weight or intensity of the vignette effect.
  98150. */
  98151. vignetteWeight: number;
  98152. /**
  98153. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98154. * if vignetteEnabled is set to true.
  98155. */
  98156. /**
  98157. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98158. * if vignetteEnabled is set to true.
  98159. */
  98160. vignetteColor: Color4;
  98161. /**
  98162. * Gets Camera field of view used by the Vignette effect.
  98163. */
  98164. /**
  98165. * Sets Camera field of view used by the Vignette effect.
  98166. */
  98167. vignetteCameraFov: number;
  98168. /**
  98169. * Gets the vignette blend mode allowing different kind of effect.
  98170. */
  98171. /**
  98172. * Sets the vignette blend mode allowing different kind of effect.
  98173. */
  98174. vignetteBlendMode: number;
  98175. /**
  98176. * Gets wether the vignette effect is enabled.
  98177. */
  98178. /**
  98179. * Sets wether the vignette effect is enabled.
  98180. */
  98181. vignetteEnabled: boolean;
  98182. private _fromLinearSpace;
  98183. /**
  98184. * Gets wether the input of the processing is in Gamma or Linear Space.
  98185. */
  98186. /**
  98187. * Sets wether the input of the processing is in Gamma or Linear Space.
  98188. */
  98189. fromLinearSpace: boolean;
  98190. /**
  98191. * Defines cache preventing GC.
  98192. */
  98193. private _defines;
  98194. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98195. /**
  98196. * "ImageProcessingPostProcess"
  98197. * @returns "ImageProcessingPostProcess"
  98198. */
  98199. getClassName(): string;
  98200. protected _updateParameters(): void;
  98201. dispose(camera?: Camera): void;
  98202. }
  98203. }
  98204. declare module BABYLON {
  98205. /**
  98206. * Class containing static functions to help procedurally build meshes
  98207. */
  98208. export class GroundBuilder {
  98209. /**
  98210. * Creates a ground mesh
  98211. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98212. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98214. * @param name defines the name of the mesh
  98215. * @param options defines the options used to create the mesh
  98216. * @param scene defines the hosting scene
  98217. * @returns the ground mesh
  98218. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98219. */
  98220. static CreateGround(name: string, options: {
  98221. width?: number;
  98222. height?: number;
  98223. subdivisions?: number;
  98224. subdivisionsX?: number;
  98225. subdivisionsY?: number;
  98226. updatable?: boolean;
  98227. }, scene: any): Mesh;
  98228. /**
  98229. * Creates a tiled ground mesh
  98230. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98231. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98232. * * 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
  98233. * * 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
  98234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98235. * @param name defines the name of the mesh
  98236. * @param options defines the options used to create the mesh
  98237. * @param scene defines the hosting scene
  98238. * @returns the tiled ground mesh
  98239. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98240. */
  98241. static CreateTiledGround(name: string, options: {
  98242. xmin: number;
  98243. zmin: number;
  98244. xmax: number;
  98245. zmax: number;
  98246. subdivisions?: {
  98247. w: number;
  98248. h: number;
  98249. };
  98250. precision?: {
  98251. w: number;
  98252. h: number;
  98253. };
  98254. updatable?: boolean;
  98255. }, scene: Scene): Mesh;
  98256. /**
  98257. * Creates a ground mesh from a height map
  98258. * * The parameter `url` sets the URL of the height map image resource.
  98259. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98260. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98261. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98262. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98263. * * 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.
  98264. * * 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).
  98265. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98267. * @param name defines the name of the mesh
  98268. * @param url defines the url to the height map
  98269. * @param options defines the options used to create the mesh
  98270. * @param scene defines the hosting scene
  98271. * @returns the ground mesh
  98272. * @see https://doc.babylonjs.com/babylon101/height_map
  98273. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98274. */
  98275. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98276. width?: number;
  98277. height?: number;
  98278. subdivisions?: number;
  98279. minHeight?: number;
  98280. maxHeight?: number;
  98281. colorFilter?: Color3;
  98282. alphaFilter?: number;
  98283. updatable?: boolean;
  98284. onReady?: (mesh: GroundMesh) => void;
  98285. }, scene: Scene): GroundMesh;
  98286. }
  98287. }
  98288. declare module BABYLON {
  98289. /**
  98290. * Class containing static functions to help procedurally build meshes
  98291. */
  98292. export class TorusBuilder {
  98293. /**
  98294. * Creates a torus mesh
  98295. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98296. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98297. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98301. * @param name defines the name of the mesh
  98302. * @param options defines the options used to create the mesh
  98303. * @param scene defines the hosting scene
  98304. * @returns the torus mesh
  98305. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98306. */
  98307. static CreateTorus(name: string, options: {
  98308. diameter?: number;
  98309. thickness?: number;
  98310. tessellation?: number;
  98311. updatable?: boolean;
  98312. sideOrientation?: number;
  98313. frontUVs?: Vector4;
  98314. backUVs?: Vector4;
  98315. }, scene: any): Mesh;
  98316. }
  98317. }
  98318. declare module BABYLON {
  98319. /**
  98320. * Class containing static functions to help procedurally build meshes
  98321. */
  98322. export class CylinderBuilder {
  98323. /**
  98324. * Creates a cylinder or a cone mesh
  98325. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98326. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98327. * * 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.
  98328. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98329. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98330. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98331. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98332. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98333. * * 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).
  98334. * * 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
  98335. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98336. * * 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
  98337. * * 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.
  98338. * * If `enclose` is false, a ring surface is one element.
  98339. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98340. * * 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
  98341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98344. * @param name defines the name of the mesh
  98345. * @param options defines the options used to create the mesh
  98346. * @param scene defines the hosting scene
  98347. * @returns the cylinder mesh
  98348. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98349. */
  98350. static CreateCylinder(name: string, options: {
  98351. height?: number;
  98352. diameterTop?: number;
  98353. diameterBottom?: number;
  98354. diameter?: number;
  98355. tessellation?: number;
  98356. subdivisions?: number;
  98357. arc?: number;
  98358. faceColors?: Color4[];
  98359. faceUV?: Vector4[];
  98360. updatable?: boolean;
  98361. hasRings?: boolean;
  98362. enclose?: boolean;
  98363. sideOrientation?: number;
  98364. frontUVs?: Vector4;
  98365. backUVs?: Vector4;
  98366. }, scene: any): Mesh;
  98367. }
  98368. }
  98369. declare module BABYLON {
  98370. /**
  98371. * Manager for handling gamepads
  98372. */
  98373. export class GamepadManager {
  98374. private _scene?;
  98375. private _babylonGamepads;
  98376. private _oneGamepadConnected;
  98377. /** @hidden */
  98378. _isMonitoring: boolean;
  98379. private _gamepadEventSupported;
  98380. private _gamepadSupport;
  98381. /**
  98382. * observable to be triggered when the gamepad controller has been connected
  98383. */
  98384. onGamepadConnectedObservable: Observable<Gamepad>;
  98385. /**
  98386. * observable to be triggered when the gamepad controller has been disconnected
  98387. */
  98388. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98389. private _onGamepadConnectedEvent;
  98390. private _onGamepadDisconnectedEvent;
  98391. /**
  98392. * Initializes the gamepad manager
  98393. * @param _scene BabylonJS scene
  98394. */
  98395. constructor(_scene?: Scene | undefined);
  98396. /**
  98397. * The gamepads in the game pad manager
  98398. */
  98399. readonly gamepads: Gamepad[];
  98400. /**
  98401. * Get the gamepad controllers based on type
  98402. * @param type The type of gamepad controller
  98403. * @returns Nullable gamepad
  98404. */
  98405. getGamepadByType(type?: number): Nullable<Gamepad>;
  98406. /**
  98407. * Disposes the gamepad manager
  98408. */
  98409. dispose(): void;
  98410. private _addNewGamepad;
  98411. private _startMonitoringGamepads;
  98412. private _stopMonitoringGamepads;
  98413. /** @hidden */
  98414. _checkGamepadsStatus(): void;
  98415. private _updateGamepadObjects;
  98416. }
  98417. }
  98418. declare module BABYLON {
  98419. interface Scene {
  98420. /** @hidden */
  98421. _gamepadManager: Nullable<GamepadManager>;
  98422. /**
  98423. * Gets the gamepad manager associated with the scene
  98424. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98425. */
  98426. gamepadManager: GamepadManager;
  98427. }
  98428. /**
  98429. * Interface representing a free camera inputs manager
  98430. */
  98431. interface FreeCameraInputsManager {
  98432. /**
  98433. * Adds gamepad input support to the FreeCameraInputsManager.
  98434. * @returns the FreeCameraInputsManager
  98435. */
  98436. addGamepad(): FreeCameraInputsManager;
  98437. }
  98438. /**
  98439. * Interface representing an arc rotate camera inputs manager
  98440. */
  98441. interface ArcRotateCameraInputsManager {
  98442. /**
  98443. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98444. * @returns the camera inputs manager
  98445. */
  98446. addGamepad(): ArcRotateCameraInputsManager;
  98447. }
  98448. /**
  98449. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98450. */
  98451. export class GamepadSystemSceneComponent implements ISceneComponent {
  98452. /**
  98453. * The component name helpfull to identify the component in the list of scene components.
  98454. */
  98455. readonly name: string;
  98456. /**
  98457. * The scene the component belongs to.
  98458. */
  98459. scene: Scene;
  98460. /**
  98461. * Creates a new instance of the component for the given scene
  98462. * @param scene Defines the scene to register the component in
  98463. */
  98464. constructor(scene: Scene);
  98465. /**
  98466. * Registers the component in a given scene
  98467. */
  98468. register(): void;
  98469. /**
  98470. * Rebuilds the elements related to this component in case of
  98471. * context lost for instance.
  98472. */
  98473. rebuild(): void;
  98474. /**
  98475. * Disposes the component and the associated ressources
  98476. */
  98477. dispose(): void;
  98478. private _beforeCameraUpdate;
  98479. }
  98480. }
  98481. declare module BABYLON {
  98482. /**
  98483. * Options to modify the vr teleportation behavior.
  98484. */
  98485. export interface VRTeleportationOptions {
  98486. /**
  98487. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98488. */
  98489. floorMeshName?: string;
  98490. /**
  98491. * A list of meshes to be used as the teleportation floor. (default: empty)
  98492. */
  98493. floorMeshes?: Mesh[];
  98494. }
  98495. /**
  98496. * Options to modify the vr experience helper's behavior.
  98497. */
  98498. export interface VRExperienceHelperOptions extends WebVROptions {
  98499. /**
  98500. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98501. */
  98502. createDeviceOrientationCamera?: boolean;
  98503. /**
  98504. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98505. */
  98506. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98507. /**
  98508. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98509. */
  98510. laserToggle?: boolean;
  98511. /**
  98512. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98513. */
  98514. floorMeshes?: Mesh[];
  98515. /**
  98516. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98517. */
  98518. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98519. }
  98520. /**
  98521. * Event containing information after VR has been entered
  98522. */
  98523. export class OnAfterEnteringVRObservableEvent {
  98524. /**
  98525. * If entering vr was successful
  98526. */
  98527. success: boolean;
  98528. }
  98529. /**
  98530. * Helps to quickly add VR support to an existing scene.
  98531. * See http://doc.babylonjs.com/how_to/webvr_helper
  98532. */
  98533. export class VRExperienceHelper {
  98534. /** Options to modify the vr experience helper's behavior. */
  98535. webVROptions: VRExperienceHelperOptions;
  98536. private _scene;
  98537. private _position;
  98538. private _btnVR;
  98539. private _btnVRDisplayed;
  98540. private _webVRsupported;
  98541. private _webVRready;
  98542. private _webVRrequesting;
  98543. private _webVRpresenting;
  98544. private _hasEnteredVR;
  98545. private _fullscreenVRpresenting;
  98546. private _canvas;
  98547. private _webVRCamera;
  98548. private _vrDeviceOrientationCamera;
  98549. private _deviceOrientationCamera;
  98550. private _existingCamera;
  98551. private _onKeyDown;
  98552. private _onVrDisplayPresentChange;
  98553. private _onVRDisplayChanged;
  98554. private _onVRRequestPresentStart;
  98555. private _onVRRequestPresentComplete;
  98556. /**
  98557. * Observable raised right before entering VR.
  98558. */
  98559. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98560. /**
  98561. * Observable raised when entering VR has completed.
  98562. */
  98563. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98564. /**
  98565. * Observable raised when exiting VR.
  98566. */
  98567. onExitingVRObservable: Observable<VRExperienceHelper>;
  98568. /**
  98569. * Observable raised when controller mesh is loaded.
  98570. */
  98571. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98572. /** Return this.onEnteringVRObservable
  98573. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98574. */
  98575. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98576. /** Return this.onExitingVRObservable
  98577. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98578. */
  98579. readonly onExitingVR: Observable<VRExperienceHelper>;
  98580. /** Return this.onControllerMeshLoadedObservable
  98581. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98582. */
  98583. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98584. private _rayLength;
  98585. private _useCustomVRButton;
  98586. private _teleportationRequested;
  98587. private _teleportActive;
  98588. private _floorMeshName;
  98589. private _floorMeshesCollection;
  98590. private _rotationAllowed;
  98591. private _teleportBackwardsVector;
  98592. private _teleportationTarget;
  98593. private _isDefaultTeleportationTarget;
  98594. private _postProcessMove;
  98595. private _teleportationFillColor;
  98596. private _teleportationBorderColor;
  98597. private _rotationAngle;
  98598. private _haloCenter;
  98599. private _cameraGazer;
  98600. private _padSensibilityUp;
  98601. private _padSensibilityDown;
  98602. private _leftController;
  98603. private _rightController;
  98604. /**
  98605. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98606. */
  98607. onNewMeshSelected: Observable<AbstractMesh>;
  98608. /**
  98609. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98610. */
  98611. onNewMeshPicked: Observable<PickingInfo>;
  98612. private _circleEase;
  98613. /**
  98614. * Observable raised before camera teleportation
  98615. */
  98616. onBeforeCameraTeleport: Observable<Vector3>;
  98617. /**
  98618. * Observable raised after camera teleportation
  98619. */
  98620. onAfterCameraTeleport: Observable<Vector3>;
  98621. /**
  98622. * Observable raised when current selected mesh gets unselected
  98623. */
  98624. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98625. private _raySelectionPredicate;
  98626. /**
  98627. * To be optionaly changed by user to define custom ray selection
  98628. */
  98629. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98630. /**
  98631. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98632. */
  98633. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98634. /**
  98635. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98636. */
  98637. teleportationEnabled: boolean;
  98638. private _defaultHeight;
  98639. private _teleportationInitialized;
  98640. private _interactionsEnabled;
  98641. private _interactionsRequested;
  98642. private _displayGaze;
  98643. private _displayLaserPointer;
  98644. /**
  98645. * The mesh used to display where the user is going to teleport.
  98646. */
  98647. /**
  98648. * Sets the mesh to be used to display where the user is going to teleport.
  98649. */
  98650. teleportationTarget: Mesh;
  98651. /**
  98652. * 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
  98653. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98654. * See http://doc.babylonjs.com/resources/baking_transformations
  98655. */
  98656. gazeTrackerMesh: Mesh;
  98657. /**
  98658. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98659. */
  98660. updateGazeTrackerScale: boolean;
  98661. /**
  98662. * If the gaze trackers color should be updated when selecting meshes
  98663. */
  98664. updateGazeTrackerColor: boolean;
  98665. /**
  98666. * The gaze tracking mesh corresponding to the left controller
  98667. */
  98668. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98669. /**
  98670. * The gaze tracking mesh corresponding to the right controller
  98671. */
  98672. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98673. /**
  98674. * If the ray of the gaze should be displayed.
  98675. */
  98676. /**
  98677. * Sets if the ray of the gaze should be displayed.
  98678. */
  98679. displayGaze: boolean;
  98680. /**
  98681. * If the ray of the LaserPointer should be displayed.
  98682. */
  98683. /**
  98684. * Sets if the ray of the LaserPointer should be displayed.
  98685. */
  98686. displayLaserPointer: boolean;
  98687. /**
  98688. * The deviceOrientationCamera used as the camera when not in VR.
  98689. */
  98690. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98691. /**
  98692. * Based on the current WebVR support, returns the current VR camera used.
  98693. */
  98694. readonly currentVRCamera: Nullable<Camera>;
  98695. /**
  98696. * The webVRCamera which is used when in VR.
  98697. */
  98698. readonly webVRCamera: WebVRFreeCamera;
  98699. /**
  98700. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98701. */
  98702. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98703. private readonly _teleportationRequestInitiated;
  98704. /**
  98705. * Defines wether or not Pointer lock should be requested when switching to
  98706. * full screen.
  98707. */
  98708. requestPointerLockOnFullScreen: boolean;
  98709. /**
  98710. * Instantiates a VRExperienceHelper.
  98711. * Helps to quickly add VR support to an existing scene.
  98712. * @param scene The scene the VRExperienceHelper belongs to.
  98713. * @param webVROptions Options to modify the vr experience helper's behavior.
  98714. */
  98715. constructor(scene: Scene,
  98716. /** Options to modify the vr experience helper's behavior. */
  98717. webVROptions?: VRExperienceHelperOptions);
  98718. private _onDefaultMeshLoaded;
  98719. private _onResize;
  98720. private _onFullscreenChange;
  98721. /**
  98722. * Gets a value indicating if we are currently in VR mode.
  98723. */
  98724. readonly isInVRMode: boolean;
  98725. private onVrDisplayPresentChange;
  98726. private onVRDisplayChanged;
  98727. private moveButtonToBottomRight;
  98728. private displayVRButton;
  98729. private updateButtonVisibility;
  98730. private _cachedAngularSensibility;
  98731. /**
  98732. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98733. * Otherwise, will use the fullscreen API.
  98734. */
  98735. enterVR(): void;
  98736. /**
  98737. * Attempt to exit VR, or fullscreen.
  98738. */
  98739. exitVR(): void;
  98740. /**
  98741. * The position of the vr experience helper.
  98742. */
  98743. /**
  98744. * Sets the position of the vr experience helper.
  98745. */
  98746. position: Vector3;
  98747. /**
  98748. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  98749. */
  98750. enableInteractions(): void;
  98751. private readonly _noControllerIsActive;
  98752. private beforeRender;
  98753. private _isTeleportationFloor;
  98754. /**
  98755. * Adds a floor mesh to be used for teleportation.
  98756. * @param floorMesh the mesh to be used for teleportation.
  98757. */
  98758. addFloorMesh(floorMesh: Mesh): void;
  98759. /**
  98760. * Removes a floor mesh from being used for teleportation.
  98761. * @param floorMesh the mesh to be removed.
  98762. */
  98763. removeFloorMesh(floorMesh: Mesh): void;
  98764. /**
  98765. * Enables interactions and teleportation using the VR controllers and gaze.
  98766. * @param vrTeleportationOptions options to modify teleportation behavior.
  98767. */
  98768. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  98769. private _onNewGamepadConnected;
  98770. private _tryEnableInteractionOnController;
  98771. private _onNewGamepadDisconnected;
  98772. private _enableInteractionOnController;
  98773. private _checkTeleportWithRay;
  98774. private _checkRotate;
  98775. private _checkTeleportBackwards;
  98776. private _enableTeleportationOnController;
  98777. private _createTeleportationCircles;
  98778. private _displayTeleportationTarget;
  98779. private _hideTeleportationTarget;
  98780. private _rotateCamera;
  98781. private _moveTeleportationSelectorTo;
  98782. private _workingVector;
  98783. private _workingQuaternion;
  98784. private _workingMatrix;
  98785. /**
  98786. * Teleports the users feet to the desired location
  98787. * @param location The location where the user's feet should be placed
  98788. */
  98789. teleportCamera(location: Vector3): void;
  98790. private _convertNormalToDirectionOfRay;
  98791. private _castRayAndSelectObject;
  98792. private _notifySelectedMeshUnselected;
  98793. /**
  98794. * Sets the color of the laser ray from the vr controllers.
  98795. * @param color new color for the ray.
  98796. */
  98797. changeLaserColor(color: Color3): void;
  98798. /**
  98799. * Sets the color of the ray from the vr headsets gaze.
  98800. * @param color new color for the ray.
  98801. */
  98802. changeGazeColor(color: Color3): void;
  98803. /**
  98804. * Exits VR and disposes of the vr experience helper
  98805. */
  98806. dispose(): void;
  98807. /**
  98808. * Gets the name of the VRExperienceHelper class
  98809. * @returns "VRExperienceHelper"
  98810. */
  98811. getClassName(): string;
  98812. }
  98813. }
  98814. declare module BABYLON {
  98815. /**
  98816. * Manages an XRSession
  98817. * @see https://doc.babylonjs.com/how_to/webxr
  98818. */
  98819. export class WebXRSessionManager implements IDisposable {
  98820. private scene;
  98821. /**
  98822. * Fires every time a new xrFrame arrives which can be used to update the camera
  98823. */
  98824. onXRFrameObservable: Observable<any>;
  98825. /**
  98826. * Fires when the xr session is ended either by the device or manually done
  98827. */
  98828. onXRSessionEnded: Observable<any>;
  98829. /** @hidden */
  98830. _xrSession: XRSession;
  98831. /** @hidden */
  98832. _frameOfReference: XRFrameOfReference;
  98833. /** @hidden */
  98834. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98835. /** @hidden */
  98836. _currentXRFrame: Nullable<XRFrame>;
  98837. private _xrNavigator;
  98838. private _xrDevice;
  98839. private _tmpMatrix;
  98840. /**
  98841. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98842. * @param scene The scene which the session should be created for
  98843. */
  98844. constructor(scene: Scene);
  98845. /**
  98846. * Initializes the manager
  98847. * After initialization enterXR can be called to start an XR session
  98848. * @returns Promise which resolves after it is initialized
  98849. */
  98850. initializeAsync(): Promise<void>;
  98851. /**
  98852. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98853. * @param sessionCreationOptions xr options to create the session with
  98854. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98855. * @returns Promise which resolves after it enters XR
  98856. */
  98857. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98858. /**
  98859. * Stops the xrSession and restores the renderloop
  98860. * @returns Promise which resolves after it exits XR
  98861. */
  98862. exitXRAsync(): Promise<void>;
  98863. /**
  98864. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98865. * @param ray ray to cast into the environment
  98866. * @returns Promise which resolves with a collision point in the environment if it exists
  98867. */
  98868. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98869. /**
  98870. * Checks if a session would be supported for the creation options specified
  98871. * @param options creation options to check if they are supported
  98872. * @returns true if supported
  98873. */
  98874. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98875. /**
  98876. * @hidden
  98877. * Converts the render layer of xrSession to a render target
  98878. * @param session session to create render target for
  98879. * @param scene scene the new render target should be created for
  98880. */
  98881. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98882. /**
  98883. * Disposes of the session manager
  98884. */
  98885. dispose(): void;
  98886. }
  98887. }
  98888. declare module BABYLON {
  98889. /**
  98890. * WebXR Camera which holds the views for the xrSession
  98891. * @see https://doc.babylonjs.com/how_to/webxr
  98892. */
  98893. export class WebXRCamera extends FreeCamera {
  98894. private static _TmpMatrix;
  98895. /**
  98896. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98897. * @param name the name of the camera
  98898. * @param scene the scene to add the camera to
  98899. */
  98900. constructor(name: string, scene: Scene);
  98901. private _updateNumberOfRigCameras;
  98902. /** @hidden */
  98903. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98904. /**
  98905. * Updates the cameras position from the current pose information of the XR session
  98906. * @param xrSessionManager the session containing pose information
  98907. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98908. */
  98909. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98910. }
  98911. }
  98912. declare module BABYLON {
  98913. /**
  98914. * States of the webXR experience
  98915. */
  98916. export enum WebXRState {
  98917. /**
  98918. * Transitioning to being in XR mode
  98919. */
  98920. ENTERING_XR = 0,
  98921. /**
  98922. * Transitioning to non XR mode
  98923. */
  98924. EXITING_XR = 1,
  98925. /**
  98926. * In XR mode and presenting
  98927. */
  98928. IN_XR = 2,
  98929. /**
  98930. * Not entered XR mode
  98931. */
  98932. NOT_IN_XR = 3
  98933. }
  98934. /**
  98935. * Helper class used to enable XR
  98936. * @see https://doc.babylonjs.com/how_to/webxr
  98937. */
  98938. export class WebXRExperienceHelper implements IDisposable {
  98939. private scene;
  98940. /**
  98941. * 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
  98942. */
  98943. container: AbstractMesh;
  98944. /**
  98945. * Camera used to render xr content
  98946. */
  98947. camera: WebXRCamera;
  98948. /**
  98949. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98950. */
  98951. state: WebXRState;
  98952. private _setState;
  98953. private static _TmpVector;
  98954. /**
  98955. * Fires when the state of the experience helper has changed
  98956. */
  98957. onStateChangedObservable: Observable<WebXRState>;
  98958. /** @hidden */
  98959. _sessionManager: WebXRSessionManager;
  98960. private _nonVRCamera;
  98961. private _originalSceneAutoClear;
  98962. private _supported;
  98963. /**
  98964. * Creates the experience helper
  98965. * @param scene the scene to attach the experience helper to
  98966. * @returns a promise for the experience helper
  98967. */
  98968. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98969. /**
  98970. * Creates a WebXRExperienceHelper
  98971. * @param scene The scene the helper should be created in
  98972. */
  98973. private constructor();
  98974. /**
  98975. * Exits XR mode and returns the scene to its original state
  98976. * @returns promise that resolves after xr mode has exited
  98977. */
  98978. exitXRAsync(): Promise<void>;
  98979. /**
  98980. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98981. * @param sessionCreationOptions options for the XR session
  98982. * @param frameOfReference frame of reference of the XR session
  98983. * @returns promise that resolves after xr mode has entered
  98984. */
  98985. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98986. /**
  98987. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98988. * @param ray ray to cast into the environment
  98989. * @returns Promise which resolves with a collision point in the environment if it exists
  98990. */
  98991. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98992. /**
  98993. * Updates the global position of the camera by moving the camera's container
  98994. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98995. * @param position The desired global position of the camera
  98996. */
  98997. setPositionOfCameraUsingContainer(position: Vector3): void;
  98998. /**
  98999. * Rotates the xr camera by rotating the camera's container around the camera's position
  99000. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99001. * @param rotation the desired quaternion rotation to apply to the camera
  99002. */
  99003. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99004. /**
  99005. * Checks if the creation options are supported by the xr session
  99006. * @param options creation options
  99007. * @returns true if supported
  99008. */
  99009. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99010. /**
  99011. * Disposes of the experience helper
  99012. */
  99013. dispose(): void;
  99014. }
  99015. }
  99016. declare module BABYLON {
  99017. /**
  99018. * Button which can be used to enter a different mode of XR
  99019. */
  99020. export class WebXREnterExitUIButton {
  99021. /** button element */
  99022. element: HTMLElement;
  99023. /** XR initialization options for the button */
  99024. initializationOptions: XRSessionCreationOptions;
  99025. /**
  99026. * Creates a WebXREnterExitUIButton
  99027. * @param element button element
  99028. * @param initializationOptions XR initialization options for the button
  99029. */
  99030. constructor(
  99031. /** button element */
  99032. element: HTMLElement,
  99033. /** XR initialization options for the button */
  99034. initializationOptions: XRSessionCreationOptions);
  99035. /**
  99036. * Overwritable function which can be used to update the button's visuals when the state changes
  99037. * @param activeButton the current active button in the UI
  99038. */
  99039. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99040. }
  99041. /**
  99042. * Options to create the webXR UI
  99043. */
  99044. export class WebXREnterExitUIOptions {
  99045. /**
  99046. * Context to enter xr with
  99047. */
  99048. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99049. /**
  99050. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99051. */
  99052. customButtons?: Array<WebXREnterExitUIButton>;
  99053. }
  99054. /**
  99055. * UI to allow the user to enter/exit XR mode
  99056. */
  99057. export class WebXREnterExitUI implements IDisposable {
  99058. private scene;
  99059. private _overlay;
  99060. private _buttons;
  99061. private _activeButton;
  99062. /**
  99063. * Fired every time the active button is changed.
  99064. *
  99065. * When xr is entered via a button that launches xr that button will be the callback parameter
  99066. *
  99067. * When exiting xr the callback parameter will be null)
  99068. */
  99069. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99070. /**
  99071. * Creates UI to allow the user to enter/exit XR mode
  99072. * @param scene the scene to add the ui to
  99073. * @param helper the xr experience helper to enter/exit xr with
  99074. * @param options options to configure the UI
  99075. * @returns the created ui
  99076. */
  99077. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99078. private constructor();
  99079. private _updateButtons;
  99080. /**
  99081. * Disposes of the object
  99082. */
  99083. dispose(): void;
  99084. }
  99085. }
  99086. declare module BABYLON {
  99087. /**
  99088. * Represents an XR input
  99089. */
  99090. export class WebXRController {
  99091. /**
  99092. * 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
  99093. */
  99094. grip?: AbstractMesh;
  99095. /**
  99096. * Pointer which can be used to select objects or attach a visible laser to
  99097. */
  99098. pointer: AbstractMesh;
  99099. /**
  99100. * Creates the controller
  99101. * @see https://doc.babylonjs.com/how_to/webxr
  99102. * @param scene the scene which the controller should be associated to
  99103. */
  99104. constructor(scene: Scene);
  99105. /**
  99106. * Disposes of the object
  99107. */
  99108. dispose(): void;
  99109. }
  99110. /**
  99111. * XR input used to track XR inputs such as controllers/rays
  99112. */
  99113. export class WebXRInput implements IDisposable {
  99114. private helper;
  99115. /**
  99116. * XR controllers being tracked
  99117. */
  99118. controllers: Array<WebXRController>;
  99119. private _tmpMatrix;
  99120. private _frameObserver;
  99121. /**
  99122. * Initializes the WebXRInput
  99123. * @param helper experience helper which the input should be created for
  99124. */
  99125. constructor(helper: WebXRExperienceHelper);
  99126. /**
  99127. * Disposes of the object
  99128. */
  99129. dispose(): void;
  99130. }
  99131. }
  99132. declare module BABYLON {
  99133. /**
  99134. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99135. */
  99136. export class WebXRManagedOutputCanvas implements IDisposable {
  99137. private _canvas;
  99138. /**
  99139. * xrpresent context of the canvas which can be used to display/mirror xr content
  99140. */
  99141. canvasContext: Nullable<WebGLRenderingContext>;
  99142. /**
  99143. * Initializes the canvas to be added/removed upon entering/exiting xr
  99144. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99145. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99146. */
  99147. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99148. /**
  99149. * Disposes of the object
  99150. */
  99151. dispose(): void;
  99152. private _setManagedOutputCanvas;
  99153. private _addCanvas;
  99154. private _removeCanvas;
  99155. }
  99156. }
  99157. declare module BABYLON {
  99158. /**
  99159. * Contains an array of blocks representing the octree
  99160. */
  99161. export interface IOctreeContainer<T> {
  99162. /**
  99163. * Blocks within the octree
  99164. */
  99165. blocks: Array<OctreeBlock<T>>;
  99166. }
  99167. /**
  99168. * Class used to store a cell in an octree
  99169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99170. */
  99171. export class OctreeBlock<T> {
  99172. /**
  99173. * Gets the content of the current block
  99174. */
  99175. entries: T[];
  99176. /**
  99177. * Gets the list of block children
  99178. */
  99179. blocks: Array<OctreeBlock<T>>;
  99180. private _depth;
  99181. private _maxDepth;
  99182. private _capacity;
  99183. private _minPoint;
  99184. private _maxPoint;
  99185. private _boundingVectors;
  99186. private _creationFunc;
  99187. /**
  99188. * Creates a new block
  99189. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99190. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99191. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99192. * @param depth defines the current depth of this block in the octree
  99193. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99194. * @param creationFunc defines a callback to call when an element is added to the block
  99195. */
  99196. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99197. /**
  99198. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99199. */
  99200. readonly capacity: number;
  99201. /**
  99202. * Gets the minimum vector (in world space) of the block's bounding box
  99203. */
  99204. readonly minPoint: Vector3;
  99205. /**
  99206. * Gets the maximum vector (in world space) of the block's bounding box
  99207. */
  99208. readonly maxPoint: Vector3;
  99209. /**
  99210. * Add a new element to this block
  99211. * @param entry defines the element to add
  99212. */
  99213. addEntry(entry: T): void;
  99214. /**
  99215. * Remove an element from this block
  99216. * @param entry defines the element to remove
  99217. */
  99218. removeEntry(entry: T): void;
  99219. /**
  99220. * Add an array of elements to this block
  99221. * @param entries defines the array of elements to add
  99222. */
  99223. addEntries(entries: T[]): void;
  99224. /**
  99225. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99226. * @param frustumPlanes defines the frustum planes to test
  99227. * @param selection defines the array to store current content if selection is positive
  99228. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99229. */
  99230. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99231. /**
  99232. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99233. * @param sphereCenter defines the bounding sphere center
  99234. * @param sphereRadius defines the bounding sphere radius
  99235. * @param selection defines the array to store current content if selection is positive
  99236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99237. */
  99238. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99239. /**
  99240. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99241. * @param ray defines the ray to test with
  99242. * @param selection defines the array to store current content if selection is positive
  99243. */
  99244. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99245. /**
  99246. * Subdivide the content into child blocks (this block will then be empty)
  99247. */
  99248. createInnerBlocks(): void;
  99249. /**
  99250. * @hidden
  99251. */
  99252. 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;
  99253. }
  99254. }
  99255. declare module BABYLON {
  99256. /**
  99257. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99258. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99259. */
  99260. export class Octree<T> {
  99261. /** 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.) */
  99262. maxDepth: number;
  99263. /**
  99264. * Blocks within the octree containing objects
  99265. */
  99266. blocks: Array<OctreeBlock<T>>;
  99267. /**
  99268. * Content stored in the octree
  99269. */
  99270. dynamicContent: T[];
  99271. private _maxBlockCapacity;
  99272. private _selectionContent;
  99273. private _creationFunc;
  99274. /**
  99275. * Creates a octree
  99276. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99277. * @param creationFunc function to be used to instatiate the octree
  99278. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99279. * @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.)
  99280. */
  99281. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99282. /** 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.) */
  99283. maxDepth?: number);
  99284. /**
  99285. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99286. * @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);
  99287. * @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);
  99288. * @param entries meshes to be added to the octree blocks
  99289. */
  99290. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99291. /**
  99292. * Adds a mesh to the octree
  99293. * @param entry Mesh to add to the octree
  99294. */
  99295. addMesh(entry: T): void;
  99296. /**
  99297. * Remove an element from the octree
  99298. * @param entry defines the element to remove
  99299. */
  99300. removeMesh(entry: T): void;
  99301. /**
  99302. * Selects an array of meshes within the frustum
  99303. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99304. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99305. * @returns array of meshes within the frustum
  99306. */
  99307. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99308. /**
  99309. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99310. * @param sphereCenter defines the bounding sphere center
  99311. * @param sphereRadius defines the bounding sphere radius
  99312. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99313. * @returns an array of objects that intersect the sphere
  99314. */
  99315. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99316. /**
  99317. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99318. * @param ray defines the ray to test with
  99319. * @returns array of intersected objects
  99320. */
  99321. intersectsRay(ray: Ray): SmartArray<T>;
  99322. /**
  99323. * Adds a mesh into the octree block if it intersects the block
  99324. */
  99325. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99326. /**
  99327. * Adds a submesh into the octree block if it intersects the block
  99328. */
  99329. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99330. }
  99331. }
  99332. declare module BABYLON {
  99333. interface Scene {
  99334. /**
  99335. * @hidden
  99336. * Backing Filed
  99337. */
  99338. _selectionOctree: Octree<AbstractMesh>;
  99339. /**
  99340. * Gets the octree used to boost mesh selection (picking)
  99341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99342. */
  99343. selectionOctree: Octree<AbstractMesh>;
  99344. /**
  99345. * Creates or updates the octree used to boost selection (picking)
  99346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99347. * @param maxCapacity defines the maximum capacity per leaf
  99348. * @param maxDepth defines the maximum depth of the octree
  99349. * @returns an octree of AbstractMesh
  99350. */
  99351. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99352. }
  99353. interface AbstractMesh {
  99354. /**
  99355. * @hidden
  99356. * Backing Field
  99357. */
  99358. _submeshesOctree: Octree<SubMesh>;
  99359. /**
  99360. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99361. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99362. * @param maxCapacity defines the maximum size of each block (64 by default)
  99363. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99364. * @returns the new octree
  99365. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99367. */
  99368. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99369. }
  99370. /**
  99371. * Defines the octree scene component responsible to manage any octrees
  99372. * in a given scene.
  99373. */
  99374. export class OctreeSceneComponent {
  99375. /**
  99376. * The component name helpfull to identify the component in the list of scene components.
  99377. */
  99378. readonly name: string;
  99379. /**
  99380. * The scene the component belongs to.
  99381. */
  99382. scene: Scene;
  99383. /**
  99384. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99385. */
  99386. readonly checksIsEnabled: boolean;
  99387. /**
  99388. * Creates a new instance of the component for the given scene
  99389. * @param scene Defines the scene to register the component in
  99390. */
  99391. constructor(scene: Scene);
  99392. /**
  99393. * Registers the component in a given scene
  99394. */
  99395. register(): void;
  99396. /**
  99397. * Return the list of active meshes
  99398. * @returns the list of active meshes
  99399. */
  99400. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99401. /**
  99402. * Return the list of active sub meshes
  99403. * @param mesh The mesh to get the candidates sub meshes from
  99404. * @returns the list of active sub meshes
  99405. */
  99406. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99407. private _tempRay;
  99408. /**
  99409. * Return the list of sub meshes intersecting with a given local ray
  99410. * @param mesh defines the mesh to find the submesh for
  99411. * @param localRay defines the ray in local space
  99412. * @returns the list of intersecting sub meshes
  99413. */
  99414. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99415. /**
  99416. * Return the list of sub meshes colliding with a collider
  99417. * @param mesh defines the mesh to find the submesh for
  99418. * @param collider defines the collider to evaluate the collision against
  99419. * @returns the list of colliding sub meshes
  99420. */
  99421. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99422. /**
  99423. * Rebuilds the elements related to this component in case of
  99424. * context lost for instance.
  99425. */
  99426. rebuild(): void;
  99427. /**
  99428. * Disposes the component and the associated ressources.
  99429. */
  99430. dispose(): void;
  99431. }
  99432. }
  99433. declare module BABYLON {
  99434. /**
  99435. * Renders a layer on top of an existing scene
  99436. */
  99437. export class UtilityLayerRenderer implements IDisposable {
  99438. /** the original scene that will be rendered on top of */
  99439. originalScene: Scene;
  99440. private _pointerCaptures;
  99441. private _lastPointerEvents;
  99442. private static _DefaultUtilityLayer;
  99443. private static _DefaultKeepDepthUtilityLayer;
  99444. private _sharedGizmoLight;
  99445. /**
  99446. * @hidden
  99447. * Light which used by gizmos to get light shading
  99448. */
  99449. _getSharedGizmoLight(): HemisphericLight;
  99450. /**
  99451. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99452. */
  99453. pickUtilitySceneFirst: boolean;
  99454. /**
  99455. * 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)
  99456. */
  99457. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99458. /**
  99459. * 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)
  99460. */
  99461. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99462. /**
  99463. * The scene that is rendered on top of the original scene
  99464. */
  99465. utilityLayerScene: Scene;
  99466. /**
  99467. * If the utility layer should automatically be rendered on top of existing scene
  99468. */
  99469. shouldRender: boolean;
  99470. /**
  99471. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99472. */
  99473. onlyCheckPointerDownEvents: boolean;
  99474. /**
  99475. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99476. */
  99477. processAllEvents: boolean;
  99478. /**
  99479. * Observable raised when the pointer move from the utility layer scene to the main scene
  99480. */
  99481. onPointerOutObservable: Observable<number>;
  99482. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99483. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99484. private _afterRenderObserver;
  99485. private _sceneDisposeObserver;
  99486. private _originalPointerObserver;
  99487. /**
  99488. * Instantiates a UtilityLayerRenderer
  99489. * @param originalScene the original scene that will be rendered on top of
  99490. * @param handleEvents boolean indicating if the utility layer should handle events
  99491. */
  99492. constructor(
  99493. /** the original scene that will be rendered on top of */
  99494. originalScene: Scene, handleEvents?: boolean);
  99495. private _notifyObservers;
  99496. /**
  99497. * Renders the utility layers scene on top of the original scene
  99498. */
  99499. render(): void;
  99500. /**
  99501. * Disposes of the renderer
  99502. */
  99503. dispose(): void;
  99504. private _updateCamera;
  99505. }
  99506. }
  99507. declare module BABYLON {
  99508. /**
  99509. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99510. */
  99511. export class Gizmo implements IDisposable {
  99512. /** The utility layer the gizmo will be added to */
  99513. gizmoLayer: UtilityLayerRenderer;
  99514. /**
  99515. * The root mesh of the gizmo
  99516. */
  99517. _rootMesh: Mesh;
  99518. private _attachedMesh;
  99519. /**
  99520. * Ratio for the scale of the gizmo (Default: 1)
  99521. */
  99522. scaleRatio: number;
  99523. private _tmpMatrix;
  99524. /**
  99525. * If a custom mesh has been set (Default: false)
  99526. */
  99527. protected _customMeshSet: boolean;
  99528. /**
  99529. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99530. * * When set, interactions will be enabled
  99531. */
  99532. attachedMesh: Nullable<AbstractMesh>;
  99533. /**
  99534. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99535. * @param mesh The mesh to replace the default mesh of the gizmo
  99536. */
  99537. setCustomMesh(mesh: Mesh): void;
  99538. /**
  99539. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99540. */
  99541. updateGizmoRotationToMatchAttachedMesh: boolean;
  99542. /**
  99543. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99544. */
  99545. updateGizmoPositionToMatchAttachedMesh: boolean;
  99546. /**
  99547. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99548. */
  99549. protected _updateScale: boolean;
  99550. protected _interactionsEnabled: boolean;
  99551. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99552. private _beforeRenderObserver;
  99553. /**
  99554. * Creates a gizmo
  99555. * @param gizmoLayer The utility layer the gizmo will be added to
  99556. */
  99557. constructor(
  99558. /** The utility layer the gizmo will be added to */
  99559. gizmoLayer?: UtilityLayerRenderer);
  99560. private _tempVector;
  99561. /**
  99562. * @hidden
  99563. * Updates the gizmo to match the attached mesh's position/rotation
  99564. */
  99565. protected _update(): void;
  99566. /**
  99567. * Disposes of the gizmo
  99568. */
  99569. dispose(): void;
  99570. }
  99571. }
  99572. declare module BABYLON {
  99573. /**
  99574. * Single axis drag gizmo
  99575. */
  99576. export class AxisDragGizmo extends Gizmo {
  99577. /**
  99578. * Drag behavior responsible for the gizmos dragging interactions
  99579. */
  99580. dragBehavior: PointerDragBehavior;
  99581. private _pointerObserver;
  99582. /**
  99583. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99584. */
  99585. snapDistance: number;
  99586. /**
  99587. * Event that fires each time the gizmo snaps to a new location.
  99588. * * snapDistance is the the change in distance
  99589. */
  99590. onSnapObservable: Observable<{
  99591. snapDistance: number;
  99592. }>;
  99593. /** @hidden */
  99594. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99595. /** @hidden */
  99596. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99597. /**
  99598. * Creates an AxisDragGizmo
  99599. * @param gizmoLayer The utility layer the gizmo will be added to
  99600. * @param dragAxis The axis which the gizmo will be able to drag on
  99601. * @param color The color of the gizmo
  99602. */
  99603. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99604. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99605. /**
  99606. * Disposes of the gizmo
  99607. */
  99608. dispose(): void;
  99609. }
  99610. }
  99611. declare module BABYLON.Debug {
  99612. /**
  99613. * The Axes viewer will show 3 axes in a specific point in space
  99614. */
  99615. export class AxesViewer {
  99616. private _xAxis;
  99617. private _yAxis;
  99618. private _zAxis;
  99619. private _scaleLinesFactor;
  99620. private _instanced;
  99621. /**
  99622. * Gets the hosting scene
  99623. */
  99624. scene: Scene;
  99625. /**
  99626. * Gets or sets a number used to scale line length
  99627. */
  99628. scaleLines: number;
  99629. /** Gets the node hierarchy used to render x-axis */
  99630. readonly xAxis: TransformNode;
  99631. /** Gets the node hierarchy used to render y-axis */
  99632. readonly yAxis: TransformNode;
  99633. /** Gets the node hierarchy used to render z-axis */
  99634. readonly zAxis: TransformNode;
  99635. /**
  99636. * Creates a new AxesViewer
  99637. * @param scene defines the hosting scene
  99638. * @param scaleLines defines a number used to scale line length (1 by default)
  99639. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99640. * @param xAxis defines the node hierarchy used to render the x-axis
  99641. * @param yAxis defines the node hierarchy used to render the y-axis
  99642. * @param zAxis defines the node hierarchy used to render the z-axis
  99643. */
  99644. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99645. /**
  99646. * Force the viewer to update
  99647. * @param position defines the position of the viewer
  99648. * @param xaxis defines the x axis of the viewer
  99649. * @param yaxis defines the y axis of the viewer
  99650. * @param zaxis defines the z axis of the viewer
  99651. */
  99652. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99653. /**
  99654. * Creates an instance of this axes viewer.
  99655. * @returns a new axes viewer with instanced meshes
  99656. */
  99657. createInstance(): AxesViewer;
  99658. /** Releases resources */
  99659. dispose(): void;
  99660. private static _SetRenderingGroupId;
  99661. }
  99662. }
  99663. declare module BABYLON.Debug {
  99664. /**
  99665. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99666. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99667. */
  99668. export class BoneAxesViewer extends AxesViewer {
  99669. /**
  99670. * Gets or sets the target mesh where to display the axes viewer
  99671. */
  99672. mesh: Nullable<Mesh>;
  99673. /**
  99674. * Gets or sets the target bone where to display the axes viewer
  99675. */
  99676. bone: Nullable<Bone>;
  99677. /** Gets current position */
  99678. pos: Vector3;
  99679. /** Gets direction of X axis */
  99680. xaxis: Vector3;
  99681. /** Gets direction of Y axis */
  99682. yaxis: Vector3;
  99683. /** Gets direction of Z axis */
  99684. zaxis: Vector3;
  99685. /**
  99686. * Creates a new BoneAxesViewer
  99687. * @param scene defines the hosting scene
  99688. * @param bone defines the target bone
  99689. * @param mesh defines the target mesh
  99690. * @param scaleLines defines a scaling factor for line length (1 by default)
  99691. */
  99692. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99693. /**
  99694. * Force the viewer to update
  99695. */
  99696. update(): void;
  99697. /** Releases resources */
  99698. dispose(): void;
  99699. }
  99700. }
  99701. declare module BABYLON {
  99702. /**
  99703. * Interface used to define scene explorer extensibility option
  99704. */
  99705. export interface IExplorerExtensibilityOption {
  99706. /**
  99707. * Define the option label
  99708. */
  99709. label: string;
  99710. /**
  99711. * Defines the action to execute on click
  99712. */
  99713. action: (entity: any) => void;
  99714. }
  99715. /**
  99716. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99717. */
  99718. export interface IExplorerExtensibilityGroup {
  99719. /**
  99720. * Defines a predicate to test if a given type mut be extended
  99721. */
  99722. predicate: (entity: any) => boolean;
  99723. /**
  99724. * Gets the list of options added to a type
  99725. */
  99726. entries: IExplorerExtensibilityOption[];
  99727. }
  99728. /**
  99729. * Interface used to define the options to use to create the Inspector
  99730. */
  99731. export interface IInspectorOptions {
  99732. /**
  99733. * Display in overlay mode (default: false)
  99734. */
  99735. overlay?: boolean;
  99736. /**
  99737. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99738. */
  99739. globalRoot?: HTMLElement;
  99740. /**
  99741. * Display the Scene explorer
  99742. */
  99743. showExplorer?: boolean;
  99744. /**
  99745. * Display the property inspector
  99746. */
  99747. showInspector?: boolean;
  99748. /**
  99749. * Display in embed mode (both panes on the right)
  99750. */
  99751. embedMode?: boolean;
  99752. /**
  99753. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99754. */
  99755. handleResize?: boolean;
  99756. /**
  99757. * Allow the panes to popup (default: true)
  99758. */
  99759. enablePopup?: boolean;
  99760. /**
  99761. * Allow the panes to be closed by users (default: true)
  99762. */
  99763. enableClose?: boolean;
  99764. /**
  99765. * Optional list of extensibility entries
  99766. */
  99767. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99768. /**
  99769. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99770. */
  99771. inspectorURL?: string;
  99772. }
  99773. interface Scene {
  99774. /**
  99775. * @hidden
  99776. * Backing field
  99777. */
  99778. _debugLayer: DebugLayer;
  99779. /**
  99780. * Gets the debug layer (aka Inspector) associated with the scene
  99781. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99782. */
  99783. debugLayer: DebugLayer;
  99784. }
  99785. /**
  99786. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99787. * what is happening in your scene
  99788. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99789. */
  99790. export class DebugLayer {
  99791. /**
  99792. * Define the url to get the inspector script from.
  99793. * By default it uses the babylonjs CDN.
  99794. * @ignoreNaming
  99795. */
  99796. static InspectorURL: string;
  99797. private _scene;
  99798. private BJSINSPECTOR;
  99799. /**
  99800. * Observable triggered when a property is changed through the inspector.
  99801. */
  99802. onPropertyChangedObservable: Observable<{
  99803. object: any;
  99804. property: string;
  99805. value: any;
  99806. initialValue: any;
  99807. }>;
  99808. /**
  99809. * Instantiates a new debug layer.
  99810. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99811. * what is happening in your scene
  99812. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99813. * @param scene Defines the scene to inspect
  99814. */
  99815. constructor(scene: Scene);
  99816. /** Creates the inspector window. */
  99817. private _createInspector;
  99818. /**
  99819. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99820. * @param entity defines the entity to select
  99821. * @param lineContainerTitle defines the specific block to highlight
  99822. */
  99823. select(entity: any, lineContainerTitle?: string): void;
  99824. /** Get the inspector from bundle or global */
  99825. private _getGlobalInspector;
  99826. /**
  99827. * Get if the inspector is visible or not.
  99828. * @returns true if visible otherwise, false
  99829. */
  99830. isVisible(): boolean;
  99831. /**
  99832. * Hide the inspector and close its window.
  99833. */
  99834. hide(): void;
  99835. /**
  99836. * Launch the debugLayer.
  99837. * @param config Define the configuration of the inspector
  99838. * @return a promise fulfilled when the debug layer is visible
  99839. */
  99840. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99841. }
  99842. }
  99843. declare module BABYLON {
  99844. /**
  99845. * Class containing static functions to help procedurally build meshes
  99846. */
  99847. export class BoxBuilder {
  99848. /**
  99849. * Creates a box mesh
  99850. * * The parameter `size` sets the size (float) of each box side (default 1)
  99851. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99852. * * 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)
  99853. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99857. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99858. * @param name defines the name of the mesh
  99859. * @param options defines the options used to create the mesh
  99860. * @param scene defines the hosting scene
  99861. * @returns the box mesh
  99862. */
  99863. static CreateBox(name: string, options: {
  99864. size?: number;
  99865. width?: number;
  99866. height?: number;
  99867. depth?: number;
  99868. faceUV?: Vector4[];
  99869. faceColors?: Color4[];
  99870. sideOrientation?: number;
  99871. frontUVs?: Vector4;
  99872. backUVs?: Vector4;
  99873. updatable?: boolean;
  99874. }, scene?: Nullable<Scene>): Mesh;
  99875. }
  99876. }
  99877. declare module BABYLON {
  99878. /**
  99879. * Class containing static functions to help procedurally build meshes
  99880. */
  99881. export class SphereBuilder {
  99882. /**
  99883. * Creates a sphere mesh
  99884. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99885. * * 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`)
  99886. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99887. * * 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
  99888. * * 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)
  99889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99892. * @param name defines the name of the mesh
  99893. * @param options defines the options used to create the mesh
  99894. * @param scene defines the hosting scene
  99895. * @returns the sphere mesh
  99896. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99897. */
  99898. static CreateSphere(name: string, options: {
  99899. segments?: number;
  99900. diameter?: number;
  99901. diameterX?: number;
  99902. diameterY?: number;
  99903. diameterZ?: number;
  99904. arc?: number;
  99905. slice?: number;
  99906. sideOrientation?: number;
  99907. frontUVs?: Vector4;
  99908. backUVs?: Vector4;
  99909. updatable?: boolean;
  99910. }, scene: any): Mesh;
  99911. }
  99912. }
  99913. declare module BABYLON.Debug {
  99914. /**
  99915. * Used to show the physics impostor around the specific mesh
  99916. */
  99917. export class PhysicsViewer {
  99918. /** @hidden */
  99919. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99920. /** @hidden */
  99921. protected _meshes: Array<Nullable<AbstractMesh>>;
  99922. /** @hidden */
  99923. protected _scene: Nullable<Scene>;
  99924. /** @hidden */
  99925. protected _numMeshes: number;
  99926. /** @hidden */
  99927. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99928. private _renderFunction;
  99929. private _utilityLayer;
  99930. private _debugBoxMesh;
  99931. private _debugSphereMesh;
  99932. private _debugMaterial;
  99933. private _debugMeshMeshes;
  99934. /**
  99935. * Creates a new PhysicsViewer
  99936. * @param scene defines the hosting scene
  99937. */
  99938. constructor(scene: Scene);
  99939. /** @hidden */
  99940. protected _updateDebugMeshes(): void;
  99941. /**
  99942. * Renders a specified physic impostor
  99943. * @param impostor defines the impostor to render
  99944. * @param targetMesh defines the mesh represented by the impostor
  99945. * @returns the new debug mesh used to render the impostor
  99946. */
  99947. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  99948. /**
  99949. * Hides a specified physic impostor
  99950. * @param impostor defines the impostor to hide
  99951. */
  99952. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99953. private _getDebugMaterial;
  99954. private _getDebugBoxMesh;
  99955. private _getDebugSphereMesh;
  99956. private _getDebugMeshMesh;
  99957. private _getDebugMesh;
  99958. /** Releases all resources */
  99959. dispose(): void;
  99960. }
  99961. }
  99962. declare module BABYLON {
  99963. /**
  99964. * Class containing static functions to help procedurally build meshes
  99965. */
  99966. export class LinesBuilder {
  99967. /**
  99968. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  99969. * * 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
  99970. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  99971. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  99972. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  99973. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  99974. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  99975. * * 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
  99976. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  99977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  99979. * @param name defines the name of the new line system
  99980. * @param options defines the options used to create the line system
  99981. * @param scene defines the hosting scene
  99982. * @returns a new line system mesh
  99983. */
  99984. static CreateLineSystem(name: string, options: {
  99985. lines: Vector3[][];
  99986. updatable?: boolean;
  99987. instance?: Nullable<LinesMesh>;
  99988. colors?: Nullable<Color4[][]>;
  99989. useVertexAlpha?: boolean;
  99990. }, scene: Nullable<Scene>): LinesMesh;
  99991. /**
  99992. * Creates a line mesh
  99993. * 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
  99994. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  99995. * * The parameter `points` is an array successive Vector3
  99996. * * 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
  99997. * * The optional parameter `colors` is an array of successive Color4, one per line point
  99998. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  99999. * * When updating an instance, remember that only point positions can change, not the number of points
  100000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100002. * @param name defines the name of the new line system
  100003. * @param options defines the options used to create the line system
  100004. * @param scene defines the hosting scene
  100005. * @returns a new line mesh
  100006. */
  100007. static CreateLines(name: string, options: {
  100008. points: Vector3[];
  100009. updatable?: boolean;
  100010. instance?: Nullable<LinesMesh>;
  100011. colors?: Color4[];
  100012. useVertexAlpha?: boolean;
  100013. }, scene?: Nullable<Scene>): LinesMesh;
  100014. /**
  100015. * Creates a dashed line mesh
  100016. * * 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
  100017. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100018. * * The parameter `points` is an array successive Vector3
  100019. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100020. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100021. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100022. * * 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
  100023. * * When updating an instance, remember that only point positions can change, not the number of points
  100024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100025. * @param name defines the name of the mesh
  100026. * @param options defines the options used to create the mesh
  100027. * @param scene defines the hosting scene
  100028. * @returns the dashed line mesh
  100029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100030. */
  100031. static CreateDashedLines(name: string, options: {
  100032. points: Vector3[];
  100033. dashSize?: number;
  100034. gapSize?: number;
  100035. dashNb?: number;
  100036. updatable?: boolean;
  100037. instance?: LinesMesh;
  100038. }, scene?: Nullable<Scene>): LinesMesh;
  100039. }
  100040. }
  100041. declare module BABYLON {
  100042. /**
  100043. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100044. * in order to better appreciate the issue one might have.
  100045. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100046. */
  100047. export class RayHelper {
  100048. /**
  100049. * Defines the ray we are currently tryin to visualize.
  100050. */
  100051. ray: Nullable<Ray>;
  100052. private _renderPoints;
  100053. private _renderLine;
  100054. private _renderFunction;
  100055. private _scene;
  100056. private _updateToMeshFunction;
  100057. private _attachedToMesh;
  100058. private _meshSpaceDirection;
  100059. private _meshSpaceOrigin;
  100060. /**
  100061. * Helper function to create a colored helper in a scene in one line.
  100062. * @param ray Defines the ray we are currently tryin to visualize
  100063. * @param scene Defines the scene the ray is used in
  100064. * @param color Defines the color we want to see the ray in
  100065. * @returns The newly created ray helper.
  100066. */
  100067. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100068. /**
  100069. * Instantiate a new ray helper.
  100070. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100071. * in order to better appreciate the issue one might have.
  100072. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100073. * @param ray Defines the ray we are currently tryin to visualize
  100074. */
  100075. constructor(ray: Ray);
  100076. /**
  100077. * Shows the ray we are willing to debug.
  100078. * @param scene Defines the scene the ray needs to be rendered in
  100079. * @param color Defines the color the ray needs to be rendered in
  100080. */
  100081. show(scene: Scene, color?: Color3): void;
  100082. /**
  100083. * Hides the ray we are debugging.
  100084. */
  100085. hide(): void;
  100086. private _render;
  100087. /**
  100088. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100089. * @param mesh Defines the mesh we want the helper attached to
  100090. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100091. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100092. * @param length Defines the length of the ray
  100093. */
  100094. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100095. /**
  100096. * Detach the ray helper from the mesh it has previously been attached to.
  100097. */
  100098. detachFromMesh(): void;
  100099. private _updateToMesh;
  100100. /**
  100101. * Dispose the helper and release its associated resources.
  100102. */
  100103. dispose(): void;
  100104. }
  100105. }
  100106. declare module BABYLON.Debug {
  100107. /**
  100108. * Class used to render a debug view of a given skeleton
  100109. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100110. */
  100111. export class SkeletonViewer {
  100112. /** defines the skeleton to render */
  100113. skeleton: Skeleton;
  100114. /** defines the mesh attached to the skeleton */
  100115. mesh: AbstractMesh;
  100116. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100117. autoUpdateBonesMatrices: boolean;
  100118. /** defines the rendering group id to use with the viewer */
  100119. renderingGroupId: number;
  100120. /** Gets or sets the color used to render the skeleton */
  100121. color: Color3;
  100122. private _scene;
  100123. private _debugLines;
  100124. private _debugMesh;
  100125. private _isEnabled;
  100126. private _renderFunction;
  100127. private _utilityLayer;
  100128. /**
  100129. * Returns the mesh used to render the bones
  100130. */
  100131. readonly debugMesh: Nullable<LinesMesh>;
  100132. /**
  100133. * Creates a new SkeletonViewer
  100134. * @param skeleton defines the skeleton to render
  100135. * @param mesh defines the mesh attached to the skeleton
  100136. * @param scene defines the hosting scene
  100137. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100138. * @param renderingGroupId defines the rendering group id to use with the viewer
  100139. */
  100140. constructor(
  100141. /** defines the skeleton to render */
  100142. skeleton: Skeleton,
  100143. /** defines the mesh attached to the skeleton */
  100144. mesh: AbstractMesh, scene: Scene,
  100145. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100146. autoUpdateBonesMatrices?: boolean,
  100147. /** defines the rendering group id to use with the viewer */
  100148. renderingGroupId?: number);
  100149. /** Gets or sets a boolean indicating if the viewer is enabled */
  100150. isEnabled: boolean;
  100151. private _getBonePosition;
  100152. private _getLinesForBonesWithLength;
  100153. private _getLinesForBonesNoLength;
  100154. /** Update the viewer to sync with current skeleton state */
  100155. update(): void;
  100156. /** Release associated resources */
  100157. dispose(): void;
  100158. }
  100159. }
  100160. declare module BABYLON {
  100161. /**
  100162. * Options to create the null engine
  100163. */
  100164. export class NullEngineOptions {
  100165. /**
  100166. * Render width (Default: 512)
  100167. */
  100168. renderWidth: number;
  100169. /**
  100170. * Render height (Default: 256)
  100171. */
  100172. renderHeight: number;
  100173. /**
  100174. * Texture size (Default: 512)
  100175. */
  100176. textureSize: number;
  100177. /**
  100178. * If delta time between frames should be constant
  100179. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100180. */
  100181. deterministicLockstep: boolean;
  100182. /**
  100183. * Maximum about of steps between frames (Default: 4)
  100184. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100185. */
  100186. lockstepMaxSteps: number;
  100187. }
  100188. /**
  100189. * The null engine class provides support for headless version of babylon.js.
  100190. * This can be used in server side scenario or for testing purposes
  100191. */
  100192. export class NullEngine extends Engine {
  100193. private _options;
  100194. /**
  100195. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100196. */
  100197. isDeterministicLockStep(): boolean;
  100198. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100199. getLockstepMaxSteps(): number;
  100200. /**
  100201. * Sets hardware scaling, used to save performance if needed
  100202. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100203. */
  100204. getHardwareScalingLevel(): number;
  100205. constructor(options?: NullEngineOptions);
  100206. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100207. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100208. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100209. getRenderWidth(useScreen?: boolean): number;
  100210. getRenderHeight(useScreen?: boolean): number;
  100211. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100212. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100213. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100214. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100215. bindSamplers(effect: Effect): void;
  100216. enableEffect(effect: Effect): void;
  100217. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100218. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100219. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100220. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100221. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100222. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100223. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100224. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100225. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100226. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100227. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100228. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100229. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100230. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100231. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100232. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100233. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100234. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100235. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100236. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100237. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100238. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100239. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100240. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100241. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100242. bindBuffers(vertexBuffers: {
  100243. [key: string]: VertexBuffer;
  100244. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100245. wipeCaches(bruteForce?: boolean): void;
  100246. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100247. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100248. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100249. /** @hidden */
  100250. _createTexture(): WebGLTexture;
  100251. /** @hidden */
  100252. _releaseTexture(texture: InternalTexture): void;
  100253. 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;
  100254. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100255. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100256. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100257. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100258. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100259. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100260. areAllEffectsReady(): boolean;
  100261. /**
  100262. * @hidden
  100263. * Get the current error code of the webGL context
  100264. * @returns the error code
  100265. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100266. */
  100267. getError(): number;
  100268. /** @hidden */
  100269. _getUnpackAlignement(): number;
  100270. /** @hidden */
  100271. _unpackFlipY(value: boolean): void;
  100272. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100273. /**
  100274. * Updates a dynamic vertex buffer.
  100275. * @param vertexBuffer the vertex buffer to update
  100276. * @param data the data used to update the vertex buffer
  100277. * @param byteOffset the byte offset of the data (optional)
  100278. * @param byteLength the byte length of the data (optional)
  100279. */
  100280. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100281. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100282. /** @hidden */
  100283. _bindTexture(channel: number, texture: InternalTexture): void;
  100284. /** @hidden */
  100285. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100286. releaseEffects(): void;
  100287. displayLoadingUI(): void;
  100288. hideLoadingUI(): void;
  100289. /** @hidden */
  100290. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100291. /** @hidden */
  100292. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100293. /** @hidden */
  100294. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100295. /** @hidden */
  100296. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100297. }
  100298. }
  100299. declare module BABYLON {
  100300. /** @hidden */
  100301. export class _OcclusionDataStorage {
  100302. /** @hidden */
  100303. occlusionInternalRetryCounter: number;
  100304. /** @hidden */
  100305. isOcclusionQueryInProgress: boolean;
  100306. /** @hidden */
  100307. isOccluded: boolean;
  100308. /** @hidden */
  100309. occlusionRetryCount: number;
  100310. /** @hidden */
  100311. occlusionType: number;
  100312. /** @hidden */
  100313. occlusionQueryAlgorithmType: number;
  100314. }
  100315. interface Engine {
  100316. /**
  100317. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100318. * @return the new query
  100319. */
  100320. createQuery(): WebGLQuery;
  100321. /**
  100322. * Delete and release a webGL query
  100323. * @param query defines the query to delete
  100324. * @return the current engine
  100325. */
  100326. deleteQuery(query: WebGLQuery): Engine;
  100327. /**
  100328. * Check if a given query has resolved and got its value
  100329. * @param query defines the query to check
  100330. * @returns true if the query got its value
  100331. */
  100332. isQueryResultAvailable(query: WebGLQuery): boolean;
  100333. /**
  100334. * Gets the value of a given query
  100335. * @param query defines the query to check
  100336. * @returns the value of the query
  100337. */
  100338. getQueryResult(query: WebGLQuery): number;
  100339. /**
  100340. * Initiates an occlusion query
  100341. * @param algorithmType defines the algorithm to use
  100342. * @param query defines the query to use
  100343. * @returns the current engine
  100344. * @see http://doc.babylonjs.com/features/occlusionquery
  100345. */
  100346. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100347. /**
  100348. * Ends an occlusion query
  100349. * @see http://doc.babylonjs.com/features/occlusionquery
  100350. * @param algorithmType defines the algorithm to use
  100351. * @returns the current engine
  100352. */
  100353. endOcclusionQuery(algorithmType: number): Engine;
  100354. /**
  100355. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100356. * Please note that only one query can be issued at a time
  100357. * @returns a time token used to track the time span
  100358. */
  100359. startTimeQuery(): Nullable<_TimeToken>;
  100360. /**
  100361. * Ends a time query
  100362. * @param token defines the token used to measure the time span
  100363. * @returns the time spent (in ns)
  100364. */
  100365. endTimeQuery(token: _TimeToken): int;
  100366. /** @hidden */
  100367. _currentNonTimestampToken: Nullable<_TimeToken>;
  100368. /** @hidden */
  100369. _createTimeQuery(): WebGLQuery;
  100370. /** @hidden */
  100371. _deleteTimeQuery(query: WebGLQuery): void;
  100372. /** @hidden */
  100373. _getGlAlgorithmType(algorithmType: number): number;
  100374. /** @hidden */
  100375. _getTimeQueryResult(query: WebGLQuery): any;
  100376. /** @hidden */
  100377. _getTimeQueryAvailability(query: WebGLQuery): any;
  100378. }
  100379. interface AbstractMesh {
  100380. /**
  100381. * Backing filed
  100382. * @hidden
  100383. */
  100384. __occlusionDataStorage: _OcclusionDataStorage;
  100385. /**
  100386. * Access property
  100387. * @hidden
  100388. */
  100389. _occlusionDataStorage: _OcclusionDataStorage;
  100390. /**
  100391. * 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.
  100392. * The default value is -1 which means don't break the query and wait till the result
  100393. * @see http://doc.babylonjs.com/features/occlusionquery
  100394. */
  100395. occlusionRetryCount: number;
  100396. /**
  100397. * 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:
  100398. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100399. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100400. * * 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.
  100401. * @see http://doc.babylonjs.com/features/occlusionquery
  100402. */
  100403. occlusionType: number;
  100404. /**
  100405. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100406. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100407. * * 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.
  100408. * @see http://doc.babylonjs.com/features/occlusionquery
  100409. */
  100410. occlusionQueryAlgorithmType: number;
  100411. /**
  100412. * 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
  100413. * @see http://doc.babylonjs.com/features/occlusionquery
  100414. */
  100415. isOccluded: boolean;
  100416. /**
  100417. * Flag to check the progress status of the query
  100418. * @see http://doc.babylonjs.com/features/occlusionquery
  100419. */
  100420. isOcclusionQueryInProgress: boolean;
  100421. }
  100422. }
  100423. declare module BABYLON {
  100424. /** @hidden */
  100425. export var _forceTransformFeedbackToBundle: boolean;
  100426. interface Engine {
  100427. /**
  100428. * Creates a webGL transform feedback object
  100429. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100430. * @returns the webGL transform feedback object
  100431. */
  100432. createTransformFeedback(): WebGLTransformFeedback;
  100433. /**
  100434. * Delete a webGL transform feedback object
  100435. * @param value defines the webGL transform feedback object to delete
  100436. */
  100437. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100438. /**
  100439. * Bind a webGL transform feedback object to the webgl context
  100440. * @param value defines the webGL transform feedback object to bind
  100441. */
  100442. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100443. /**
  100444. * Begins a transform feedback operation
  100445. * @param usePoints defines if points or triangles must be used
  100446. */
  100447. beginTransformFeedback(usePoints: boolean): void;
  100448. /**
  100449. * Ends a transform feedback operation
  100450. */
  100451. endTransformFeedback(): void;
  100452. /**
  100453. * Specify the varyings to use with transform feedback
  100454. * @param program defines the associated webGL program
  100455. * @param value defines the list of strings representing the varying names
  100456. */
  100457. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100458. /**
  100459. * Bind a webGL buffer for a transform feedback operation
  100460. * @param value defines the webGL buffer to bind
  100461. */
  100462. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100463. }
  100464. }
  100465. declare module BABYLON {
  100466. /**
  100467. * Gather the list of clipboard event types as constants.
  100468. */
  100469. export class ClipboardEventTypes {
  100470. /**
  100471. * The clipboard event is fired when a copy command is active (pressed).
  100472. */
  100473. static readonly COPY: number;
  100474. /**
  100475. * The clipboard event is fired when a cut command is active (pressed).
  100476. */
  100477. static readonly CUT: number;
  100478. /**
  100479. * The clipboard event is fired when a paste command is active (pressed).
  100480. */
  100481. static readonly PASTE: number;
  100482. }
  100483. /**
  100484. * This class is used to store clipboard related info for the onClipboardObservable event.
  100485. */
  100486. export class ClipboardInfo {
  100487. /**
  100488. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100489. */
  100490. type: number;
  100491. /**
  100492. * Defines the related dom event
  100493. */
  100494. event: ClipboardEvent;
  100495. /**
  100496. *Creates an instance of ClipboardInfo.
  100497. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100498. * @param event Defines the related dom event
  100499. */
  100500. constructor(
  100501. /**
  100502. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100503. */
  100504. type: number,
  100505. /**
  100506. * Defines the related dom event
  100507. */
  100508. event: ClipboardEvent);
  100509. /**
  100510. * Get the clipboard event's type from the keycode.
  100511. * @param keyCode Defines the keyCode for the current keyboard event.
  100512. * @return {number}
  100513. */
  100514. static GetTypeFromCharacter(keyCode: number): number;
  100515. }
  100516. }
  100517. declare module BABYLON {
  100518. /**
  100519. * Class used to represent data loading progression
  100520. */
  100521. export class SceneLoaderProgressEvent {
  100522. /** defines if data length to load can be evaluated */
  100523. readonly lengthComputable: boolean;
  100524. /** defines the loaded data length */
  100525. readonly loaded: number;
  100526. /** defines the data length to load */
  100527. readonly total: number;
  100528. /**
  100529. * Create a new progress event
  100530. * @param lengthComputable defines if data length to load can be evaluated
  100531. * @param loaded defines the loaded data length
  100532. * @param total defines the data length to load
  100533. */
  100534. constructor(
  100535. /** defines if data length to load can be evaluated */
  100536. lengthComputable: boolean,
  100537. /** defines the loaded data length */
  100538. loaded: number,
  100539. /** defines the data length to load */
  100540. total: number);
  100541. /**
  100542. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100543. * @param event defines the source event
  100544. * @returns a new SceneLoaderProgressEvent
  100545. */
  100546. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100547. }
  100548. /**
  100549. * Interface used by SceneLoader plugins to define supported file extensions
  100550. */
  100551. export interface ISceneLoaderPluginExtensions {
  100552. /**
  100553. * Defines the list of supported extensions
  100554. */
  100555. [extension: string]: {
  100556. isBinary: boolean;
  100557. };
  100558. }
  100559. /**
  100560. * Interface used by SceneLoader plugin factory
  100561. */
  100562. export interface ISceneLoaderPluginFactory {
  100563. /**
  100564. * Defines the name of the factory
  100565. */
  100566. name: string;
  100567. /**
  100568. * Function called to create a new plugin
  100569. * @return the new plugin
  100570. */
  100571. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100572. /**
  100573. * Boolean indicating if the plugin can direct load specific data
  100574. */
  100575. canDirectLoad?: (data: string) => boolean;
  100576. }
  100577. /**
  100578. * Interface used to define a SceneLoader plugin
  100579. */
  100580. export interface ISceneLoaderPlugin {
  100581. /**
  100582. * The friendly name of this plugin.
  100583. */
  100584. name: string;
  100585. /**
  100586. * The file extensions supported by this plugin.
  100587. */
  100588. extensions: string | ISceneLoaderPluginExtensions;
  100589. /**
  100590. * Import meshes into a scene.
  100591. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100592. * @param scene The scene to import into
  100593. * @param data The data to import
  100594. * @param rootUrl The root url for scene and resources
  100595. * @param meshes The meshes array to import into
  100596. * @param particleSystems The particle systems array to import into
  100597. * @param skeletons The skeletons array to import into
  100598. * @param onError The callback when import fails
  100599. * @returns True if successful or false otherwise
  100600. */
  100601. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100602. /**
  100603. * Load into a scene.
  100604. * @param scene The scene to load into
  100605. * @param data The data to import
  100606. * @param rootUrl The root url for scene and resources
  100607. * @param onError The callback when import fails
  100608. * @returns true if successful or false otherwise
  100609. */
  100610. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100611. /**
  100612. * The callback that returns true if the data can be directly loaded.
  100613. */
  100614. canDirectLoad?: (data: string) => boolean;
  100615. /**
  100616. * The callback that allows custom handling of the root url based on the response url.
  100617. */
  100618. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100619. /**
  100620. * Load into an asset container.
  100621. * @param scene The scene to load into
  100622. * @param data The data to import
  100623. * @param rootUrl The root url for scene and resources
  100624. * @param onError The callback when import fails
  100625. * @returns The loaded asset container
  100626. */
  100627. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100628. }
  100629. /**
  100630. * Interface used to define an async SceneLoader plugin
  100631. */
  100632. export interface ISceneLoaderPluginAsync {
  100633. /**
  100634. * The friendly name of this plugin.
  100635. */
  100636. name: string;
  100637. /**
  100638. * The file extensions supported by this plugin.
  100639. */
  100640. extensions: string | ISceneLoaderPluginExtensions;
  100641. /**
  100642. * Import meshes into a scene.
  100643. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100644. * @param scene The scene to import into
  100645. * @param data The data to import
  100646. * @param rootUrl The root url for scene and resources
  100647. * @param onProgress The callback when the load progresses
  100648. * @param fileName Defines the name of the file to load
  100649. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100650. */
  100651. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100652. meshes: AbstractMesh[];
  100653. particleSystems: IParticleSystem[];
  100654. skeletons: Skeleton[];
  100655. animationGroups: AnimationGroup[];
  100656. }>;
  100657. /**
  100658. * Load into a scene.
  100659. * @param scene The scene to load into
  100660. * @param data The data to import
  100661. * @param rootUrl The root url for scene and resources
  100662. * @param onProgress The callback when the load progresses
  100663. * @param fileName Defines the name of the file to load
  100664. * @returns Nothing
  100665. */
  100666. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100667. /**
  100668. * The callback that returns true if the data can be directly loaded.
  100669. */
  100670. canDirectLoad?: (data: string) => boolean;
  100671. /**
  100672. * The callback that allows custom handling of the root url based on the response url.
  100673. */
  100674. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100675. /**
  100676. * Load into an asset container.
  100677. * @param scene The scene to load into
  100678. * @param data The data to import
  100679. * @param rootUrl The root url for scene and resources
  100680. * @param onProgress The callback when the load progresses
  100681. * @param fileName Defines the name of the file to load
  100682. * @returns The loaded asset container
  100683. */
  100684. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100685. }
  100686. /**
  100687. * Class used to load scene from various file formats using registered plugins
  100688. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100689. */
  100690. export class SceneLoader {
  100691. /**
  100692. * No logging while loading
  100693. */
  100694. static readonly NO_LOGGING: number;
  100695. /**
  100696. * Minimal logging while loading
  100697. */
  100698. static readonly MINIMAL_LOGGING: number;
  100699. /**
  100700. * Summary logging while loading
  100701. */
  100702. static readonly SUMMARY_LOGGING: number;
  100703. /**
  100704. * Detailled logging while loading
  100705. */
  100706. static readonly DETAILED_LOGGING: number;
  100707. /**
  100708. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100709. */
  100710. static ForceFullSceneLoadingForIncremental: boolean;
  100711. /**
  100712. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100713. */
  100714. static ShowLoadingScreen: boolean;
  100715. /**
  100716. * Defines the current logging level (while loading the scene)
  100717. * @ignorenaming
  100718. */
  100719. static loggingLevel: number;
  100720. /**
  100721. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100722. */
  100723. static CleanBoneMatrixWeights: boolean;
  100724. /**
  100725. * Event raised when a plugin is used to load a scene
  100726. */
  100727. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100728. private static _registeredPlugins;
  100729. private static _getDefaultPlugin;
  100730. private static _getPluginForExtension;
  100731. private static _getPluginForDirectLoad;
  100732. private static _getPluginForFilename;
  100733. private static _getDirectLoad;
  100734. private static _loadData;
  100735. private static _getFileInfo;
  100736. /**
  100737. * Gets a plugin that can load the given extension
  100738. * @param extension defines the extension to load
  100739. * @returns a plugin or null if none works
  100740. */
  100741. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  100742. /**
  100743. * Gets a boolean indicating that the given extension can be loaded
  100744. * @param extension defines the extension to load
  100745. * @returns true if the extension is supported
  100746. */
  100747. static IsPluginForExtensionAvailable(extension: string): boolean;
  100748. /**
  100749. * Adds a new plugin to the list of registered plugins
  100750. * @param plugin defines the plugin to add
  100751. */
  100752. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  100753. /**
  100754. * Import meshes into a scene
  100755. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100756. * @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)
  100757. * @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)
  100758. * @param scene the instance of BABYLON.Scene to append to
  100759. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  100760. * @param onProgress a callback with a progress event for each file being loaded
  100761. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100762. * @param pluginExtension the extension used to determine the plugin
  100763. * @returns The loaded plugin
  100764. */
  100765. 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>;
  100766. /**
  100767. * Import meshes into a scene
  100768. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100769. * @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)
  100770. * @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)
  100771. * @param scene the instance of BABYLON.Scene to append to
  100772. * @param onProgress a callback with a progress event for each file being loaded
  100773. * @param pluginExtension the extension used to determine the plugin
  100774. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  100775. */
  100776. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  100777. meshes: AbstractMesh[];
  100778. particleSystems: IParticleSystem[];
  100779. skeletons: Skeleton[];
  100780. animationGroups: AnimationGroup[];
  100781. }>;
  100782. /**
  100783. * Load a scene
  100784. * @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)
  100785. * @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)
  100786. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100787. * @param onSuccess a callback with the scene when import succeeds
  100788. * @param onProgress a callback with a progress event for each file being loaded
  100789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100790. * @param pluginExtension the extension used to determine the plugin
  100791. * @returns The loaded plugin
  100792. */
  100793. 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>;
  100794. /**
  100795. * Load a scene
  100796. * @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)
  100797. * @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)
  100798. * @param engine is the instance of BABYLON.Engine to use to create the scene
  100799. * @param onProgress a callback with a progress event for each file being loaded
  100800. * @param pluginExtension the extension used to determine the plugin
  100801. * @returns The loaded scene
  100802. */
  100803. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100804. /**
  100805. * Append a scene
  100806. * @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)
  100807. * @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)
  100808. * @param scene is the instance of BABYLON.Scene to append to
  100809. * @param onSuccess a callback with the scene when import succeeds
  100810. * @param onProgress a callback with a progress event for each file being loaded
  100811. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100812. * @param pluginExtension the extension used to determine the plugin
  100813. * @returns The loaded plugin
  100814. */
  100815. 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>;
  100816. /**
  100817. * Append a scene
  100818. * @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)
  100819. * @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)
  100820. * @param scene is the instance of BABYLON.Scene to append to
  100821. * @param onProgress a callback with a progress event for each file being loaded
  100822. * @param pluginExtension the extension used to determine the plugin
  100823. * @returns The given scene
  100824. */
  100825. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100826. /**
  100827. * Load a scene into an asset container
  100828. * @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)
  100829. * @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)
  100830. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100831. * @param onSuccess a callback with the scene when import succeeds
  100832. * @param onProgress a callback with a progress event for each file being loaded
  100833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100834. * @param pluginExtension the extension used to determine the plugin
  100835. * @returns The loaded plugin
  100836. */
  100837. 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>;
  100838. /**
  100839. * Load a scene into an asset container
  100840. * @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)
  100841. * @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)
  100842. * @param scene is the instance of Scene to append to
  100843. * @param onProgress a callback with a progress event for each file being loaded
  100844. * @param pluginExtension the extension used to determine the plugin
  100845. * @returns The loaded asset container
  100846. */
  100847. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100848. }
  100849. }
  100850. declare module BABYLON {
  100851. /**
  100852. * Google Daydream controller
  100853. */
  100854. export class DaydreamController extends WebVRController {
  100855. /**
  100856. * Base Url for the controller model.
  100857. */
  100858. static MODEL_BASE_URL: string;
  100859. /**
  100860. * File name for the controller model.
  100861. */
  100862. static MODEL_FILENAME: string;
  100863. /**
  100864. * Gamepad Id prefix used to identify Daydream Controller.
  100865. */
  100866. static readonly GAMEPAD_ID_PREFIX: string;
  100867. /**
  100868. * Creates a new DaydreamController from a gamepad
  100869. * @param vrGamepad the gamepad that the controller should be created from
  100870. */
  100871. constructor(vrGamepad: any);
  100872. /**
  100873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100874. * @param scene scene in which to add meshes
  100875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100876. */
  100877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100878. /**
  100879. * Called once for each button that changed state since the last frame
  100880. * @param buttonIdx Which button index changed
  100881. * @param state New state of the button
  100882. * @param changes Which properties on the state changed since last frame
  100883. */
  100884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100885. }
  100886. }
  100887. declare module BABYLON {
  100888. /**
  100889. * Gear VR Controller
  100890. */
  100891. export class GearVRController extends WebVRController {
  100892. /**
  100893. * Base Url for the controller model.
  100894. */
  100895. static MODEL_BASE_URL: string;
  100896. /**
  100897. * File name for the controller model.
  100898. */
  100899. static MODEL_FILENAME: string;
  100900. /**
  100901. * Gamepad Id prefix used to identify this controller.
  100902. */
  100903. static readonly GAMEPAD_ID_PREFIX: string;
  100904. private readonly _buttonIndexToObservableNameMap;
  100905. /**
  100906. * Creates a new GearVRController from a gamepad
  100907. * @param vrGamepad the gamepad that the controller should be created from
  100908. */
  100909. constructor(vrGamepad: any);
  100910. /**
  100911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100912. * @param scene scene in which to add meshes
  100913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100914. */
  100915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100916. /**
  100917. * Called once for each button that changed state since the last frame
  100918. * @param buttonIdx Which button index changed
  100919. * @param state New state of the button
  100920. * @param changes Which properties on the state changed since last frame
  100921. */
  100922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100923. }
  100924. }
  100925. declare module BABYLON {
  100926. /**
  100927. * Generic Controller
  100928. */
  100929. export class GenericController extends WebVRController {
  100930. /**
  100931. * Base Url for the controller model.
  100932. */
  100933. static readonly MODEL_BASE_URL: string;
  100934. /**
  100935. * File name for the controller model.
  100936. */
  100937. static readonly MODEL_FILENAME: string;
  100938. /**
  100939. * Creates a new GenericController from a gamepad
  100940. * @param vrGamepad the gamepad that the controller should be created from
  100941. */
  100942. constructor(vrGamepad: any);
  100943. /**
  100944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100945. * @param scene scene in which to add meshes
  100946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100947. */
  100948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100949. /**
  100950. * Called once for each button that changed state since the last frame
  100951. * @param buttonIdx Which button index changed
  100952. * @param state New state of the button
  100953. * @param changes Which properties on the state changed since last frame
  100954. */
  100955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100956. }
  100957. }
  100958. declare module BABYLON {
  100959. /**
  100960. * Oculus Touch Controller
  100961. */
  100962. export class OculusTouchController extends WebVRController {
  100963. /**
  100964. * Base Url for the controller model.
  100965. */
  100966. static MODEL_BASE_URL: string;
  100967. /**
  100968. * File name for the left controller model.
  100969. */
  100970. static MODEL_LEFT_FILENAME: string;
  100971. /**
  100972. * File name for the right controller model.
  100973. */
  100974. static MODEL_RIGHT_FILENAME: string;
  100975. /**
  100976. * Fired when the secondary trigger on this controller is modified
  100977. */
  100978. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100979. /**
  100980. * Fired when the thumb rest on this controller is modified
  100981. */
  100982. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100983. /**
  100984. * Creates a new OculusTouchController from a gamepad
  100985. * @param vrGamepad the gamepad that the controller should be created from
  100986. */
  100987. constructor(vrGamepad: any);
  100988. /**
  100989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100990. * @param scene scene in which to add meshes
  100991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100992. */
  100993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100994. /**
  100995. * Fired when the A button on this controller is modified
  100996. */
  100997. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100998. /**
  100999. * Fired when the B button on this controller is modified
  101000. */
  101001. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101002. /**
  101003. * Fired when the X button on this controller is modified
  101004. */
  101005. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101006. /**
  101007. * Fired when the Y button on this controller is modified
  101008. */
  101009. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101010. /**
  101011. * Called once for each button that changed state since the last frame
  101012. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101013. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101014. * 2) secondary trigger (same)
  101015. * 3) A (right) X (left), touch, pressed = value
  101016. * 4) B / Y
  101017. * 5) thumb rest
  101018. * @param buttonIdx Which button index changed
  101019. * @param state New state of the button
  101020. * @param changes Which properties on the state changed since last frame
  101021. */
  101022. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101023. }
  101024. }
  101025. declare module BABYLON {
  101026. /**
  101027. * Vive Controller
  101028. */
  101029. export class ViveController extends WebVRController {
  101030. /**
  101031. * Base Url for the controller model.
  101032. */
  101033. static MODEL_BASE_URL: string;
  101034. /**
  101035. * File name for the controller model.
  101036. */
  101037. static MODEL_FILENAME: string;
  101038. /**
  101039. * Creates a new ViveController from a gamepad
  101040. * @param vrGamepad the gamepad that the controller should be created from
  101041. */
  101042. constructor(vrGamepad: any);
  101043. /**
  101044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101045. * @param scene scene in which to add meshes
  101046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101047. */
  101048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101049. /**
  101050. * Fired when the left button on this controller is modified
  101051. */
  101052. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101053. /**
  101054. * Fired when the right button on this controller is modified
  101055. */
  101056. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101057. /**
  101058. * Fired when the menu button on this controller is modified
  101059. */
  101060. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101061. /**
  101062. * Called once for each button that changed state since the last frame
  101063. * Vive mapping:
  101064. * 0: touchpad
  101065. * 1: trigger
  101066. * 2: left AND right buttons
  101067. * 3: menu button
  101068. * @param buttonIdx Which button index changed
  101069. * @param state New state of the button
  101070. * @param changes Which properties on the state changed since last frame
  101071. */
  101072. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101073. }
  101074. }
  101075. declare module BABYLON {
  101076. /**
  101077. * Defines the WindowsMotionController object that the state of the windows motion controller
  101078. */
  101079. export class WindowsMotionController extends WebVRController {
  101080. /**
  101081. * The base url used to load the left and right controller models
  101082. */
  101083. static MODEL_BASE_URL: string;
  101084. /**
  101085. * The name of the left controller model file
  101086. */
  101087. static MODEL_LEFT_FILENAME: string;
  101088. /**
  101089. * The name of the right controller model file
  101090. */
  101091. static MODEL_RIGHT_FILENAME: string;
  101092. /**
  101093. * The controller name prefix for this controller type
  101094. */
  101095. static readonly GAMEPAD_ID_PREFIX: string;
  101096. /**
  101097. * The controller id pattern for this controller type
  101098. */
  101099. private static readonly GAMEPAD_ID_PATTERN;
  101100. private _loadedMeshInfo;
  101101. private readonly _mapping;
  101102. /**
  101103. * Fired when the trackpad on this controller is clicked
  101104. */
  101105. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101106. /**
  101107. * Fired when the trackpad on this controller is modified
  101108. */
  101109. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101110. /**
  101111. * The current x and y values of this controller's trackpad
  101112. */
  101113. trackpad: StickValues;
  101114. /**
  101115. * Creates a new WindowsMotionController from a gamepad
  101116. * @param vrGamepad the gamepad that the controller should be created from
  101117. */
  101118. constructor(vrGamepad: any);
  101119. /**
  101120. * Fired when the trigger on this controller is modified
  101121. */
  101122. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101123. /**
  101124. * Fired when the menu button on this controller is modified
  101125. */
  101126. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101127. /**
  101128. * Fired when the grip button on this controller is modified
  101129. */
  101130. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101131. /**
  101132. * Fired when the thumbstick button on this controller is modified
  101133. */
  101134. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101135. /**
  101136. * Fired when the touchpad button on this controller is modified
  101137. */
  101138. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101139. /**
  101140. * Fired when the touchpad values on this controller are modified
  101141. */
  101142. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101143. private _updateTrackpad;
  101144. /**
  101145. * Called once per frame by the engine.
  101146. */
  101147. update(): void;
  101148. /**
  101149. * Called once for each button that changed state since the last frame
  101150. * @param buttonIdx Which button index changed
  101151. * @param state New state of the button
  101152. * @param changes Which properties on the state changed since last frame
  101153. */
  101154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101155. /**
  101156. * Moves the buttons on the controller mesh based on their current state
  101157. * @param buttonName the name of the button to move
  101158. * @param buttonValue the value of the button which determines the buttons new position
  101159. */
  101160. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101161. /**
  101162. * Moves the axis on the controller mesh based on its current state
  101163. * @param axis the index of the axis
  101164. * @param axisValue the value of the axis which determines the meshes new position
  101165. * @hidden
  101166. */
  101167. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101168. /**
  101169. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101170. * @param scene scene in which to add meshes
  101171. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101172. */
  101173. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101174. /**
  101175. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101176. * can be transformed by button presses and axes values, based on this._mapping.
  101177. *
  101178. * @param scene scene in which the meshes exist
  101179. * @param meshes list of meshes that make up the controller model to process
  101180. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101181. */
  101182. private processModel;
  101183. private createMeshInfo;
  101184. /**
  101185. * Gets the ray of the controller in the direction the controller is pointing
  101186. * @param length the length the resulting ray should be
  101187. * @returns a ray in the direction the controller is pointing
  101188. */
  101189. getForwardRay(length?: number): Ray;
  101190. /**
  101191. * Disposes of the controller
  101192. */
  101193. dispose(): void;
  101194. }
  101195. }
  101196. declare module BABYLON {
  101197. /**
  101198. * Single axis scale gizmo
  101199. */
  101200. export class AxisScaleGizmo extends Gizmo {
  101201. private _coloredMaterial;
  101202. /**
  101203. * Drag behavior responsible for the gizmos dragging interactions
  101204. */
  101205. dragBehavior: PointerDragBehavior;
  101206. private _pointerObserver;
  101207. /**
  101208. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101209. */
  101210. snapDistance: number;
  101211. /**
  101212. * Event that fires each time the gizmo snaps to a new location.
  101213. * * snapDistance is the the change in distance
  101214. */
  101215. onSnapObservable: Observable<{
  101216. snapDistance: number;
  101217. }>;
  101218. /**
  101219. * If the scaling operation should be done on all axis (default: false)
  101220. */
  101221. uniformScaling: boolean;
  101222. /**
  101223. * Creates an AxisScaleGizmo
  101224. * @param gizmoLayer The utility layer the gizmo will be added to
  101225. * @param dragAxis The axis which the gizmo will be able to scale on
  101226. * @param color The color of the gizmo
  101227. */
  101228. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101229. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101230. /**
  101231. * Disposes of the gizmo
  101232. */
  101233. dispose(): void;
  101234. /**
  101235. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101236. * @param mesh The mesh to replace the default mesh of the gizmo
  101237. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101238. */
  101239. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101240. }
  101241. }
  101242. declare module BABYLON {
  101243. /**
  101244. * Bounding box gizmo
  101245. */
  101246. export class BoundingBoxGizmo extends Gizmo {
  101247. private _lineBoundingBox;
  101248. private _rotateSpheresParent;
  101249. private _scaleBoxesParent;
  101250. private _boundingDimensions;
  101251. private _renderObserver;
  101252. private _pointerObserver;
  101253. private _scaleDragSpeed;
  101254. private _tmpQuaternion;
  101255. private _tmpVector;
  101256. private _tmpRotationMatrix;
  101257. /**
  101258. * 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)
  101259. */
  101260. ignoreChildren: boolean;
  101261. /**
  101262. * 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)
  101263. */
  101264. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101265. /**
  101266. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101267. */
  101268. rotationSphereSize: number;
  101269. /**
  101270. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101271. */
  101272. scaleBoxSize: number;
  101273. /**
  101274. * 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)
  101275. */
  101276. fixedDragMeshScreenSize: boolean;
  101277. /**
  101278. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101279. */
  101280. fixedDragMeshScreenSizeDistanceFactor: number;
  101281. /**
  101282. * Fired when a rotation sphere or scale box is dragged
  101283. */
  101284. onDragStartObservable: Observable<{}>;
  101285. /**
  101286. * Fired when a scale box is dragged
  101287. */
  101288. onScaleBoxDragObservable: Observable<{}>;
  101289. /**
  101290. * Fired when a scale box drag is ended
  101291. */
  101292. onScaleBoxDragEndObservable: Observable<{}>;
  101293. /**
  101294. * Fired when a rotation sphere is dragged
  101295. */
  101296. onRotationSphereDragObservable: Observable<{}>;
  101297. /**
  101298. * Fired when a rotation sphere drag is ended
  101299. */
  101300. onRotationSphereDragEndObservable: Observable<{}>;
  101301. /**
  101302. * 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)
  101303. */
  101304. scalePivot: Nullable<Vector3>;
  101305. private _anchorMesh;
  101306. private _existingMeshScale;
  101307. private _dragMesh;
  101308. private pointerDragBehavior;
  101309. private coloredMaterial;
  101310. private hoverColoredMaterial;
  101311. /**
  101312. * Sets the color of the bounding box gizmo
  101313. * @param color the color to set
  101314. */
  101315. setColor(color: Color3): void;
  101316. /**
  101317. * Creates an BoundingBoxGizmo
  101318. * @param gizmoLayer The utility layer the gizmo will be added to
  101319. * @param color The color of the gizmo
  101320. */
  101321. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101323. private _selectNode;
  101324. /**
  101325. * Updates the bounding box information for the Gizmo
  101326. */
  101327. updateBoundingBox(): void;
  101328. private _updateRotationSpheres;
  101329. private _updateScaleBoxes;
  101330. /**
  101331. * Enables rotation on the specified axis and disables rotation on the others
  101332. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101333. */
  101334. setEnabledRotationAxis(axis: string): void;
  101335. /**
  101336. * Enables/disables scaling
  101337. * @param enable if scaling should be enabled
  101338. */
  101339. setEnabledScaling(enable: boolean): void;
  101340. private _updateDummy;
  101341. /**
  101342. * Enables a pointer drag behavior on the bounding box of the gizmo
  101343. */
  101344. enableDragBehavior(): void;
  101345. /**
  101346. * Disposes of the gizmo
  101347. */
  101348. dispose(): void;
  101349. /**
  101350. * 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)
  101351. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101352. * @returns the bounding box mesh with the passed in mesh as a child
  101353. */
  101354. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101355. /**
  101356. * CustomMeshes are not supported by this gizmo
  101357. * @param mesh The mesh to replace the default mesh of the gizmo
  101358. */
  101359. setCustomMesh(mesh: Mesh): void;
  101360. }
  101361. }
  101362. declare module BABYLON {
  101363. /**
  101364. * Single plane rotation gizmo
  101365. */
  101366. export class PlaneRotationGizmo extends Gizmo {
  101367. /**
  101368. * Drag behavior responsible for the gizmos dragging interactions
  101369. */
  101370. dragBehavior: PointerDragBehavior;
  101371. private _pointerObserver;
  101372. /**
  101373. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101374. */
  101375. snapDistance: number;
  101376. /**
  101377. * Event that fires each time the gizmo snaps to a new location.
  101378. * * snapDistance is the the change in distance
  101379. */
  101380. onSnapObservable: Observable<{
  101381. snapDistance: number;
  101382. }>;
  101383. /**
  101384. * Creates a PlaneRotationGizmo
  101385. * @param gizmoLayer The utility layer the gizmo will be added to
  101386. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101387. * @param color The color of the gizmo
  101388. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101389. */
  101390. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101391. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101392. /**
  101393. * Disposes of the gizmo
  101394. */
  101395. dispose(): void;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * Gizmo that enables rotating a mesh along 3 axis
  101401. */
  101402. export class RotationGizmo extends Gizmo {
  101403. /**
  101404. * Internal gizmo used for interactions on the x axis
  101405. */
  101406. xGizmo: PlaneRotationGizmo;
  101407. /**
  101408. * Internal gizmo used for interactions on the y axis
  101409. */
  101410. yGizmo: PlaneRotationGizmo;
  101411. /**
  101412. * Internal gizmo used for interactions on the z axis
  101413. */
  101414. zGizmo: PlaneRotationGizmo;
  101415. /** Fires an event when any of it's sub gizmos are dragged */
  101416. onDragStartObservable: Observable<{}>;
  101417. /** Fires an event when any of it's sub gizmos are released from dragging */
  101418. onDragEndObservable: Observable<{}>;
  101419. attachedMesh: Nullable<AbstractMesh>;
  101420. /**
  101421. * Creates a RotationGizmo
  101422. * @param gizmoLayer The utility layer the gizmo will be added to
  101423. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101424. */
  101425. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101426. updateGizmoRotationToMatchAttachedMesh: boolean;
  101427. /**
  101428. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101429. */
  101430. snapDistance: number;
  101431. /**
  101432. * Ratio for the scale of the gizmo (Default: 1)
  101433. */
  101434. scaleRatio: number;
  101435. /**
  101436. * Disposes of the gizmo
  101437. */
  101438. dispose(): void;
  101439. /**
  101440. * CustomMeshes are not supported by this gizmo
  101441. * @param mesh The mesh to replace the default mesh of the gizmo
  101442. */
  101443. setCustomMesh(mesh: Mesh): void;
  101444. }
  101445. }
  101446. declare module BABYLON {
  101447. /**
  101448. * Gizmo that enables dragging a mesh along 3 axis
  101449. */
  101450. export class PositionGizmo extends Gizmo {
  101451. /**
  101452. * Internal gizmo used for interactions on the x axis
  101453. */
  101454. xGizmo: AxisDragGizmo;
  101455. /**
  101456. * Internal gizmo used for interactions on the y axis
  101457. */
  101458. yGizmo: AxisDragGizmo;
  101459. /**
  101460. * Internal gizmo used for interactions on the z axis
  101461. */
  101462. zGizmo: AxisDragGizmo;
  101463. /** Fires an event when any of it's sub gizmos are dragged */
  101464. onDragStartObservable: Observable<{}>;
  101465. /** Fires an event when any of it's sub gizmos are released from dragging */
  101466. onDragEndObservable: Observable<{}>;
  101467. attachedMesh: Nullable<AbstractMesh>;
  101468. /**
  101469. * Creates a PositionGizmo
  101470. * @param gizmoLayer The utility layer the gizmo will be added to
  101471. */
  101472. constructor(gizmoLayer?: UtilityLayerRenderer);
  101473. updateGizmoRotationToMatchAttachedMesh: boolean;
  101474. /**
  101475. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101476. */
  101477. snapDistance: number;
  101478. /**
  101479. * Ratio for the scale of the gizmo (Default: 1)
  101480. */
  101481. scaleRatio: number;
  101482. /**
  101483. * Disposes of the gizmo
  101484. */
  101485. dispose(): void;
  101486. /**
  101487. * CustomMeshes are not supported by this gizmo
  101488. * @param mesh The mesh to replace the default mesh of the gizmo
  101489. */
  101490. setCustomMesh(mesh: Mesh): void;
  101491. }
  101492. }
  101493. declare module BABYLON {
  101494. /**
  101495. * Class containing static functions to help procedurally build meshes
  101496. */
  101497. export class PolyhedronBuilder {
  101498. /**
  101499. * Creates a polyhedron mesh
  101500. * * 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
  101501. * * The parameter `size` (positive float, default 1) sets the polygon size
  101502. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101503. * * 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`
  101504. * * 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
  101505. * * 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)`)
  101506. * * 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
  101507. * * 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
  101508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101511. * @param name defines the name of the mesh
  101512. * @param options defines the options used to create the mesh
  101513. * @param scene defines the hosting scene
  101514. * @returns the polyhedron mesh
  101515. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101516. */
  101517. static CreatePolyhedron(name: string, options: {
  101518. type?: number;
  101519. size?: number;
  101520. sizeX?: number;
  101521. sizeY?: number;
  101522. sizeZ?: number;
  101523. custom?: any;
  101524. faceUV?: Vector4[];
  101525. faceColors?: Color4[];
  101526. flat?: boolean;
  101527. updatable?: boolean;
  101528. sideOrientation?: number;
  101529. frontUVs?: Vector4;
  101530. backUVs?: Vector4;
  101531. }, scene: Scene): Mesh;
  101532. }
  101533. }
  101534. declare module BABYLON {
  101535. /**
  101536. * Gizmo that enables scaling a mesh along 3 axis
  101537. */
  101538. export class ScaleGizmo extends Gizmo {
  101539. /**
  101540. * Internal gizmo used for interactions on the x axis
  101541. */
  101542. xGizmo: AxisScaleGizmo;
  101543. /**
  101544. * Internal gizmo used for interactions on the y axis
  101545. */
  101546. yGizmo: AxisScaleGizmo;
  101547. /**
  101548. * Internal gizmo used for interactions on the z axis
  101549. */
  101550. zGizmo: AxisScaleGizmo;
  101551. /**
  101552. * Internal gizmo used to scale all axis equally
  101553. */
  101554. uniformScaleGizmo: AxisScaleGizmo;
  101555. /** Fires an event when any of it's sub gizmos are dragged */
  101556. onDragStartObservable: Observable<{}>;
  101557. /** Fires an event when any of it's sub gizmos are released from dragging */
  101558. onDragEndObservable: Observable<{}>;
  101559. attachedMesh: Nullable<AbstractMesh>;
  101560. /**
  101561. * Creates a ScaleGizmo
  101562. * @param gizmoLayer The utility layer the gizmo will be added to
  101563. */
  101564. constructor(gizmoLayer?: UtilityLayerRenderer);
  101565. updateGizmoRotationToMatchAttachedMesh: boolean;
  101566. /**
  101567. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101568. */
  101569. snapDistance: number;
  101570. /**
  101571. * Ratio for the scale of the gizmo (Default: 1)
  101572. */
  101573. scaleRatio: number;
  101574. /**
  101575. * Disposes of the gizmo
  101576. */
  101577. dispose(): void;
  101578. }
  101579. }
  101580. declare module BABYLON {
  101581. /**
  101582. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101583. */
  101584. export class GizmoManager implements IDisposable {
  101585. private scene;
  101586. /**
  101587. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101588. */
  101589. gizmos: {
  101590. positionGizmo: Nullable<PositionGizmo>;
  101591. rotationGizmo: Nullable<RotationGizmo>;
  101592. scaleGizmo: Nullable<ScaleGizmo>;
  101593. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101594. };
  101595. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101596. clearGizmoOnEmptyPointerEvent: boolean;
  101597. /** Fires an event when the manager is attached to a mesh */
  101598. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101599. private _gizmosEnabled;
  101600. private _pointerObserver;
  101601. private _attachedMesh;
  101602. private _boundingBoxColor;
  101603. private _defaultUtilityLayer;
  101604. private _defaultKeepDepthUtilityLayer;
  101605. /**
  101606. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101607. */
  101608. boundingBoxDragBehavior: SixDofDragBehavior;
  101609. /**
  101610. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101611. */
  101612. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101613. /**
  101614. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101615. */
  101616. usePointerToAttachGizmos: boolean;
  101617. /**
  101618. * Instatiates a gizmo manager
  101619. * @param scene the scene to overlay the gizmos on top of
  101620. */
  101621. constructor(scene: Scene);
  101622. /**
  101623. * Attaches a set of gizmos to the specified mesh
  101624. * @param mesh The mesh the gizmo's should be attached to
  101625. */
  101626. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101627. /**
  101628. * If the position gizmo is enabled
  101629. */
  101630. positionGizmoEnabled: boolean;
  101631. /**
  101632. * If the rotation gizmo is enabled
  101633. */
  101634. rotationGizmoEnabled: boolean;
  101635. /**
  101636. * If the scale gizmo is enabled
  101637. */
  101638. scaleGizmoEnabled: boolean;
  101639. /**
  101640. * If the boundingBox gizmo is enabled
  101641. */
  101642. boundingBoxGizmoEnabled: boolean;
  101643. /**
  101644. * Disposes of the gizmo manager
  101645. */
  101646. dispose(): void;
  101647. }
  101648. }
  101649. declare module BABYLON {
  101650. /**
  101651. * A directional light is defined by a direction (what a surprise!).
  101652. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101653. * 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.
  101654. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101655. */
  101656. export class DirectionalLight extends ShadowLight {
  101657. private _shadowFrustumSize;
  101658. /**
  101659. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101660. */
  101661. /**
  101662. * Specifies a fix frustum size for the shadow generation.
  101663. */
  101664. shadowFrustumSize: number;
  101665. private _shadowOrthoScale;
  101666. /**
  101667. * Gets the shadow projection scale against the optimal computed one.
  101668. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101669. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101670. */
  101671. /**
  101672. * Sets the shadow projection scale against the optimal computed one.
  101673. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101674. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101675. */
  101676. shadowOrthoScale: number;
  101677. /**
  101678. * Automatically compute the projection matrix to best fit (including all the casters)
  101679. * on each frame.
  101680. */
  101681. autoUpdateExtends: boolean;
  101682. private _orthoLeft;
  101683. private _orthoRight;
  101684. private _orthoTop;
  101685. private _orthoBottom;
  101686. /**
  101687. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101688. * The directional light is emitted from everywhere in the given direction.
  101689. * It can cast shadows.
  101690. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101691. * @param name The friendly name of the light
  101692. * @param direction The direction of the light
  101693. * @param scene The scene the light belongs to
  101694. */
  101695. constructor(name: string, direction: Vector3, scene: Scene);
  101696. /**
  101697. * Returns the string "DirectionalLight".
  101698. * @return The class name
  101699. */
  101700. getClassName(): string;
  101701. /**
  101702. * Returns the integer 1.
  101703. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101704. */
  101705. getTypeID(): number;
  101706. /**
  101707. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101708. * Returns the DirectionalLight Shadow projection matrix.
  101709. */
  101710. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101711. /**
  101712. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101713. * Returns the DirectionalLight Shadow projection matrix.
  101714. */
  101715. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101716. /**
  101717. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101718. * Returns the DirectionalLight Shadow projection matrix.
  101719. */
  101720. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101721. protected _buildUniformLayout(): void;
  101722. /**
  101723. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101724. * @param effect The effect to update
  101725. * @param lightIndex The index of the light in the effect to update
  101726. * @returns The directional light
  101727. */
  101728. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101729. /**
  101730. * Gets the minZ used for shadow according to both the scene and the light.
  101731. *
  101732. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101733. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101734. * @param activeCamera The camera we are returning the min for
  101735. * @returns the depth min z
  101736. */
  101737. getDepthMinZ(activeCamera: Camera): number;
  101738. /**
  101739. * Gets the maxZ used for shadow according to both the scene and the light.
  101740. *
  101741. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101742. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101743. * @param activeCamera The camera we are returning the max for
  101744. * @returns the depth max z
  101745. */
  101746. getDepthMaxZ(activeCamera: Camera): number;
  101747. /**
  101748. * Prepares the list of defines specific to the light type.
  101749. * @param defines the list of defines
  101750. * @param lightIndex defines the index of the light for the effect
  101751. */
  101752. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101753. }
  101754. }
  101755. declare module BABYLON {
  101756. /**
  101757. * Class containing static functions to help procedurally build meshes
  101758. */
  101759. export class HemisphereBuilder {
  101760. /**
  101761. * Creates a hemisphere mesh
  101762. * @param name defines the name of the mesh
  101763. * @param options defines the options used to create the mesh
  101764. * @param scene defines the hosting scene
  101765. * @returns the hemisphere mesh
  101766. */
  101767. static CreateHemisphere(name: string, options: {
  101768. segments?: number;
  101769. diameter?: number;
  101770. sideOrientation?: number;
  101771. }, scene: any): Mesh;
  101772. }
  101773. }
  101774. declare module BABYLON {
  101775. /**
  101776. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101777. * These values define a cone of light starting from the position, emitting toward the direction.
  101778. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101779. * and the exponent defines the speed of the decay of the light with distance (reach).
  101780. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101781. */
  101782. export class SpotLight extends ShadowLight {
  101783. private _angle;
  101784. private _innerAngle;
  101785. private _cosHalfAngle;
  101786. private _lightAngleScale;
  101787. private _lightAngleOffset;
  101788. /**
  101789. * Gets the cone angle of the spot light in Radians.
  101790. */
  101791. /**
  101792. * Sets the cone angle of the spot light in Radians.
  101793. */
  101794. angle: number;
  101795. /**
  101796. * Only used in gltf falloff mode, this defines the angle where
  101797. * the directional falloff will start before cutting at angle which could be seen
  101798. * as outer angle.
  101799. */
  101800. /**
  101801. * Only used in gltf falloff mode, this defines the angle where
  101802. * the directional falloff will start before cutting at angle which could be seen
  101803. * as outer angle.
  101804. */
  101805. innerAngle: number;
  101806. private _shadowAngleScale;
  101807. /**
  101808. * Allows scaling the angle of the light for shadow generation only.
  101809. */
  101810. /**
  101811. * Allows scaling the angle of the light for shadow generation only.
  101812. */
  101813. shadowAngleScale: number;
  101814. /**
  101815. * The light decay speed with the distance from the emission spot.
  101816. */
  101817. exponent: number;
  101818. private _projectionTextureMatrix;
  101819. /**
  101820. * Allows reading the projecton texture
  101821. */
  101822. readonly projectionTextureMatrix: Matrix;
  101823. protected _projectionTextureLightNear: number;
  101824. /**
  101825. * Gets the near clip of the Spotlight for texture projection.
  101826. */
  101827. /**
  101828. * Sets the near clip of the Spotlight for texture projection.
  101829. */
  101830. projectionTextureLightNear: number;
  101831. protected _projectionTextureLightFar: number;
  101832. /**
  101833. * Gets the far clip of the Spotlight for texture projection.
  101834. */
  101835. /**
  101836. * Sets the far clip of the Spotlight for texture projection.
  101837. */
  101838. projectionTextureLightFar: number;
  101839. protected _projectionTextureUpDirection: Vector3;
  101840. /**
  101841. * Gets the Up vector of the Spotlight for texture projection.
  101842. */
  101843. /**
  101844. * Sets the Up vector of the Spotlight for texture projection.
  101845. */
  101846. projectionTextureUpDirection: Vector3;
  101847. private _projectionTexture;
  101848. /**
  101849. * Gets the projection texture of the light.
  101850. */
  101851. /**
  101852. * Sets the projection texture of the light.
  101853. */
  101854. projectionTexture: Nullable<BaseTexture>;
  101855. private _projectionTextureViewLightDirty;
  101856. private _projectionTextureProjectionLightDirty;
  101857. private _projectionTextureDirty;
  101858. private _projectionTextureViewTargetVector;
  101859. private _projectionTextureViewLightMatrix;
  101860. private _projectionTextureProjectionLightMatrix;
  101861. private _projectionTextureScalingMatrix;
  101862. /**
  101863. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101864. * It can cast shadows.
  101865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101866. * @param name The light friendly name
  101867. * @param position The position of the spot light in the scene
  101868. * @param direction The direction of the light in the scene
  101869. * @param angle The cone angle of the light in Radians
  101870. * @param exponent The light decay speed with the distance from the emission spot
  101871. * @param scene The scene the lights belongs to
  101872. */
  101873. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101874. /**
  101875. * Returns the string "SpotLight".
  101876. * @returns the class name
  101877. */
  101878. getClassName(): string;
  101879. /**
  101880. * Returns the integer 2.
  101881. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101882. */
  101883. getTypeID(): number;
  101884. /**
  101885. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101886. */
  101887. protected _setDirection(value: Vector3): void;
  101888. /**
  101889. * Overrides the position setter to recompute the projection texture view light Matrix.
  101890. */
  101891. protected _setPosition(value: Vector3): void;
  101892. /**
  101893. * 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.
  101894. * Returns the SpotLight.
  101895. */
  101896. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101897. protected _computeProjectionTextureViewLightMatrix(): void;
  101898. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101899. /**
  101900. * Main function for light texture projection matrix computing.
  101901. */
  101902. protected _computeProjectionTextureMatrix(): void;
  101903. protected _buildUniformLayout(): void;
  101904. private _computeAngleValues;
  101905. /**
  101906. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101907. * @param effect The effect to update
  101908. * @param lightIndex The index of the light in the effect to update
  101909. * @returns The spot light
  101910. */
  101911. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101912. /**
  101913. * Disposes the light and the associated resources.
  101914. */
  101915. dispose(): void;
  101916. /**
  101917. * Prepares the list of defines specific to the light type.
  101918. * @param defines the list of defines
  101919. * @param lightIndex defines the index of the light for the effect
  101920. */
  101921. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101922. }
  101923. }
  101924. declare module BABYLON {
  101925. /**
  101926. * Gizmo that enables viewing a light
  101927. */
  101928. export class LightGizmo extends Gizmo {
  101929. private _lightMesh;
  101930. private _material;
  101931. /**
  101932. * Creates a LightGizmo
  101933. * @param gizmoLayer The utility layer the gizmo will be added to
  101934. */
  101935. constructor(gizmoLayer?: UtilityLayerRenderer);
  101936. private _light;
  101937. /**
  101938. * The light that the gizmo is attached to
  101939. */
  101940. light: Nullable<Light>;
  101941. /**
  101942. * @hidden
  101943. * Updates the gizmo to match the attached mesh's position/rotation
  101944. */
  101945. protected _update(): void;
  101946. private static _Scale;
  101947. /**
  101948. * Creates the lines for a light mesh
  101949. */
  101950. private static _createLightLines;
  101951. private static _CreateHemisphericLightMesh;
  101952. private static _CreatePointLightMesh;
  101953. private static _CreateSpotLightMesh;
  101954. private static _CreateDirectionalLightMesh;
  101955. }
  101956. }
  101957. declare module BABYLON {
  101958. /** @hidden */
  101959. export var backgroundFragmentDeclaration: {
  101960. name: string;
  101961. shader: string;
  101962. };
  101963. }
  101964. declare module BABYLON {
  101965. /** @hidden */
  101966. export var backgroundUboDeclaration: {
  101967. name: string;
  101968. shader: string;
  101969. };
  101970. }
  101971. declare module BABYLON {
  101972. /** @hidden */
  101973. export var backgroundPixelShader: {
  101974. name: string;
  101975. shader: string;
  101976. };
  101977. }
  101978. declare module BABYLON {
  101979. /** @hidden */
  101980. export var backgroundVertexDeclaration: {
  101981. name: string;
  101982. shader: string;
  101983. };
  101984. }
  101985. declare module BABYLON {
  101986. /** @hidden */
  101987. export var backgroundVertexShader: {
  101988. name: string;
  101989. shader: string;
  101990. };
  101991. }
  101992. declare module BABYLON {
  101993. /**
  101994. * Background material used to create an efficient environement around your scene.
  101995. */
  101996. export class BackgroundMaterial extends PushMaterial {
  101997. /**
  101998. * Standard reflectance value at parallel view angle.
  101999. */
  102000. static StandardReflectance0: number;
  102001. /**
  102002. * Standard reflectance value at grazing angle.
  102003. */
  102004. static StandardReflectance90: number;
  102005. protected _primaryColor: Color3;
  102006. /**
  102007. * Key light Color (multiply against the environement texture)
  102008. */
  102009. primaryColor: Color3;
  102010. protected __perceptualColor: Nullable<Color3>;
  102011. /**
  102012. * Experimental Internal Use Only.
  102013. *
  102014. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102015. * This acts as a helper to set the primary color to a more "human friendly" value.
  102016. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102017. * output color as close as possible from the chosen value.
  102018. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102019. * part of lighting setup.)
  102020. */
  102021. _perceptualColor: Nullable<Color3>;
  102022. protected _primaryColorShadowLevel: float;
  102023. /**
  102024. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102025. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102026. */
  102027. primaryColorShadowLevel: float;
  102028. protected _primaryColorHighlightLevel: float;
  102029. /**
  102030. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102031. * The primary color is used at the level chosen to define what the white area would look.
  102032. */
  102033. primaryColorHighlightLevel: float;
  102034. protected _reflectionTexture: Nullable<BaseTexture>;
  102035. /**
  102036. * Reflection Texture used in the material.
  102037. * Should be author in a specific way for the best result (refer to the documentation).
  102038. */
  102039. reflectionTexture: Nullable<BaseTexture>;
  102040. protected _reflectionBlur: float;
  102041. /**
  102042. * Reflection Texture level of blur.
  102043. *
  102044. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102045. * texture twice.
  102046. */
  102047. reflectionBlur: float;
  102048. protected _diffuseTexture: Nullable<BaseTexture>;
  102049. /**
  102050. * Diffuse Texture used in the material.
  102051. * Should be author in a specific way for the best result (refer to the documentation).
  102052. */
  102053. diffuseTexture: Nullable<BaseTexture>;
  102054. protected _shadowLights: Nullable<IShadowLight[]>;
  102055. /**
  102056. * Specify the list of lights casting shadow on the material.
  102057. * All scene shadow lights will be included if null.
  102058. */
  102059. shadowLights: Nullable<IShadowLight[]>;
  102060. protected _shadowLevel: float;
  102061. /**
  102062. * Helps adjusting the shadow to a softer level if required.
  102063. * 0 means black shadows and 1 means no shadows.
  102064. */
  102065. shadowLevel: float;
  102066. protected _sceneCenter: Vector3;
  102067. /**
  102068. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102069. * It is usually zero but might be interesting to modify according to your setup.
  102070. */
  102071. sceneCenter: Vector3;
  102072. protected _opacityFresnel: boolean;
  102073. /**
  102074. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102075. * This helps ensuring a nice transition when the camera goes under the ground.
  102076. */
  102077. opacityFresnel: boolean;
  102078. protected _reflectionFresnel: boolean;
  102079. /**
  102080. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102081. * This helps adding a mirror texture on the ground.
  102082. */
  102083. reflectionFresnel: boolean;
  102084. protected _reflectionFalloffDistance: number;
  102085. /**
  102086. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102087. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102088. */
  102089. reflectionFalloffDistance: number;
  102090. protected _reflectionAmount: number;
  102091. /**
  102092. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102093. */
  102094. reflectionAmount: number;
  102095. protected _reflectionReflectance0: number;
  102096. /**
  102097. * This specifies the weight of the reflection at grazing angle.
  102098. */
  102099. reflectionReflectance0: number;
  102100. protected _reflectionReflectance90: number;
  102101. /**
  102102. * This specifies the weight of the reflection at a perpendicular point of view.
  102103. */
  102104. reflectionReflectance90: number;
  102105. /**
  102106. * Sets the reflection reflectance fresnel values according to the default standard
  102107. * empirically know to work well :-)
  102108. */
  102109. reflectionStandardFresnelWeight: number;
  102110. protected _useRGBColor: boolean;
  102111. /**
  102112. * Helps to directly use the maps channels instead of their level.
  102113. */
  102114. useRGBColor: boolean;
  102115. protected _enableNoise: boolean;
  102116. /**
  102117. * This helps reducing the banding effect that could occur on the background.
  102118. */
  102119. enableNoise: boolean;
  102120. /**
  102121. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102122. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102123. * Recommended to be keep at 1.0 except for special cases.
  102124. */
  102125. fovMultiplier: number;
  102126. private _fovMultiplier;
  102127. /**
  102128. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102129. */
  102130. useEquirectangularFOV: boolean;
  102131. private _maxSimultaneousLights;
  102132. /**
  102133. * Number of Simultaneous lights allowed on the material.
  102134. */
  102135. maxSimultaneousLights: int;
  102136. /**
  102137. * Default configuration related to image processing available in the Background Material.
  102138. */
  102139. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102140. /**
  102141. * Keep track of the image processing observer to allow dispose and replace.
  102142. */
  102143. private _imageProcessingObserver;
  102144. /**
  102145. * Attaches a new image processing configuration to the PBR Material.
  102146. * @param configuration (if null the scene configuration will be use)
  102147. */
  102148. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102149. /**
  102150. * Gets the image processing configuration used either in this material.
  102151. */
  102152. /**
  102153. * Sets the Default image processing configuration used either in the this material.
  102154. *
  102155. * If sets to null, the scene one is in use.
  102156. */
  102157. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102158. /**
  102159. * Gets wether the color curves effect is enabled.
  102160. */
  102161. /**
  102162. * Sets wether the color curves effect is enabled.
  102163. */
  102164. cameraColorCurvesEnabled: boolean;
  102165. /**
  102166. * Gets wether the color grading effect is enabled.
  102167. */
  102168. /**
  102169. * Gets wether the color grading effect is enabled.
  102170. */
  102171. cameraColorGradingEnabled: boolean;
  102172. /**
  102173. * Gets wether tonemapping is enabled or not.
  102174. */
  102175. /**
  102176. * Sets wether tonemapping is enabled or not
  102177. */
  102178. cameraToneMappingEnabled: boolean;
  102179. /**
  102180. * The camera exposure used on this material.
  102181. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102182. * This corresponds to a photographic exposure.
  102183. */
  102184. /**
  102185. * The camera exposure used on this material.
  102186. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102187. * This corresponds to a photographic exposure.
  102188. */
  102189. cameraExposure: float;
  102190. /**
  102191. * Gets The camera contrast used on this material.
  102192. */
  102193. /**
  102194. * Sets The camera contrast used on this material.
  102195. */
  102196. cameraContrast: float;
  102197. /**
  102198. * Gets the Color Grading 2D Lookup Texture.
  102199. */
  102200. /**
  102201. * Sets the Color Grading 2D Lookup Texture.
  102202. */
  102203. cameraColorGradingTexture: Nullable<BaseTexture>;
  102204. /**
  102205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102207. * 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;
  102208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102209. */
  102210. /**
  102211. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102212. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102213. * 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;
  102214. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102215. */
  102216. cameraColorCurves: Nullable<ColorCurves>;
  102217. /**
  102218. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102219. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102220. */
  102221. switchToBGR: boolean;
  102222. private _renderTargets;
  102223. private _reflectionControls;
  102224. private _white;
  102225. private _primaryShadowColor;
  102226. private _primaryHighlightColor;
  102227. /**
  102228. * Instantiates a Background Material in the given scene
  102229. * @param name The friendly name of the material
  102230. * @param scene The scene to add the material to
  102231. */
  102232. constructor(name: string, scene: Scene);
  102233. /**
  102234. * Gets a boolean indicating that current material needs to register RTT
  102235. */
  102236. readonly hasRenderTargetTextures: boolean;
  102237. /**
  102238. * The entire material has been created in order to prevent overdraw.
  102239. * @returns false
  102240. */
  102241. needAlphaTesting(): boolean;
  102242. /**
  102243. * The entire material has been created in order to prevent overdraw.
  102244. * @returns true if blending is enable
  102245. */
  102246. needAlphaBlending(): boolean;
  102247. /**
  102248. * Checks wether the material is ready to be rendered for a given mesh.
  102249. * @param mesh The mesh to render
  102250. * @param subMesh The submesh to check against
  102251. * @param useInstances Specify wether or not the material is used with instances
  102252. * @returns true if all the dependencies are ready (Textures, Effects...)
  102253. */
  102254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102255. /**
  102256. * Compute the primary color according to the chosen perceptual color.
  102257. */
  102258. private _computePrimaryColorFromPerceptualColor;
  102259. /**
  102260. * Compute the highlights and shadow colors according to their chosen levels.
  102261. */
  102262. private _computePrimaryColors;
  102263. /**
  102264. * Build the uniform buffer used in the material.
  102265. */
  102266. buildUniformLayout(): void;
  102267. /**
  102268. * Unbind the material.
  102269. */
  102270. unbind(): void;
  102271. /**
  102272. * Bind only the world matrix to the material.
  102273. * @param world The world matrix to bind.
  102274. */
  102275. bindOnlyWorldMatrix(world: Matrix): void;
  102276. /**
  102277. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102278. * @param world The world matrix to bind.
  102279. * @param subMesh The submesh to bind for.
  102280. */
  102281. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102282. /**
  102283. * Dispose the material.
  102284. * @param forceDisposeEffect Force disposal of the associated effect.
  102285. * @param forceDisposeTextures Force disposal of the associated textures.
  102286. */
  102287. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102288. /**
  102289. * Clones the material.
  102290. * @param name The cloned name.
  102291. * @returns The cloned material.
  102292. */
  102293. clone(name: string): BackgroundMaterial;
  102294. /**
  102295. * Serializes the current material to its JSON representation.
  102296. * @returns The JSON representation.
  102297. */
  102298. serialize(): any;
  102299. /**
  102300. * Gets the class name of the material
  102301. * @returns "BackgroundMaterial"
  102302. */
  102303. getClassName(): string;
  102304. /**
  102305. * Parse a JSON input to create back a background material.
  102306. * @param source The JSON data to parse
  102307. * @param scene The scene to create the parsed material in
  102308. * @param rootUrl The root url of the assets the material depends upon
  102309. * @returns the instantiated BackgroundMaterial.
  102310. */
  102311. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102312. }
  102313. }
  102314. declare module BABYLON {
  102315. /**
  102316. * Represents the different options available during the creation of
  102317. * a Environment helper.
  102318. *
  102319. * This can control the default ground, skybox and image processing setup of your scene.
  102320. */
  102321. export interface IEnvironmentHelperOptions {
  102322. /**
  102323. * Specifies wether or not to create a ground.
  102324. * True by default.
  102325. */
  102326. createGround: boolean;
  102327. /**
  102328. * Specifies the ground size.
  102329. * 15 by default.
  102330. */
  102331. groundSize: number;
  102332. /**
  102333. * The texture used on the ground for the main color.
  102334. * Comes from the BabylonJS CDN by default.
  102335. *
  102336. * Remarks: Can be either a texture or a url.
  102337. */
  102338. groundTexture: string | BaseTexture;
  102339. /**
  102340. * The color mixed in the ground texture by default.
  102341. * BabylonJS clearColor by default.
  102342. */
  102343. groundColor: Color3;
  102344. /**
  102345. * Specifies the ground opacity.
  102346. * 1 by default.
  102347. */
  102348. groundOpacity: number;
  102349. /**
  102350. * Enables the ground to receive shadows.
  102351. * True by default.
  102352. */
  102353. enableGroundShadow: boolean;
  102354. /**
  102355. * Helps preventing the shadow to be fully black on the ground.
  102356. * 0.5 by default.
  102357. */
  102358. groundShadowLevel: number;
  102359. /**
  102360. * Creates a mirror texture attach to the ground.
  102361. * false by default.
  102362. */
  102363. enableGroundMirror: boolean;
  102364. /**
  102365. * Specifies the ground mirror size ratio.
  102366. * 0.3 by default as the default kernel is 64.
  102367. */
  102368. groundMirrorSizeRatio: number;
  102369. /**
  102370. * Specifies the ground mirror blur kernel size.
  102371. * 64 by default.
  102372. */
  102373. groundMirrorBlurKernel: number;
  102374. /**
  102375. * Specifies the ground mirror visibility amount.
  102376. * 1 by default
  102377. */
  102378. groundMirrorAmount: number;
  102379. /**
  102380. * Specifies the ground mirror reflectance weight.
  102381. * This uses the standard weight of the background material to setup the fresnel effect
  102382. * of the mirror.
  102383. * 1 by default.
  102384. */
  102385. groundMirrorFresnelWeight: number;
  102386. /**
  102387. * Specifies the ground mirror Falloff distance.
  102388. * This can helps reducing the size of the reflection.
  102389. * 0 by Default.
  102390. */
  102391. groundMirrorFallOffDistance: number;
  102392. /**
  102393. * Specifies the ground mirror texture type.
  102394. * Unsigned Int by Default.
  102395. */
  102396. groundMirrorTextureType: number;
  102397. /**
  102398. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102399. * the shown objects.
  102400. */
  102401. groundYBias: number;
  102402. /**
  102403. * Specifies wether or not to create a skybox.
  102404. * True by default.
  102405. */
  102406. createSkybox: boolean;
  102407. /**
  102408. * Specifies the skybox size.
  102409. * 20 by default.
  102410. */
  102411. skyboxSize: number;
  102412. /**
  102413. * The texture used on the skybox for the main color.
  102414. * Comes from the BabylonJS CDN by default.
  102415. *
  102416. * Remarks: Can be either a texture or a url.
  102417. */
  102418. skyboxTexture: string | BaseTexture;
  102419. /**
  102420. * The color mixed in the skybox texture by default.
  102421. * BabylonJS clearColor by default.
  102422. */
  102423. skyboxColor: Color3;
  102424. /**
  102425. * The background rotation around the Y axis of the scene.
  102426. * This helps aligning the key lights of your scene with the background.
  102427. * 0 by default.
  102428. */
  102429. backgroundYRotation: number;
  102430. /**
  102431. * Compute automatically the size of the elements to best fit with the scene.
  102432. */
  102433. sizeAuto: boolean;
  102434. /**
  102435. * Default position of the rootMesh if autoSize is not true.
  102436. */
  102437. rootPosition: Vector3;
  102438. /**
  102439. * Sets up the image processing in the scene.
  102440. * true by default.
  102441. */
  102442. setupImageProcessing: boolean;
  102443. /**
  102444. * The texture used as your environment texture in the scene.
  102445. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102446. *
  102447. * Remarks: Can be either a texture or a url.
  102448. */
  102449. environmentTexture: string | BaseTexture;
  102450. /**
  102451. * The value of the exposure to apply to the scene.
  102452. * 0.6 by default if setupImageProcessing is true.
  102453. */
  102454. cameraExposure: number;
  102455. /**
  102456. * The value of the contrast to apply to the scene.
  102457. * 1.6 by default if setupImageProcessing is true.
  102458. */
  102459. cameraContrast: number;
  102460. /**
  102461. * Specifies wether or not tonemapping should be enabled in the scene.
  102462. * true by default if setupImageProcessing is true.
  102463. */
  102464. toneMappingEnabled: boolean;
  102465. }
  102466. /**
  102467. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102468. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102469. * It also helps with the default setup of your imageProcessing configuration.
  102470. */
  102471. export class EnvironmentHelper {
  102472. /**
  102473. * Default ground texture URL.
  102474. */
  102475. private static _groundTextureCDNUrl;
  102476. /**
  102477. * Default skybox texture URL.
  102478. */
  102479. private static _skyboxTextureCDNUrl;
  102480. /**
  102481. * Default environment texture URL.
  102482. */
  102483. private static _environmentTextureCDNUrl;
  102484. /**
  102485. * Creates the default options for the helper.
  102486. */
  102487. private static _getDefaultOptions;
  102488. private _rootMesh;
  102489. /**
  102490. * Gets the root mesh created by the helper.
  102491. */
  102492. readonly rootMesh: Mesh;
  102493. private _skybox;
  102494. /**
  102495. * Gets the skybox created by the helper.
  102496. */
  102497. readonly skybox: Nullable<Mesh>;
  102498. private _skyboxTexture;
  102499. /**
  102500. * Gets the skybox texture created by the helper.
  102501. */
  102502. readonly skyboxTexture: Nullable<BaseTexture>;
  102503. private _skyboxMaterial;
  102504. /**
  102505. * Gets the skybox material created by the helper.
  102506. */
  102507. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102508. private _ground;
  102509. /**
  102510. * Gets the ground mesh created by the helper.
  102511. */
  102512. readonly ground: Nullable<Mesh>;
  102513. private _groundTexture;
  102514. /**
  102515. * Gets the ground texture created by the helper.
  102516. */
  102517. readonly groundTexture: Nullable<BaseTexture>;
  102518. private _groundMirror;
  102519. /**
  102520. * Gets the ground mirror created by the helper.
  102521. */
  102522. readonly groundMirror: Nullable<MirrorTexture>;
  102523. /**
  102524. * Gets the ground mirror render list to helps pushing the meshes
  102525. * you wish in the ground reflection.
  102526. */
  102527. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102528. private _groundMaterial;
  102529. /**
  102530. * Gets the ground material created by the helper.
  102531. */
  102532. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102533. /**
  102534. * Stores the creation options.
  102535. */
  102536. private readonly _scene;
  102537. private _options;
  102538. /**
  102539. * This observable will be notified with any error during the creation of the environment,
  102540. * mainly texture creation errors.
  102541. */
  102542. onErrorObservable: Observable<{
  102543. message?: string;
  102544. exception?: any;
  102545. }>;
  102546. /**
  102547. * constructor
  102548. * @param options Defines the options we want to customize the helper
  102549. * @param scene The scene to add the material to
  102550. */
  102551. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102552. /**
  102553. * Updates the background according to the new options
  102554. * @param options
  102555. */
  102556. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102557. /**
  102558. * Sets the primary color of all the available elements.
  102559. * @param color the main color to affect to the ground and the background
  102560. */
  102561. setMainColor(color: Color3): void;
  102562. /**
  102563. * Setup the image processing according to the specified options.
  102564. */
  102565. private _setupImageProcessing;
  102566. /**
  102567. * Setup the environment texture according to the specified options.
  102568. */
  102569. private _setupEnvironmentTexture;
  102570. /**
  102571. * Setup the background according to the specified options.
  102572. */
  102573. private _setupBackground;
  102574. /**
  102575. * Get the scene sizes according to the setup.
  102576. */
  102577. private _getSceneSize;
  102578. /**
  102579. * Setup the ground according to the specified options.
  102580. */
  102581. private _setupGround;
  102582. /**
  102583. * Setup the ground material according to the specified options.
  102584. */
  102585. private _setupGroundMaterial;
  102586. /**
  102587. * Setup the ground diffuse texture according to the specified options.
  102588. */
  102589. private _setupGroundDiffuseTexture;
  102590. /**
  102591. * Setup the ground mirror texture according to the specified options.
  102592. */
  102593. private _setupGroundMirrorTexture;
  102594. /**
  102595. * Setup the ground to receive the mirror texture.
  102596. */
  102597. private _setupMirrorInGroundMaterial;
  102598. /**
  102599. * Setup the skybox according to the specified options.
  102600. */
  102601. private _setupSkybox;
  102602. /**
  102603. * Setup the skybox material according to the specified options.
  102604. */
  102605. private _setupSkyboxMaterial;
  102606. /**
  102607. * Setup the skybox reflection texture according to the specified options.
  102608. */
  102609. private _setupSkyboxReflectionTexture;
  102610. private _errorHandler;
  102611. /**
  102612. * Dispose all the elements created by the Helper.
  102613. */
  102614. dispose(): void;
  102615. }
  102616. }
  102617. declare module BABYLON {
  102618. /**
  102619. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102620. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102621. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102622. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102623. */
  102624. export class PhotoDome extends TransformNode {
  102625. private _useDirectMapping;
  102626. /**
  102627. * The texture being displayed on the sphere
  102628. */
  102629. protected _photoTexture: Texture;
  102630. /**
  102631. * Gets or sets the texture being displayed on the sphere
  102632. */
  102633. photoTexture: Texture;
  102634. /**
  102635. * Observable raised when an error occured while loading the 360 image
  102636. */
  102637. onLoadErrorObservable: Observable<string>;
  102638. /**
  102639. * The skybox material
  102640. */
  102641. protected _material: BackgroundMaterial;
  102642. /**
  102643. * The surface used for the skybox
  102644. */
  102645. protected _mesh: Mesh;
  102646. /**
  102647. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102648. * Also see the options.resolution property.
  102649. */
  102650. fovMultiplier: number;
  102651. /**
  102652. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102653. * @param name Element's name, child elements will append suffixes for their own names.
  102654. * @param urlsOfPhoto defines the url of the photo to display
  102655. * @param options defines an object containing optional or exposed sub element properties
  102656. * @param onError defines a callback called when an error occured while loading the texture
  102657. */
  102658. constructor(name: string, urlOfPhoto: string, options: {
  102659. resolution?: number;
  102660. size?: number;
  102661. useDirectMapping?: boolean;
  102662. faceForward?: boolean;
  102663. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102664. /**
  102665. * Releases resources associated with this node.
  102666. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102667. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102668. */
  102669. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102670. }
  102671. }
  102672. declare module BABYLON {
  102673. /**
  102674. * Class used to host texture specific utilities
  102675. */
  102676. export class BRDFTextureTools {
  102677. /**
  102678. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102679. * @param texture the texture to expand.
  102680. */
  102681. private static _ExpandDefaultBRDFTexture;
  102682. /**
  102683. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  102684. * @param scene defines the hosting scene
  102685. * @returns the environment BRDF texture
  102686. */
  102687. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  102688. private static _environmentBRDFBase64Texture;
  102689. }
  102690. }
  102691. declare module BABYLON {
  102692. /**
  102693. * @hidden
  102694. */
  102695. export interface IMaterialClearCoatDefines {
  102696. CLEARCOAT: boolean;
  102697. CLEARCOAT_DEFAULTIOR: boolean;
  102698. CLEARCOAT_TEXTURE: boolean;
  102699. CLEARCOAT_TEXTUREDIRECTUV: number;
  102700. CLEARCOAT_BUMP: boolean;
  102701. CLEARCOAT_BUMPDIRECTUV: number;
  102702. CLEARCOAT_TINT: boolean;
  102703. CLEARCOAT_TINT_TEXTURE: boolean;
  102704. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102705. /** @hidden */
  102706. _areTexturesDirty: boolean;
  102707. }
  102708. /**
  102709. * Define the code related to the clear coat parameters of the pbr material.
  102710. */
  102711. export class PBRClearCoatConfiguration {
  102712. /**
  102713. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102714. * The default fits with a polyurethane material.
  102715. */
  102716. private static readonly _DefaultIndiceOfRefraction;
  102717. private _isEnabled;
  102718. /**
  102719. * Defines if the clear coat is enabled in the material.
  102720. */
  102721. isEnabled: boolean;
  102722. /**
  102723. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  102724. */
  102725. intensity: number;
  102726. /**
  102727. * Defines the clear coat layer roughness.
  102728. */
  102729. roughness: number;
  102730. private _indiceOfRefraction;
  102731. /**
  102732. * Defines the indice of refraction of the clear coat.
  102733. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102734. * The default fits with a polyurethane material.
  102735. * Changing the default value is more performance intensive.
  102736. */
  102737. indiceOfRefraction: number;
  102738. private _texture;
  102739. /**
  102740. * Stores the clear coat values in a texture.
  102741. */
  102742. texture: Nullable<BaseTexture>;
  102743. private _bumpTexture;
  102744. /**
  102745. * Define the clear coat specific bump texture.
  102746. */
  102747. bumpTexture: Nullable<BaseTexture>;
  102748. private _isTintEnabled;
  102749. /**
  102750. * Defines if the clear coat tint is enabled in the material.
  102751. */
  102752. isTintEnabled: boolean;
  102753. /**
  102754. * Defines if the clear coat tint is enabled in the material.
  102755. * This is only use if tint is enabled
  102756. */
  102757. tintColor: Color3;
  102758. /**
  102759. * Defines if the distance at which the tint color should be found in the
  102760. * clear coat media.
  102761. * This is only use if tint is enabled
  102762. */
  102763. tintColorAtDistance: number;
  102764. /**
  102765. * Defines the clear coat layer thickness.
  102766. * This is only use if tint is enabled
  102767. */
  102768. tintThickness: number;
  102769. private _tintTexture;
  102770. /**
  102771. * Stores the clear tint values in a texture.
  102772. * rgb is tint
  102773. * a is a thickness factor
  102774. */
  102775. tintTexture: Nullable<BaseTexture>;
  102776. /** @hidden */
  102777. private _internalMarkAllSubMeshesAsTexturesDirty;
  102778. /** @hidden */
  102779. _markAllSubMeshesAsTexturesDirty(): void;
  102780. /**
  102781. * Instantiate a new istance of clear coat configuration.
  102782. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102783. */
  102784. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102785. /**
  102786. * Specifies that the submesh is ready to be used.
  102787. * @param defines the list of "defines" to update.
  102788. * @param scene defines the scene the material belongs to.
  102789. * @param engine defines the engine the material belongs to.
  102790. * @param disableBumpMap defines wether the material disables bump or not.
  102791. * @returns - boolean indicating that the submesh is ready or not.
  102792. */
  102793. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  102794. /**
  102795. * Checks to see if a texture is used in the material.
  102796. * @param defines the list of "defines" to update.
  102797. * @param scene defines the scene to the material belongs to.
  102798. */
  102799. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  102800. /**
  102801. * Binds the material data.
  102802. * @param uniformBuffer defines the Uniform buffer to fill in.
  102803. * @param scene defines the scene the material belongs to.
  102804. * @param engine defines the engine the material belongs to.
  102805. * @param disableBumpMap defines wether the material disables bump or not.
  102806. * @param isFrozen defines wether the material is frozen or not.
  102807. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102808. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102809. */
  102810. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  102811. /**
  102812. * Checks to see if a texture is used in the material.
  102813. * @param texture - Base texture to use.
  102814. * @returns - Boolean specifying if a texture is used in the material.
  102815. */
  102816. hasTexture(texture: BaseTexture): boolean;
  102817. /**
  102818. * Returns an array of the actively used textures.
  102819. * @param activeTextures Array of BaseTextures
  102820. */
  102821. getActiveTextures(activeTextures: BaseTexture[]): void;
  102822. /**
  102823. * Returns the animatable textures.
  102824. * @param animatables Array of animatable textures.
  102825. */
  102826. getAnimatables(animatables: IAnimatable[]): void;
  102827. /**
  102828. * Disposes the resources of the material.
  102829. * @param forceDisposeTextures - Forces the disposal of all textures.
  102830. */
  102831. dispose(forceDisposeTextures?: boolean): void;
  102832. /**
  102833. * Get the current class name of the texture useful for serialization or dynamic coding.
  102834. * @returns "PBRClearCoatConfiguration"
  102835. */
  102836. getClassName(): string;
  102837. /**
  102838. * Add fallbacks to the effect fallbacks list.
  102839. * @param defines defines the Base texture to use.
  102840. * @param fallbacks defines the current fallback list.
  102841. * @param currentRank defines the current fallback rank.
  102842. * @returns the new fallback rank.
  102843. */
  102844. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102845. /**
  102846. * Add the required uniforms to the current list.
  102847. * @param uniforms defines the current uniform list.
  102848. */
  102849. static AddUniforms(uniforms: string[]): void;
  102850. /**
  102851. * Add the required samplers to the current list.
  102852. * @param samplers defines the current sampler list.
  102853. */
  102854. static AddSamplers(samplers: string[]): void;
  102855. /**
  102856. * Add the required uniforms to the current buffer.
  102857. * @param uniformBuffer defines the current uniform buffer.
  102858. */
  102859. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102860. /**
  102861. * Makes a duplicate of the current configuration into another one.
  102862. * @param clearCoatConfiguration define the config where to copy the info
  102863. */
  102864. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  102865. /**
  102866. * Serializes this clear coat configuration.
  102867. * @returns - An object with the serialized config.
  102868. */
  102869. serialize(): any;
  102870. /**
  102871. * Parses a Clear Coat Configuration from a serialized object.
  102872. * @param source - Serialized object.
  102873. */
  102874. parse(source: any): void;
  102875. }
  102876. }
  102877. declare module BABYLON {
  102878. /**
  102879. * @hidden
  102880. */
  102881. export interface IMaterialAnisotropicDefines {
  102882. ANISOTROPIC: boolean;
  102883. ANISOTROPIC_TEXTURE: boolean;
  102884. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102885. MAINUV1: boolean;
  102886. _areTexturesDirty: boolean;
  102887. _needUVs: boolean;
  102888. }
  102889. /**
  102890. * Define the code related to the anisotropic parameters of the pbr material.
  102891. */
  102892. export class PBRAnisotropicConfiguration {
  102893. private _isEnabled;
  102894. /**
  102895. * Defines if the anisotropy is enabled in the material.
  102896. */
  102897. isEnabled: boolean;
  102898. /**
  102899. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  102900. */
  102901. intensity: number;
  102902. /**
  102903. * Defines if the effect is along the tangents, bitangents or in between.
  102904. * By default, the effect is "strectching" the highlights along the tangents.
  102905. */
  102906. direction: Vector2;
  102907. private _texture;
  102908. /**
  102909. * Stores the anisotropy values in a texture.
  102910. * rg is direction (like normal from -1 to 1)
  102911. * b is a intensity
  102912. */
  102913. texture: Nullable<BaseTexture>;
  102914. /** @hidden */
  102915. private _internalMarkAllSubMeshesAsTexturesDirty;
  102916. /** @hidden */
  102917. _markAllSubMeshesAsTexturesDirty(): void;
  102918. /**
  102919. * Instantiate a new istance of anisotropy configuration.
  102920. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102921. */
  102922. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102923. /**
  102924. * Specifies that the submesh is ready to be used.
  102925. * @param defines the list of "defines" to update.
  102926. * @param scene defines the scene the material belongs to.
  102927. * @returns - boolean indicating that the submesh is ready or not.
  102928. */
  102929. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  102930. /**
  102931. * Checks to see if a texture is used in the material.
  102932. * @param defines the list of "defines" to update.
  102933. * @param mesh the mesh we are preparing the defines for.
  102934. * @param scene defines the scene the material belongs to.
  102935. */
  102936. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  102937. /**
  102938. * Binds the material data.
  102939. * @param uniformBuffer defines the Uniform buffer to fill in.
  102940. * @param scene defines the scene the material belongs to.
  102941. * @param isFrozen defines wether the material is frozen or not.
  102942. */
  102943. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102944. /**
  102945. * Checks to see if a texture is used in the material.
  102946. * @param texture - Base texture to use.
  102947. * @returns - Boolean specifying if a texture is used in the material.
  102948. */
  102949. hasTexture(texture: BaseTexture): boolean;
  102950. /**
  102951. * Returns an array of the actively used textures.
  102952. * @param activeTextures Array of BaseTextures
  102953. */
  102954. getActiveTextures(activeTextures: BaseTexture[]): void;
  102955. /**
  102956. * Returns the animatable textures.
  102957. * @param animatables Array of animatable textures.
  102958. */
  102959. getAnimatables(animatables: IAnimatable[]): void;
  102960. /**
  102961. * Disposes the resources of the material.
  102962. * @param forceDisposeTextures - Forces the disposal of all textures.
  102963. */
  102964. dispose(forceDisposeTextures?: boolean): void;
  102965. /**
  102966. * Get the current class name of the texture useful for serialization or dynamic coding.
  102967. * @returns "PBRAnisotropicConfiguration"
  102968. */
  102969. getClassName(): string;
  102970. /**
  102971. * Add fallbacks to the effect fallbacks list.
  102972. * @param defines defines the Base texture to use.
  102973. * @param fallbacks defines the current fallback list.
  102974. * @param currentRank defines the current fallback rank.
  102975. * @returns the new fallback rank.
  102976. */
  102977. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102978. /**
  102979. * Add the required uniforms to the current list.
  102980. * @param uniforms defines the current uniform list.
  102981. */
  102982. static AddUniforms(uniforms: string[]): void;
  102983. /**
  102984. * Add the required uniforms to the current buffer.
  102985. * @param uniformBuffer defines the current uniform buffer.
  102986. */
  102987. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102988. /**
  102989. * Add the required samplers to the current list.
  102990. * @param samplers defines the current sampler list.
  102991. */
  102992. static AddSamplers(samplers: string[]): void;
  102993. /**
  102994. * Makes a duplicate of the current configuration into another one.
  102995. * @param anisotropicConfiguration define the config where to copy the info
  102996. */
  102997. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  102998. /**
  102999. * Serializes this anisotropy configuration.
  103000. * @returns - An object with the serialized config.
  103001. */
  103002. serialize(): any;
  103003. /**
  103004. * Parses a anisotropy Configuration from a serialized object.
  103005. * @param source - Serialized object.
  103006. */
  103007. parse(source: any): void;
  103008. }
  103009. }
  103010. declare module BABYLON {
  103011. /**
  103012. * @hidden
  103013. */
  103014. export interface IMaterialBRDFDefines {
  103015. BRDF_V_HEIGHT_CORRELATED: boolean;
  103016. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103017. /** @hidden */
  103018. _areMiscDirty: boolean;
  103019. }
  103020. /**
  103021. * Define the code related to the BRDF parameters of the pbr material.
  103022. */
  103023. export class PBRBRDFConfiguration {
  103024. /**
  103025. * Default value used for the energy conservation.
  103026. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103027. */
  103028. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103029. /**
  103030. * Default value used for the Smith Visibility Height Correlated mode.
  103031. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103032. */
  103033. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103034. private _useEnergyConservation;
  103035. /**
  103036. * Defines if the material uses energy conservation.
  103037. */
  103038. useEnergyConservation: boolean;
  103039. private _useSmithVisibilityHeightCorrelated;
  103040. /**
  103041. * LEGACY Mode set to false
  103042. * Defines if the material uses height smith correlated visibility term.
  103043. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103044. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103045. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103046. * Not relying on height correlated will also disable energy conservation.
  103047. */
  103048. useSmithVisibilityHeightCorrelated: boolean;
  103049. /** @hidden */
  103050. private _internalMarkAllSubMeshesAsMiscDirty;
  103051. /** @hidden */
  103052. _markAllSubMeshesAsMiscDirty(): void;
  103053. /**
  103054. * Instantiate a new istance of clear coat configuration.
  103055. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103056. */
  103057. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103058. /**
  103059. * Checks to see if a texture is used in the material.
  103060. * @param defines the list of "defines" to update.
  103061. */
  103062. prepareDefines(defines: IMaterialBRDFDefines): void;
  103063. /**
  103064. * Get the current class name of the texture useful for serialization or dynamic coding.
  103065. * @returns "PBRClearCoatConfiguration"
  103066. */
  103067. getClassName(): string;
  103068. /**
  103069. * Makes a duplicate of the current configuration into another one.
  103070. * @param brdfConfiguration define the config where to copy the info
  103071. */
  103072. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103073. /**
  103074. * Serializes this BRDF configuration.
  103075. * @returns - An object with the serialized config.
  103076. */
  103077. serialize(): any;
  103078. /**
  103079. * Parses a BRDF Configuration from a serialized object.
  103080. * @param source - Serialized object.
  103081. */
  103082. parse(source: any): void;
  103083. }
  103084. }
  103085. declare module BABYLON {
  103086. /**
  103087. * @hidden
  103088. */
  103089. export interface IMaterialSheenDefines {
  103090. SHEEN: boolean;
  103091. SHEEN_TEXTURE: boolean;
  103092. SHEEN_TEXTUREDIRECTUV: number;
  103093. SHEEN_LINKWITHALBEDO: boolean;
  103094. /** @hidden */
  103095. _areTexturesDirty: boolean;
  103096. }
  103097. /**
  103098. * Define the code related to the Sheen parameters of the pbr material.
  103099. */
  103100. export class PBRSheenConfiguration {
  103101. private _isEnabled;
  103102. /**
  103103. * Defines if the material uses sheen.
  103104. */
  103105. isEnabled: boolean;
  103106. private _linkSheenWithAlbedo;
  103107. /**
  103108. * Defines if the sheen is linked to the sheen color.
  103109. */
  103110. linkSheenWithAlbedo: boolean;
  103111. /**
  103112. * Defines the sheen intensity.
  103113. */
  103114. intensity: number;
  103115. /**
  103116. * Defines the sheen color.
  103117. */
  103118. color: Color3;
  103119. private _texture;
  103120. /**
  103121. * Stores the sheen tint values in a texture.
  103122. * rgb is tint
  103123. * a is a intensity
  103124. */
  103125. texture: Nullable<BaseTexture>;
  103126. /** @hidden */
  103127. private _internalMarkAllSubMeshesAsTexturesDirty;
  103128. /** @hidden */
  103129. _markAllSubMeshesAsTexturesDirty(): void;
  103130. /**
  103131. * Instantiate a new istance of clear coat configuration.
  103132. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103133. */
  103134. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103135. /**
  103136. * Specifies that the submesh is ready to be used.
  103137. * @param defines the list of "defines" to update.
  103138. * @param scene defines the scene the material belongs to.
  103139. * @returns - boolean indicating that the submesh is ready or not.
  103140. */
  103141. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103142. /**
  103143. * Checks to see if a texture is used in the material.
  103144. * @param defines the list of "defines" to update.
  103145. * @param scene defines the scene the material belongs to.
  103146. */
  103147. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103148. /**
  103149. * Binds the material data.
  103150. * @param uniformBuffer defines the Uniform buffer to fill in.
  103151. * @param scene defines the scene the material belongs to.
  103152. * @param isFrozen defines wether the material is frozen or not.
  103153. */
  103154. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103155. /**
  103156. * Checks to see if a texture is used in the material.
  103157. * @param texture - Base texture to use.
  103158. * @returns - Boolean specifying if a texture is used in the material.
  103159. */
  103160. hasTexture(texture: BaseTexture): boolean;
  103161. /**
  103162. * Returns an array of the actively used textures.
  103163. * @param activeTextures Array of BaseTextures
  103164. */
  103165. getActiveTextures(activeTextures: BaseTexture[]): void;
  103166. /**
  103167. * Returns the animatable textures.
  103168. * @param animatables Array of animatable textures.
  103169. */
  103170. getAnimatables(animatables: IAnimatable[]): void;
  103171. /**
  103172. * Disposes the resources of the material.
  103173. * @param forceDisposeTextures - Forces the disposal of all textures.
  103174. */
  103175. dispose(forceDisposeTextures?: boolean): void;
  103176. /**
  103177. * Get the current class name of the texture useful for serialization or dynamic coding.
  103178. * @returns "PBRSheenConfiguration"
  103179. */
  103180. getClassName(): string;
  103181. /**
  103182. * Add fallbacks to the effect fallbacks list.
  103183. * @param defines defines the Base texture to use.
  103184. * @param fallbacks defines the current fallback list.
  103185. * @param currentRank defines the current fallback rank.
  103186. * @returns the new fallback rank.
  103187. */
  103188. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103189. /**
  103190. * Add the required uniforms to the current list.
  103191. * @param uniforms defines the current uniform list.
  103192. */
  103193. static AddUniforms(uniforms: string[]): void;
  103194. /**
  103195. * Add the required uniforms to the current buffer.
  103196. * @param uniformBuffer defines the current uniform buffer.
  103197. */
  103198. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103199. /**
  103200. * Add the required samplers to the current list.
  103201. * @param samplers defines the current sampler list.
  103202. */
  103203. static AddSamplers(samplers: string[]): void;
  103204. /**
  103205. * Makes a duplicate of the current configuration into another one.
  103206. * @param sheenConfiguration define the config where to copy the info
  103207. */
  103208. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103209. /**
  103210. * Serializes this BRDF configuration.
  103211. * @returns - An object with the serialized config.
  103212. */
  103213. serialize(): any;
  103214. /**
  103215. * Parses a Sheen Configuration from a serialized object.
  103216. * @param source - Serialized object.
  103217. */
  103218. parse(source: any): void;
  103219. }
  103220. }
  103221. declare module BABYLON {
  103222. /** @hidden */
  103223. export var pbrFragmentDeclaration: {
  103224. name: string;
  103225. shader: string;
  103226. };
  103227. }
  103228. declare module BABYLON {
  103229. /** @hidden */
  103230. export var pbrUboDeclaration: {
  103231. name: string;
  103232. shader: string;
  103233. };
  103234. }
  103235. declare module BABYLON {
  103236. /** @hidden */
  103237. export var pbrFragmentExtraDeclaration: {
  103238. name: string;
  103239. shader: string;
  103240. };
  103241. }
  103242. declare module BABYLON {
  103243. /** @hidden */
  103244. export var pbrFragmentSamplersDeclaration: {
  103245. name: string;
  103246. shader: string;
  103247. };
  103248. }
  103249. declare module BABYLON {
  103250. /** @hidden */
  103251. export var pbrHelperFunctions: {
  103252. name: string;
  103253. shader: string;
  103254. };
  103255. }
  103256. declare module BABYLON {
  103257. /** @hidden */
  103258. export var harmonicsFunctions: {
  103259. name: string;
  103260. shader: string;
  103261. };
  103262. }
  103263. declare module BABYLON {
  103264. /** @hidden */
  103265. export var pbrDirectLightingSetupFunctions: {
  103266. name: string;
  103267. shader: string;
  103268. };
  103269. }
  103270. declare module BABYLON {
  103271. /** @hidden */
  103272. export var pbrDirectLightingFalloffFunctions: {
  103273. name: string;
  103274. shader: string;
  103275. };
  103276. }
  103277. declare module BABYLON {
  103278. /** @hidden */
  103279. export var pbrBRDFFunctions: {
  103280. name: string;
  103281. shader: string;
  103282. };
  103283. }
  103284. declare module BABYLON {
  103285. /** @hidden */
  103286. export var pbrDirectLightingFunctions: {
  103287. name: string;
  103288. shader: string;
  103289. };
  103290. }
  103291. declare module BABYLON {
  103292. /** @hidden */
  103293. export var pbrIBLFunctions: {
  103294. name: string;
  103295. shader: string;
  103296. };
  103297. }
  103298. declare module BABYLON {
  103299. /** @hidden */
  103300. export var pbrDebug: {
  103301. name: string;
  103302. shader: string;
  103303. };
  103304. }
  103305. declare module BABYLON {
  103306. /** @hidden */
  103307. export var pbrPixelShader: {
  103308. name: string;
  103309. shader: string;
  103310. };
  103311. }
  103312. declare module BABYLON {
  103313. /** @hidden */
  103314. export var pbrVertexDeclaration: {
  103315. name: string;
  103316. shader: string;
  103317. };
  103318. }
  103319. declare module BABYLON {
  103320. /** @hidden */
  103321. export var pbrVertexShader: {
  103322. name: string;
  103323. shader: string;
  103324. };
  103325. }
  103326. declare module BABYLON {
  103327. /**
  103328. * Manages the defines for the PBR Material.
  103329. * @hidden
  103330. */
  103331. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  103332. PBR: boolean;
  103333. MAINUV1: boolean;
  103334. MAINUV2: boolean;
  103335. UV1: boolean;
  103336. UV2: boolean;
  103337. ALBEDO: boolean;
  103338. ALBEDODIRECTUV: number;
  103339. VERTEXCOLOR: boolean;
  103340. AMBIENT: boolean;
  103341. AMBIENTDIRECTUV: number;
  103342. AMBIENTINGRAYSCALE: boolean;
  103343. OPACITY: boolean;
  103344. VERTEXALPHA: boolean;
  103345. OPACITYDIRECTUV: number;
  103346. OPACITYRGB: boolean;
  103347. ALPHATEST: boolean;
  103348. DEPTHPREPASS: boolean;
  103349. ALPHABLEND: boolean;
  103350. ALPHAFROMALBEDO: boolean;
  103351. ALPHATESTVALUE: string;
  103352. SPECULAROVERALPHA: boolean;
  103353. RADIANCEOVERALPHA: boolean;
  103354. ALPHAFRESNEL: boolean;
  103355. LINEARALPHAFRESNEL: boolean;
  103356. PREMULTIPLYALPHA: boolean;
  103357. EMISSIVE: boolean;
  103358. EMISSIVEDIRECTUV: number;
  103359. REFLECTIVITY: boolean;
  103360. REFLECTIVITYDIRECTUV: number;
  103361. SPECULARTERM: boolean;
  103362. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103363. MICROSURFACEAUTOMATIC: boolean;
  103364. LODBASEDMICROSFURACE: boolean;
  103365. MICROSURFACEMAP: boolean;
  103366. MICROSURFACEMAPDIRECTUV: number;
  103367. METALLICWORKFLOW: boolean;
  103368. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103369. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103370. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103371. AOSTOREINMETALMAPRED: boolean;
  103372. ENVIRONMENTBRDF: boolean;
  103373. ENVIRONMENTBRDF_RGBD: boolean;
  103374. NORMAL: boolean;
  103375. TANGENT: boolean;
  103376. BUMP: boolean;
  103377. BUMPDIRECTUV: number;
  103378. OBJECTSPACE_NORMALMAP: boolean;
  103379. PARALLAX: boolean;
  103380. PARALLAXOCCLUSION: boolean;
  103381. NORMALXYSCALE: boolean;
  103382. LIGHTMAP: boolean;
  103383. LIGHTMAPDIRECTUV: number;
  103384. USELIGHTMAPASSHADOWMAP: boolean;
  103385. GAMMALIGHTMAP: boolean;
  103386. REFLECTION: boolean;
  103387. REFLECTIONMAP_3D: boolean;
  103388. REFLECTIONMAP_SPHERICAL: boolean;
  103389. REFLECTIONMAP_PLANAR: boolean;
  103390. REFLECTIONMAP_CUBIC: boolean;
  103391. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103392. REFLECTIONMAP_PROJECTION: boolean;
  103393. REFLECTIONMAP_SKYBOX: boolean;
  103394. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103395. REFLECTIONMAP_EXPLICIT: boolean;
  103396. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103397. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103398. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103399. INVERTCUBICMAP: boolean;
  103400. USESPHERICALFROMREFLECTIONMAP: boolean;
  103401. USESPHERICALINVERTEX: boolean;
  103402. REFLECTIONMAP_OPPOSITEZ: boolean;
  103403. LODINREFLECTIONALPHA: boolean;
  103404. GAMMAREFLECTION: boolean;
  103405. RGBDREFLECTION: boolean;
  103406. RADIANCEOCCLUSION: boolean;
  103407. HORIZONOCCLUSION: boolean;
  103408. REFRACTION: boolean;
  103409. REFRACTIONMAP_3D: boolean;
  103410. REFRACTIONMAP_OPPOSITEZ: boolean;
  103411. LODINREFRACTIONALPHA: boolean;
  103412. GAMMAREFRACTION: boolean;
  103413. RGBDREFRACTION: boolean;
  103414. LINKREFRACTIONTOTRANSPARENCY: boolean;
  103415. INSTANCES: boolean;
  103416. NUM_BONE_INFLUENCERS: number;
  103417. BonesPerMesh: number;
  103418. BONETEXTURE: boolean;
  103419. NONUNIFORMSCALING: boolean;
  103420. MORPHTARGETS: boolean;
  103421. MORPHTARGETS_NORMAL: boolean;
  103422. MORPHTARGETS_TANGENT: boolean;
  103423. NUM_MORPH_INFLUENCERS: number;
  103424. IMAGEPROCESSING: boolean;
  103425. VIGNETTE: boolean;
  103426. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103427. VIGNETTEBLENDMODEOPAQUE: boolean;
  103428. TONEMAPPING: boolean;
  103429. TONEMAPPING_ACES: boolean;
  103430. CONTRAST: boolean;
  103431. COLORCURVES: boolean;
  103432. COLORGRADING: boolean;
  103433. COLORGRADING3D: boolean;
  103434. SAMPLER3DGREENDEPTH: boolean;
  103435. SAMPLER3DBGRMAP: boolean;
  103436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103437. EXPOSURE: boolean;
  103438. MULTIVIEW: boolean;
  103439. USEPHYSICALLIGHTFALLOFF: boolean;
  103440. USEGLTFLIGHTFALLOFF: boolean;
  103441. TWOSIDEDLIGHTING: boolean;
  103442. SHADOWFLOAT: boolean;
  103443. CLIPPLANE: boolean;
  103444. CLIPPLANE2: boolean;
  103445. CLIPPLANE3: boolean;
  103446. CLIPPLANE4: boolean;
  103447. POINTSIZE: boolean;
  103448. FOG: boolean;
  103449. LOGARITHMICDEPTH: boolean;
  103450. FORCENORMALFORWARD: boolean;
  103451. SPECULARAA: boolean;
  103452. CLEARCOAT: boolean;
  103453. CLEARCOAT_DEFAULTIOR: boolean;
  103454. CLEARCOAT_TEXTURE: boolean;
  103455. CLEARCOAT_TEXTUREDIRECTUV: number;
  103456. CLEARCOAT_BUMP: boolean;
  103457. CLEARCOAT_BUMPDIRECTUV: number;
  103458. CLEARCOAT_TINT: boolean;
  103459. CLEARCOAT_TINT_TEXTURE: boolean;
  103460. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103461. ANISOTROPIC: boolean;
  103462. ANISOTROPIC_TEXTURE: boolean;
  103463. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103464. BRDF_V_HEIGHT_CORRELATED: boolean;
  103465. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103466. SHEEN: boolean;
  103467. SHEEN_TEXTURE: boolean;
  103468. SHEEN_TEXTUREDIRECTUV: number;
  103469. SHEEN_LINKWITHALBEDO: boolean;
  103470. UNLIT: boolean;
  103471. DEBUGMODE: number;
  103472. /**
  103473. * Initializes the PBR Material defines.
  103474. */
  103475. constructor();
  103476. /**
  103477. * Resets the PBR Material defines.
  103478. */
  103479. reset(): void;
  103480. }
  103481. /**
  103482. * The Physically based material base class of BJS.
  103483. *
  103484. * This offers the main features of a standard PBR material.
  103485. * For more information, please refer to the documentation :
  103486. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  103487. */
  103488. export abstract class PBRBaseMaterial extends PushMaterial {
  103489. /**
  103490. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103491. */
  103492. static readonly PBRMATERIAL_OPAQUE: number;
  103493. /**
  103494. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103495. */
  103496. static readonly PBRMATERIAL_ALPHATEST: number;
  103497. /**
  103498. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103499. */
  103500. static readonly PBRMATERIAL_ALPHABLEND: number;
  103501. /**
  103502. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103503. * They are also discarded below the alpha cutoff threshold to improve performances.
  103504. */
  103505. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103506. /**
  103507. * Defines the default value of how much AO map is occluding the analytical lights
  103508. * (point spot...).
  103509. */
  103510. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103511. /**
  103512. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  103513. */
  103514. static readonly LIGHTFALLOFF_PHYSICAL: number;
  103515. /**
  103516. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  103517. * to enhance interoperability with other engines.
  103518. */
  103519. static readonly LIGHTFALLOFF_GLTF: number;
  103520. /**
  103521. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  103522. * to enhance interoperability with other materials.
  103523. */
  103524. static readonly LIGHTFALLOFF_STANDARD: number;
  103525. /**
  103526. * Intensity of the direct lights e.g. the four lights available in your scene.
  103527. * This impacts both the direct diffuse and specular highlights.
  103528. */
  103529. protected _directIntensity: number;
  103530. /**
  103531. * Intensity of the emissive part of the material.
  103532. * This helps controlling the emissive effect without modifying the emissive color.
  103533. */
  103534. protected _emissiveIntensity: number;
  103535. /**
  103536. * Intensity of the environment e.g. how much the environment will light the object
  103537. * either through harmonics for rough material or through the refelction for shiny ones.
  103538. */
  103539. protected _environmentIntensity: number;
  103540. /**
  103541. * This is a special control allowing the reduction of the specular highlights coming from the
  103542. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103543. */
  103544. protected _specularIntensity: number;
  103545. /**
  103546. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  103547. */
  103548. private _lightingInfos;
  103549. /**
  103550. * Debug Control allowing disabling the bump map on this material.
  103551. */
  103552. protected _disableBumpMap: boolean;
  103553. /**
  103554. * AKA Diffuse Texture in standard nomenclature.
  103555. */
  103556. protected _albedoTexture: BaseTexture;
  103557. /**
  103558. * AKA Occlusion Texture in other nomenclature.
  103559. */
  103560. protected _ambientTexture: BaseTexture;
  103561. /**
  103562. * AKA Occlusion Texture Intensity in other nomenclature.
  103563. */
  103564. protected _ambientTextureStrength: number;
  103565. /**
  103566. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103567. * 1 means it completely occludes it
  103568. * 0 mean it has no impact
  103569. */
  103570. protected _ambientTextureImpactOnAnalyticalLights: number;
  103571. /**
  103572. * Stores the alpha values in a texture.
  103573. */
  103574. protected _opacityTexture: BaseTexture;
  103575. /**
  103576. * Stores the reflection values in a texture.
  103577. */
  103578. protected _reflectionTexture: BaseTexture;
  103579. /**
  103580. * Stores the refraction values in a texture.
  103581. */
  103582. protected _refractionTexture: BaseTexture;
  103583. /**
  103584. * Stores the emissive values in a texture.
  103585. */
  103586. protected _emissiveTexture: BaseTexture;
  103587. /**
  103588. * AKA Specular texture in other nomenclature.
  103589. */
  103590. protected _reflectivityTexture: BaseTexture;
  103591. /**
  103592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103593. */
  103594. protected _metallicTexture: BaseTexture;
  103595. /**
  103596. * Specifies the metallic scalar of the metallic/roughness workflow.
  103597. * Can also be used to scale the metalness values of the metallic texture.
  103598. */
  103599. protected _metallic: Nullable<number>;
  103600. /**
  103601. * Specifies the roughness scalar of the metallic/roughness workflow.
  103602. * Can also be used to scale the roughness values of the metallic texture.
  103603. */
  103604. protected _roughness: Nullable<number>;
  103605. /**
  103606. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103607. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103608. */
  103609. protected _microSurfaceTexture: BaseTexture;
  103610. /**
  103611. * Stores surface normal data used to displace a mesh in a texture.
  103612. */
  103613. protected _bumpTexture: BaseTexture;
  103614. /**
  103615. * Stores the pre-calculated light information of a mesh in a texture.
  103616. */
  103617. protected _lightmapTexture: BaseTexture;
  103618. /**
  103619. * The color of a material in ambient lighting.
  103620. */
  103621. protected _ambientColor: Color3;
  103622. /**
  103623. * AKA Diffuse Color in other nomenclature.
  103624. */
  103625. protected _albedoColor: Color3;
  103626. /**
  103627. * AKA Specular Color in other nomenclature.
  103628. */
  103629. protected _reflectivityColor: Color3;
  103630. /**
  103631. * The color applied when light is reflected from a material.
  103632. */
  103633. protected _reflectionColor: Color3;
  103634. /**
  103635. * The color applied when light is emitted from a material.
  103636. */
  103637. protected _emissiveColor: Color3;
  103638. /**
  103639. * AKA Glossiness in other nomenclature.
  103640. */
  103641. protected _microSurface: number;
  103642. /**
  103643. * source material index of refraction (IOR)' / 'destination material IOR.
  103644. */
  103645. protected _indexOfRefraction: number;
  103646. /**
  103647. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103648. */
  103649. protected _invertRefractionY: boolean;
  103650. /**
  103651. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103652. * Materials half opaque for instance using refraction could benefit from this control.
  103653. */
  103654. protected _linkRefractionWithTransparency: boolean;
  103655. /**
  103656. * Specifies that the material will use the light map as a show map.
  103657. */
  103658. protected _useLightmapAsShadowmap: boolean;
  103659. /**
  103660. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103661. * makes the reflect vector face the model (under horizon).
  103662. */
  103663. protected _useHorizonOcclusion: boolean;
  103664. /**
  103665. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103666. * too much the area relying on ambient texture to define their ambient occlusion.
  103667. */
  103668. protected _useRadianceOcclusion: boolean;
  103669. /**
  103670. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103671. */
  103672. protected _useAlphaFromAlbedoTexture: boolean;
  103673. /**
  103674. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  103675. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103676. */
  103677. protected _useSpecularOverAlpha: boolean;
  103678. /**
  103679. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103680. */
  103681. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103682. /**
  103683. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103684. */
  103685. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  103686. /**
  103687. * Specifies if the metallic texture contains the roughness information in its green channel.
  103688. */
  103689. protected _useRoughnessFromMetallicTextureGreen: boolean;
  103690. /**
  103691. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103692. */
  103693. protected _useMetallnessFromMetallicTextureBlue: boolean;
  103694. /**
  103695. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103696. */
  103697. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  103698. /**
  103699. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103700. */
  103701. protected _useAmbientInGrayScale: boolean;
  103702. /**
  103703. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103704. * The material will try to infer what glossiness each pixel should be.
  103705. */
  103706. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  103707. /**
  103708. * Defines the falloff type used in this material.
  103709. * It by default is Physical.
  103710. */
  103711. protected _lightFalloff: number;
  103712. /**
  103713. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103714. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103715. */
  103716. protected _useRadianceOverAlpha: boolean;
  103717. /**
  103718. * Allows using an object space normal map (instead of tangent space).
  103719. */
  103720. protected _useObjectSpaceNormalMap: boolean;
  103721. /**
  103722. * Allows using the bump map in parallax mode.
  103723. */
  103724. protected _useParallax: boolean;
  103725. /**
  103726. * Allows using the bump map in parallax occlusion mode.
  103727. */
  103728. protected _useParallaxOcclusion: boolean;
  103729. /**
  103730. * Controls the scale bias of the parallax mode.
  103731. */
  103732. protected _parallaxScaleBias: number;
  103733. /**
  103734. * If sets to true, disables all the lights affecting the material.
  103735. */
  103736. protected _disableLighting: boolean;
  103737. /**
  103738. * Number of Simultaneous lights allowed on the material.
  103739. */
  103740. protected _maxSimultaneousLights: number;
  103741. /**
  103742. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103743. */
  103744. protected _invertNormalMapX: boolean;
  103745. /**
  103746. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103747. */
  103748. protected _invertNormalMapY: boolean;
  103749. /**
  103750. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103751. */
  103752. protected _twoSidedLighting: boolean;
  103753. /**
  103754. * Defines the alpha limits in alpha test mode.
  103755. */
  103756. protected _alphaCutOff: number;
  103757. /**
  103758. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103759. */
  103760. protected _forceAlphaTest: boolean;
  103761. /**
  103762. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103763. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103764. */
  103765. protected _useAlphaFresnel: boolean;
  103766. /**
  103767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103768. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103769. */
  103770. protected _useLinearAlphaFresnel: boolean;
  103771. /**
  103772. * The transparency mode of the material.
  103773. */
  103774. protected _transparencyMode: Nullable<number>;
  103775. /**
  103776. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  103777. * from cos thetav and roughness:
  103778. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  103779. */
  103780. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  103781. /**
  103782. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103783. */
  103784. protected _forceIrradianceInFragment: boolean;
  103785. /**
  103786. * Force normal to face away from face.
  103787. */
  103788. protected _forceNormalForward: boolean;
  103789. /**
  103790. * Enables specular anti aliasing in the PBR shader.
  103791. * It will both interacts on the Geometry for analytical and IBL lighting.
  103792. * It also prefilter the roughness map based on the bump values.
  103793. */
  103794. protected _enableSpecularAntiAliasing: boolean;
  103795. /**
  103796. * Default configuration related to image processing available in the PBR Material.
  103797. */
  103798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103799. /**
  103800. * Keep track of the image processing observer to allow dispose and replace.
  103801. */
  103802. private _imageProcessingObserver;
  103803. /**
  103804. * Attaches a new image processing configuration to the PBR Material.
  103805. * @param configuration
  103806. */
  103807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103808. /**
  103809. * Stores the available render targets.
  103810. */
  103811. private _renderTargets;
  103812. /**
  103813. * Sets the global ambient color for the material used in lighting calculations.
  103814. */
  103815. private _globalAmbientColor;
  103816. /**
  103817. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  103818. */
  103819. private _useLogarithmicDepth;
  103820. /**
  103821. * If set to true, no lighting calculations will be applied.
  103822. */
  103823. private _unlit;
  103824. private _debugMode;
  103825. /**
  103826. * @hidden
  103827. * This is reserved for the inspector.
  103828. * Defines the material debug mode.
  103829. * It helps seeing only some components of the material while troubleshooting.
  103830. */
  103831. debugMode: number;
  103832. /**
  103833. * @hidden
  103834. * This is reserved for the inspector.
  103835. * Specify from where on screen the debug mode should start.
  103836. * The value goes from -1 (full screen) to 1 (not visible)
  103837. * It helps with side by side comparison against the final render
  103838. * This defaults to -1
  103839. */
  103840. private debugLimit;
  103841. /**
  103842. * @hidden
  103843. * This is reserved for the inspector.
  103844. * As the default viewing range might not be enough (if the ambient is really small for instance)
  103845. * You can use the factor to better multiply the final value.
  103846. */
  103847. private debugFactor;
  103848. /**
  103849. * Defines the clear coat layer parameters for the material.
  103850. */
  103851. readonly clearCoat: PBRClearCoatConfiguration;
  103852. /**
  103853. * Defines the anisotropic parameters for the material.
  103854. */
  103855. readonly anisotropy: PBRAnisotropicConfiguration;
  103856. /**
  103857. * Defines the BRDF parameters for the material.
  103858. */
  103859. readonly brdf: PBRBRDFConfiguration;
  103860. /**
  103861. * Defines the Sheen parameters for the material.
  103862. */
  103863. readonly sheen: PBRSheenConfiguration;
  103864. /**
  103865. * Custom callback helping to override the default shader used in the material.
  103866. */
  103867. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  103868. /**
  103869. * Instantiates a new PBRMaterial instance.
  103870. *
  103871. * @param name The material name
  103872. * @param scene The scene the material will be use in.
  103873. */
  103874. constructor(name: string, scene: Scene);
  103875. /**
  103876. * Gets a boolean indicating that current material needs to register RTT
  103877. */
  103878. readonly hasRenderTargetTextures: boolean;
  103879. /**
  103880. * Gets the name of the material class.
  103881. */
  103882. getClassName(): string;
  103883. /**
  103884. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103885. */
  103886. /**
  103887. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103888. */
  103889. useLogarithmicDepth: boolean;
  103890. /**
  103891. * Gets the current transparency mode.
  103892. */
  103893. /**
  103894. * Sets the transparency mode of the material.
  103895. *
  103896. * | Value | Type | Description |
  103897. * | ----- | ----------------------------------- | ----------- |
  103898. * | 0 | OPAQUE | |
  103899. * | 1 | ALPHATEST | |
  103900. * | 2 | ALPHABLEND | |
  103901. * | 3 | ALPHATESTANDBLEND | |
  103902. *
  103903. */
  103904. transparencyMode: Nullable<number>;
  103905. /**
  103906. * Returns true if alpha blending should be disabled.
  103907. */
  103908. private readonly _disableAlphaBlending;
  103909. /**
  103910. * Specifies whether or not this material should be rendered in alpha blend mode.
  103911. */
  103912. needAlphaBlending(): boolean;
  103913. /**
  103914. * Specifies if the mesh will require alpha blending.
  103915. * @param mesh - BJS mesh.
  103916. */
  103917. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103918. /**
  103919. * Specifies whether or not this material should be rendered in alpha test mode.
  103920. */
  103921. needAlphaTesting(): boolean;
  103922. /**
  103923. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  103924. */
  103925. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  103926. /**
  103927. * Gets the texture used for the alpha test.
  103928. */
  103929. getAlphaTestTexture(): BaseTexture;
  103930. /**
  103931. * Specifies that the submesh is ready to be used.
  103932. * @param mesh - BJS mesh.
  103933. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  103934. * @param useInstances - Specifies that instances should be used.
  103935. * @returns - boolean indicating that the submesh is ready or not.
  103936. */
  103937. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103938. /**
  103939. * Specifies if the material uses metallic roughness workflow.
  103940. * @returns boolean specifiying if the material uses metallic roughness workflow.
  103941. */
  103942. isMetallicWorkflow(): boolean;
  103943. private _prepareEffect;
  103944. private _prepareDefines;
  103945. /**
  103946. * Force shader compilation
  103947. */
  103948. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  103949. clipPlane: boolean;
  103950. }>): void;
  103951. /**
  103952. * Initializes the uniform buffer layout for the shader.
  103953. */
  103954. buildUniformLayout(): void;
  103955. /**
  103956. * Unbinds the textures.
  103957. */
  103958. unbind(): void;
  103959. /**
  103960. * Binds the submesh data.
  103961. * @param world - The world matrix.
  103962. * @param mesh - The BJS mesh.
  103963. * @param subMesh - A submesh of the BJS mesh.
  103964. */
  103965. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103966. /**
  103967. * Returns the animatable textures.
  103968. * @returns - Array of animatable textures.
  103969. */
  103970. getAnimatables(): IAnimatable[];
  103971. /**
  103972. * Returns the texture used for reflections.
  103973. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  103974. */
  103975. private _getReflectionTexture;
  103976. /**
  103977. * Returns the texture used for refraction or null if none is used.
  103978. * @returns - Refection texture if present. If no refraction texture and refraction
  103979. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103980. */
  103981. private _getRefractionTexture;
  103982. /**
  103983. * Returns an array of the actively used textures.
  103984. * @returns - Array of BaseTextures
  103985. */
  103986. getActiveTextures(): BaseTexture[];
  103987. /**
  103988. * Checks to see if a texture is used in the material.
  103989. * @param texture - Base texture to use.
  103990. * @returns - Boolean specifying if a texture is used in the material.
  103991. */
  103992. hasTexture(texture: BaseTexture): boolean;
  103993. /**
  103994. * Disposes the resources of the material.
  103995. * @param forceDisposeEffect - Forces the disposal of effects.
  103996. * @param forceDisposeTextures - Forces the disposal of all textures.
  103997. */
  103998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103999. }
  104000. }
  104001. declare module BABYLON {
  104002. /**
  104003. * The Physically based material of BJS.
  104004. *
  104005. * This offers the main features of a standard PBR material.
  104006. * For more information, please refer to the documentation :
  104007. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104008. */
  104009. export class PBRMaterial extends PBRBaseMaterial {
  104010. /**
  104011. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104012. */
  104013. static readonly PBRMATERIAL_OPAQUE: number;
  104014. /**
  104015. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104016. */
  104017. static readonly PBRMATERIAL_ALPHATEST: number;
  104018. /**
  104019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104020. */
  104021. static readonly PBRMATERIAL_ALPHABLEND: number;
  104022. /**
  104023. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104024. * They are also discarded below the alpha cutoff threshold to improve performances.
  104025. */
  104026. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104027. /**
  104028. * Defines the default value of how much AO map is occluding the analytical lights
  104029. * (point spot...).
  104030. */
  104031. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104032. /**
  104033. * Intensity of the direct lights e.g. the four lights available in your scene.
  104034. * This impacts both the direct diffuse and specular highlights.
  104035. */
  104036. directIntensity: number;
  104037. /**
  104038. * Intensity of the emissive part of the material.
  104039. * This helps controlling the emissive effect without modifying the emissive color.
  104040. */
  104041. emissiveIntensity: number;
  104042. /**
  104043. * Intensity of the environment e.g. how much the environment will light the object
  104044. * either through harmonics for rough material or through the refelction for shiny ones.
  104045. */
  104046. environmentIntensity: number;
  104047. /**
  104048. * This is a special control allowing the reduction of the specular highlights coming from the
  104049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104050. */
  104051. specularIntensity: number;
  104052. /**
  104053. * Debug Control allowing disabling the bump map on this material.
  104054. */
  104055. disableBumpMap: boolean;
  104056. /**
  104057. * AKA Diffuse Texture in standard nomenclature.
  104058. */
  104059. albedoTexture: BaseTexture;
  104060. /**
  104061. * AKA Occlusion Texture in other nomenclature.
  104062. */
  104063. ambientTexture: BaseTexture;
  104064. /**
  104065. * AKA Occlusion Texture Intensity in other nomenclature.
  104066. */
  104067. ambientTextureStrength: number;
  104068. /**
  104069. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104070. * 1 means it completely occludes it
  104071. * 0 mean it has no impact
  104072. */
  104073. ambientTextureImpactOnAnalyticalLights: number;
  104074. /**
  104075. * Stores the alpha values in a texture.
  104076. */
  104077. opacityTexture: BaseTexture;
  104078. /**
  104079. * Stores the reflection values in a texture.
  104080. */
  104081. reflectionTexture: Nullable<BaseTexture>;
  104082. /**
  104083. * Stores the emissive values in a texture.
  104084. */
  104085. emissiveTexture: BaseTexture;
  104086. /**
  104087. * AKA Specular texture in other nomenclature.
  104088. */
  104089. reflectivityTexture: BaseTexture;
  104090. /**
  104091. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104092. */
  104093. metallicTexture: BaseTexture;
  104094. /**
  104095. * Specifies the metallic scalar of the metallic/roughness workflow.
  104096. * Can also be used to scale the metalness values of the metallic texture.
  104097. */
  104098. metallic: Nullable<number>;
  104099. /**
  104100. * Specifies the roughness scalar of the metallic/roughness workflow.
  104101. * Can also be used to scale the roughness values of the metallic texture.
  104102. */
  104103. roughness: Nullable<number>;
  104104. /**
  104105. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104106. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104107. */
  104108. microSurfaceTexture: BaseTexture;
  104109. /**
  104110. * Stores surface normal data used to displace a mesh in a texture.
  104111. */
  104112. bumpTexture: BaseTexture;
  104113. /**
  104114. * Stores the pre-calculated light information of a mesh in a texture.
  104115. */
  104116. lightmapTexture: BaseTexture;
  104117. /**
  104118. * Stores the refracted light information in a texture.
  104119. */
  104120. refractionTexture: BaseTexture;
  104121. /**
  104122. * The color of a material in ambient lighting.
  104123. */
  104124. ambientColor: Color3;
  104125. /**
  104126. * AKA Diffuse Color in other nomenclature.
  104127. */
  104128. albedoColor: Color3;
  104129. /**
  104130. * AKA Specular Color in other nomenclature.
  104131. */
  104132. reflectivityColor: Color3;
  104133. /**
  104134. * The color reflected from the material.
  104135. */
  104136. reflectionColor: Color3;
  104137. /**
  104138. * The color emitted from the material.
  104139. */
  104140. emissiveColor: Color3;
  104141. /**
  104142. * AKA Glossiness in other nomenclature.
  104143. */
  104144. microSurface: number;
  104145. /**
  104146. * source material index of refraction (IOR)' / 'destination material IOR.
  104147. */
  104148. indexOfRefraction: number;
  104149. /**
  104150. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104151. */
  104152. invertRefractionY: boolean;
  104153. /**
  104154. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104155. * Materials half opaque for instance using refraction could benefit from this control.
  104156. */
  104157. linkRefractionWithTransparency: boolean;
  104158. /**
  104159. * If true, the light map contains occlusion information instead of lighting info.
  104160. */
  104161. useLightmapAsShadowmap: boolean;
  104162. /**
  104163. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104164. */
  104165. useAlphaFromAlbedoTexture: boolean;
  104166. /**
  104167. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104168. */
  104169. forceAlphaTest: boolean;
  104170. /**
  104171. * Defines the alpha limits in alpha test mode.
  104172. */
  104173. alphaCutOff: number;
  104174. /**
  104175. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104176. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104177. */
  104178. useSpecularOverAlpha: boolean;
  104179. /**
  104180. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104181. */
  104182. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104183. /**
  104184. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104185. */
  104186. useRoughnessFromMetallicTextureAlpha: boolean;
  104187. /**
  104188. * Specifies if the metallic texture contains the roughness information in its green channel.
  104189. */
  104190. useRoughnessFromMetallicTextureGreen: boolean;
  104191. /**
  104192. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104193. */
  104194. useMetallnessFromMetallicTextureBlue: boolean;
  104195. /**
  104196. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104197. */
  104198. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104199. /**
  104200. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104201. */
  104202. useAmbientInGrayScale: boolean;
  104203. /**
  104204. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104205. * The material will try to infer what glossiness each pixel should be.
  104206. */
  104207. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104208. /**
  104209. * BJS is using an harcoded light falloff based on a manually sets up range.
  104210. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104211. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104212. */
  104213. /**
  104214. * BJS is using an harcoded light falloff based on a manually sets up range.
  104215. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104216. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104217. */
  104218. usePhysicalLightFalloff: boolean;
  104219. /**
  104220. * In order to support the falloff compatibility with gltf, a special mode has been added
  104221. * to reproduce the gltf light falloff.
  104222. */
  104223. /**
  104224. * In order to support the falloff compatibility with gltf, a special mode has been added
  104225. * to reproduce the gltf light falloff.
  104226. */
  104227. useGLTFLightFalloff: boolean;
  104228. /**
  104229. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104230. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104231. */
  104232. useRadianceOverAlpha: boolean;
  104233. /**
  104234. * Allows using an object space normal map (instead of tangent space).
  104235. */
  104236. useObjectSpaceNormalMap: boolean;
  104237. /**
  104238. * Allows using the bump map in parallax mode.
  104239. */
  104240. useParallax: boolean;
  104241. /**
  104242. * Allows using the bump map in parallax occlusion mode.
  104243. */
  104244. useParallaxOcclusion: boolean;
  104245. /**
  104246. * Controls the scale bias of the parallax mode.
  104247. */
  104248. parallaxScaleBias: number;
  104249. /**
  104250. * If sets to true, disables all the lights affecting the material.
  104251. */
  104252. disableLighting: boolean;
  104253. /**
  104254. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104255. */
  104256. forceIrradianceInFragment: boolean;
  104257. /**
  104258. * Number of Simultaneous lights allowed on the material.
  104259. */
  104260. maxSimultaneousLights: number;
  104261. /**
  104262. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104263. */
  104264. invertNormalMapX: boolean;
  104265. /**
  104266. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104267. */
  104268. invertNormalMapY: boolean;
  104269. /**
  104270. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104271. */
  104272. twoSidedLighting: boolean;
  104273. /**
  104274. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104275. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104276. */
  104277. useAlphaFresnel: boolean;
  104278. /**
  104279. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104280. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104281. */
  104282. useLinearAlphaFresnel: boolean;
  104283. /**
  104284. * Let user defines the brdf lookup texture used for IBL.
  104285. * A default 8bit version is embedded but you could point at :
  104286. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104287. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104288. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104289. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104290. */
  104291. environmentBRDFTexture: Nullable<BaseTexture>;
  104292. /**
  104293. * Force normal to face away from face.
  104294. */
  104295. forceNormalForward: boolean;
  104296. /**
  104297. * Enables specular anti aliasing in the PBR shader.
  104298. * It will both interacts on the Geometry for analytical and IBL lighting.
  104299. * It also prefilter the roughness map based on the bump values.
  104300. */
  104301. enableSpecularAntiAliasing: boolean;
  104302. /**
  104303. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104304. * makes the reflect vector face the model (under horizon).
  104305. */
  104306. useHorizonOcclusion: boolean;
  104307. /**
  104308. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104309. * too much the area relying on ambient texture to define their ambient occlusion.
  104310. */
  104311. useRadianceOcclusion: boolean;
  104312. /**
  104313. * If set to true, no lighting calculations will be applied.
  104314. */
  104315. unlit: boolean;
  104316. /**
  104317. * Gets the image processing configuration used either in this material.
  104318. */
  104319. /**
  104320. * Sets the Default image processing configuration used either in the this material.
  104321. *
  104322. * If sets to null, the scene one is in use.
  104323. */
  104324. imageProcessingConfiguration: ImageProcessingConfiguration;
  104325. /**
  104326. * Gets wether the color curves effect is enabled.
  104327. */
  104328. /**
  104329. * Sets wether the color curves effect is enabled.
  104330. */
  104331. cameraColorCurvesEnabled: boolean;
  104332. /**
  104333. * Gets wether the color grading effect is enabled.
  104334. */
  104335. /**
  104336. * Gets wether the color grading effect is enabled.
  104337. */
  104338. cameraColorGradingEnabled: boolean;
  104339. /**
  104340. * Gets wether tonemapping is enabled or not.
  104341. */
  104342. /**
  104343. * Sets wether tonemapping is enabled or not
  104344. */
  104345. cameraToneMappingEnabled: boolean;
  104346. /**
  104347. * The camera exposure used on this material.
  104348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104349. * This corresponds to a photographic exposure.
  104350. */
  104351. /**
  104352. * The camera exposure used on this material.
  104353. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104354. * This corresponds to a photographic exposure.
  104355. */
  104356. cameraExposure: number;
  104357. /**
  104358. * Gets The camera contrast used on this material.
  104359. */
  104360. /**
  104361. * Sets The camera contrast used on this material.
  104362. */
  104363. cameraContrast: number;
  104364. /**
  104365. * Gets the Color Grading 2D Lookup Texture.
  104366. */
  104367. /**
  104368. * Sets the Color Grading 2D Lookup Texture.
  104369. */
  104370. cameraColorGradingTexture: Nullable<BaseTexture>;
  104371. /**
  104372. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104373. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104374. * 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;
  104375. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104376. */
  104377. /**
  104378. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104379. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104380. * 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;
  104381. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104382. */
  104383. cameraColorCurves: Nullable<ColorCurves>;
  104384. /**
  104385. * Instantiates a new PBRMaterial instance.
  104386. *
  104387. * @param name The material name
  104388. * @param scene The scene the material will be use in.
  104389. */
  104390. constructor(name: string, scene: Scene);
  104391. /**
  104392. * Returns the name of this material class.
  104393. */
  104394. getClassName(): string;
  104395. /**
  104396. * Makes a duplicate of the current material.
  104397. * @param name - name to use for the new material.
  104398. */
  104399. clone(name: string): PBRMaterial;
  104400. /**
  104401. * Serializes this PBR Material.
  104402. * @returns - An object with the serialized material.
  104403. */
  104404. serialize(): any;
  104405. /**
  104406. * Parses a PBR Material from a serialized object.
  104407. * @param source - Serialized object.
  104408. * @param scene - BJS scene instance.
  104409. * @param rootUrl - url for the scene object
  104410. * @returns - PBRMaterial
  104411. */
  104412. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104413. }
  104414. }
  104415. declare module BABYLON {
  104416. /**
  104417. * Direct draw surface info
  104418. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104419. */
  104420. export interface DDSInfo {
  104421. /**
  104422. * Width of the texture
  104423. */
  104424. width: number;
  104425. /**
  104426. * Width of the texture
  104427. */
  104428. height: number;
  104429. /**
  104430. * Number of Mipmaps for the texture
  104431. * @see https://en.wikipedia.org/wiki/Mipmap
  104432. */
  104433. mipmapCount: number;
  104434. /**
  104435. * If the textures format is a known fourCC format
  104436. * @see https://www.fourcc.org/
  104437. */
  104438. isFourCC: boolean;
  104439. /**
  104440. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104441. */
  104442. isRGB: boolean;
  104443. /**
  104444. * If the texture is a lumincance format
  104445. */
  104446. isLuminance: boolean;
  104447. /**
  104448. * If this is a cube texture
  104449. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104450. */
  104451. isCube: boolean;
  104452. /**
  104453. * If the texture is a compressed format eg. FOURCC_DXT1
  104454. */
  104455. isCompressed: boolean;
  104456. /**
  104457. * The dxgiFormat of the texture
  104458. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104459. */
  104460. dxgiFormat: number;
  104461. /**
  104462. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104463. */
  104464. textureType: number;
  104465. /**
  104466. * Sphericle polynomial created for the dds texture
  104467. */
  104468. sphericalPolynomial?: SphericalPolynomial;
  104469. }
  104470. /**
  104471. * Class used to provide DDS decompression tools
  104472. */
  104473. export class DDSTools {
  104474. /**
  104475. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104476. */
  104477. static StoreLODInAlphaChannel: boolean;
  104478. /**
  104479. * Gets DDS information from an array buffer
  104480. * @param arrayBuffer defines the array buffer to read data from
  104481. * @returns the DDS information
  104482. */
  104483. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104484. private static _FloatView;
  104485. private static _Int32View;
  104486. private static _ToHalfFloat;
  104487. private static _FromHalfFloat;
  104488. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104489. private static _GetHalfFloatRGBAArrayBuffer;
  104490. private static _GetFloatRGBAArrayBuffer;
  104491. private static _GetFloatAsUIntRGBAArrayBuffer;
  104492. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104493. private static _GetRGBAArrayBuffer;
  104494. private static _ExtractLongWordOrder;
  104495. private static _GetRGBArrayBuffer;
  104496. private static _GetLuminanceArrayBuffer;
  104497. /**
  104498. * Uploads DDS Levels to a Babylon Texture
  104499. * @hidden
  104500. */
  104501. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104502. }
  104503. interface Engine {
  104504. /**
  104505. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104506. * @param rootUrl defines the url where the file to load is located
  104507. * @param scene defines the current scene
  104508. * @param lodScale defines scale to apply to the mip map selection
  104509. * @param lodOffset defines offset to apply to the mip map selection
  104510. * @param onLoad defines an optional callback raised when the texture is loaded
  104511. * @param onError defines an optional callback raised if there is an issue to load the texture
  104512. * @param format defines the format of the data
  104513. * @param forcedExtension defines the extension to use to pick the right loader
  104514. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104515. * @returns the cube texture as an InternalTexture
  104516. */
  104517. 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;
  104518. }
  104519. }
  104520. declare module BABYLON {
  104521. /**
  104522. * Implementation of the DDS Texture Loader.
  104523. * @hidden
  104524. */
  104525. export class _DDSTextureLoader implements IInternalTextureLoader {
  104526. /**
  104527. * Defines wether the loader supports cascade loading the different faces.
  104528. */
  104529. readonly supportCascades: boolean;
  104530. /**
  104531. * This returns if the loader support the current file information.
  104532. * @param extension defines the file extension of the file being loaded
  104533. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104534. * @param fallback defines the fallback internal texture if any
  104535. * @param isBase64 defines whether the texture is encoded as a base64
  104536. * @param isBuffer defines whether the texture data are stored as a buffer
  104537. * @returns true if the loader can load the specified file
  104538. */
  104539. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104540. /**
  104541. * Transform the url before loading if required.
  104542. * @param rootUrl the url of the texture
  104543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104544. * @returns the transformed texture
  104545. */
  104546. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104547. /**
  104548. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104549. * @param rootUrl the url of the texture
  104550. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104551. * @returns the fallback texture
  104552. */
  104553. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104554. /**
  104555. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104556. * @param data contains the texture data
  104557. * @param texture defines the BabylonJS internal texture
  104558. * @param createPolynomials will be true if polynomials have been requested
  104559. * @param onLoad defines the callback to trigger once the texture is ready
  104560. * @param onError defines the callback to trigger in case of error
  104561. */
  104562. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104563. /**
  104564. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104565. * @param data contains the texture data
  104566. * @param texture defines the BabylonJS internal texture
  104567. * @param callback defines the method to call once ready to upload
  104568. */
  104569. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104570. }
  104571. }
  104572. declare module BABYLON {
  104573. /** @hidden */
  104574. export var rgbdEncodePixelShader: {
  104575. name: string;
  104576. shader: string;
  104577. };
  104578. }
  104579. declare module BABYLON {
  104580. /** @hidden */
  104581. export var rgbdDecodePixelShader: {
  104582. name: string;
  104583. shader: string;
  104584. };
  104585. }
  104586. declare module BABYLON {
  104587. /**
  104588. * Raw texture data and descriptor sufficient for WebGL texture upload
  104589. */
  104590. export interface EnvironmentTextureInfo {
  104591. /**
  104592. * Version of the environment map
  104593. */
  104594. version: number;
  104595. /**
  104596. * Width of image
  104597. */
  104598. width: number;
  104599. /**
  104600. * Irradiance information stored in the file.
  104601. */
  104602. irradiance: any;
  104603. /**
  104604. * Specular information stored in the file.
  104605. */
  104606. specular: any;
  104607. }
  104608. /**
  104609. * Sets of helpers addressing the serialization and deserialization of environment texture
  104610. * stored in a BabylonJS env file.
  104611. * Those files are usually stored as .env files.
  104612. */
  104613. export class EnvironmentTextureTools {
  104614. /**
  104615. * Magic number identifying the env file.
  104616. */
  104617. private static _MagicBytes;
  104618. /**
  104619. * Gets the environment info from an env file.
  104620. * @param data The array buffer containing the .env bytes.
  104621. * @returns the environment file info (the json header) if successfully parsed.
  104622. */
  104623. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104624. /**
  104625. * Creates an environment texture from a loaded cube texture.
  104626. * @param texture defines the cube texture to convert in env file
  104627. * @return a promise containing the environment data if succesfull.
  104628. */
  104629. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104630. /**
  104631. * Creates a JSON representation of the spherical data.
  104632. * @param texture defines the texture containing the polynomials
  104633. * @return the JSON representation of the spherical info
  104634. */
  104635. private static _CreateEnvTextureIrradiance;
  104636. /**
  104637. * Uploads the texture info contained in the env file to the GPU.
  104638. * @param texture defines the internal texture to upload to
  104639. * @param arrayBuffer defines the buffer cotaining the data to load
  104640. * @param info defines the texture info retrieved through the GetEnvInfo method
  104641. * @returns a promise
  104642. */
  104643. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104644. /**
  104645. * Uploads the levels of image data to the GPU.
  104646. * @param texture defines the internal texture to upload to
  104647. * @param imageData defines the array buffer views of image data [mipmap][face]
  104648. * @returns a promise
  104649. */
  104650. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104651. /**
  104652. * Uploads spherical polynomials information to the texture.
  104653. * @param texture defines the texture we are trying to upload the information to
  104654. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104655. */
  104656. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104657. /** @hidden */
  104658. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104659. }
  104660. }
  104661. declare module BABYLON {
  104662. /**
  104663. * Implementation of the ENV Texture Loader.
  104664. * @hidden
  104665. */
  104666. export class _ENVTextureLoader implements IInternalTextureLoader {
  104667. /**
  104668. * Defines wether the loader supports cascade loading the different faces.
  104669. */
  104670. readonly supportCascades: boolean;
  104671. /**
  104672. * This returns if the loader support the current file information.
  104673. * @param extension defines the file extension of the file being loaded
  104674. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104675. * @param fallback defines the fallback internal texture if any
  104676. * @param isBase64 defines whether the texture is encoded as a base64
  104677. * @param isBuffer defines whether the texture data are stored as a buffer
  104678. * @returns true if the loader can load the specified file
  104679. */
  104680. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104681. /**
  104682. * Transform the url before loading if required.
  104683. * @param rootUrl the url of the texture
  104684. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104685. * @returns the transformed texture
  104686. */
  104687. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104688. /**
  104689. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104690. * @param rootUrl the url of the texture
  104691. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104692. * @returns the fallback texture
  104693. */
  104694. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104695. /**
  104696. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104697. * @param data contains the texture data
  104698. * @param texture defines the BabylonJS internal texture
  104699. * @param createPolynomials will be true if polynomials have been requested
  104700. * @param onLoad defines the callback to trigger once the texture is ready
  104701. * @param onError defines the callback to trigger in case of error
  104702. */
  104703. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104704. /**
  104705. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104706. * @param data contains the texture data
  104707. * @param texture defines the BabylonJS internal texture
  104708. * @param callback defines the method to call once ready to upload
  104709. */
  104710. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104711. }
  104712. }
  104713. declare module BABYLON {
  104714. /**
  104715. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104716. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104717. */
  104718. export class KhronosTextureContainer {
  104719. /** contents of the KTX container file */
  104720. arrayBuffer: any;
  104721. private static HEADER_LEN;
  104722. private static COMPRESSED_2D;
  104723. private static COMPRESSED_3D;
  104724. private static TEX_2D;
  104725. private static TEX_3D;
  104726. /**
  104727. * Gets the openGL type
  104728. */
  104729. glType: number;
  104730. /**
  104731. * Gets the openGL type size
  104732. */
  104733. glTypeSize: number;
  104734. /**
  104735. * Gets the openGL format
  104736. */
  104737. glFormat: number;
  104738. /**
  104739. * Gets the openGL internal format
  104740. */
  104741. glInternalFormat: number;
  104742. /**
  104743. * Gets the base internal format
  104744. */
  104745. glBaseInternalFormat: number;
  104746. /**
  104747. * Gets image width in pixel
  104748. */
  104749. pixelWidth: number;
  104750. /**
  104751. * Gets image height in pixel
  104752. */
  104753. pixelHeight: number;
  104754. /**
  104755. * Gets image depth in pixels
  104756. */
  104757. pixelDepth: number;
  104758. /**
  104759. * Gets the number of array elements
  104760. */
  104761. numberOfArrayElements: number;
  104762. /**
  104763. * Gets the number of faces
  104764. */
  104765. numberOfFaces: number;
  104766. /**
  104767. * Gets the number of mipmap levels
  104768. */
  104769. numberOfMipmapLevels: number;
  104770. /**
  104771. * Gets the bytes of key value data
  104772. */
  104773. bytesOfKeyValueData: number;
  104774. /**
  104775. * Gets the load type
  104776. */
  104777. loadType: number;
  104778. /**
  104779. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104780. */
  104781. isInvalid: boolean;
  104782. /**
  104783. * Creates a new KhronosTextureContainer
  104784. * @param arrayBuffer contents of the KTX container file
  104785. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104786. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104787. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104788. */
  104789. constructor(
  104790. /** contents of the KTX container file */
  104791. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104792. /**
  104793. * Uploads KTX content to a Babylon Texture.
  104794. * It is assumed that the texture has already been created & is currently bound
  104795. * @hidden
  104796. */
  104797. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104798. private _upload2DCompressedLevels;
  104799. }
  104800. }
  104801. declare module BABYLON {
  104802. /**
  104803. * Implementation of the KTX Texture Loader.
  104804. * @hidden
  104805. */
  104806. export class _KTXTextureLoader implements IInternalTextureLoader {
  104807. /**
  104808. * Defines wether the loader supports cascade loading the different faces.
  104809. */
  104810. readonly supportCascades: boolean;
  104811. /**
  104812. * This returns if the loader support the current file information.
  104813. * @param extension defines the file extension of the file being loaded
  104814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104815. * @param fallback defines the fallback internal texture if any
  104816. * @param isBase64 defines whether the texture is encoded as a base64
  104817. * @param isBuffer defines whether the texture data are stored as a buffer
  104818. * @returns true if the loader can load the specified file
  104819. */
  104820. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104821. /**
  104822. * Transform the url before loading if required.
  104823. * @param rootUrl the url of the texture
  104824. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104825. * @returns the transformed texture
  104826. */
  104827. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104828. /**
  104829. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104830. * @param rootUrl the url of the texture
  104831. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104832. * @returns the fallback texture
  104833. */
  104834. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104835. /**
  104836. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104837. * @param data contains the texture data
  104838. * @param texture defines the BabylonJS internal texture
  104839. * @param createPolynomials will be true if polynomials have been requested
  104840. * @param onLoad defines the callback to trigger once the texture is ready
  104841. * @param onError defines the callback to trigger in case of error
  104842. */
  104843. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104844. /**
  104845. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104846. * @param data contains the texture data
  104847. * @param texture defines the BabylonJS internal texture
  104848. * @param callback defines the method to call once ready to upload
  104849. */
  104850. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104851. }
  104852. }
  104853. declare module BABYLON {
  104854. /** @hidden */
  104855. export var _forceSceneHelpersToBundle: boolean;
  104856. interface Scene {
  104857. /**
  104858. * Creates a default light for the scene.
  104859. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  104860. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  104861. */
  104862. createDefaultLight(replace?: boolean): void;
  104863. /**
  104864. * Creates a default camera for the scene.
  104865. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  104866. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  104867. * @param replace has default false, when true replaces the active camera in the scene
  104868. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  104869. */
  104870. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  104871. /**
  104872. * Creates a default camera and a default light.
  104873. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  104874. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  104875. * @param replace has the default false, when true replaces the active camera/light in the scene
  104876. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  104877. */
  104878. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  104879. /**
  104880. * Creates a new sky box
  104881. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  104882. * @param environmentTexture defines the texture to use as environment texture
  104883. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  104884. * @param scale defines the overall scale of the skybox
  104885. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  104886. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  104887. * @returns a new mesh holding the sky box
  104888. */
  104889. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  104890. /**
  104891. * Creates a new environment
  104892. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  104893. * @param options defines the options you can use to configure the environment
  104894. * @returns the new EnvironmentHelper
  104895. */
  104896. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  104897. /**
  104898. * Creates a new VREXperienceHelper
  104899. * @see http://doc.babylonjs.com/how_to/webvr_helper
  104900. * @param webVROptions defines the options used to create the new VREXperienceHelper
  104901. * @returns a new VREXperienceHelper
  104902. */
  104903. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  104904. /**
  104905. * Creates a new XREXperienceHelper
  104906. * @see http://doc.babylonjs.com/how_to/webxr
  104907. * @returns a promise for a new XREXperienceHelper
  104908. */
  104909. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  104910. }
  104911. }
  104912. declare module BABYLON {
  104913. /**
  104914. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  104915. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  104916. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  104917. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  104918. */
  104919. export class VideoDome extends TransformNode {
  104920. /**
  104921. * Define the video source as a Monoscopic panoramic 360 video.
  104922. */
  104923. static readonly MODE_MONOSCOPIC: number;
  104924. /**
  104925. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  104926. */
  104927. static readonly MODE_TOPBOTTOM: number;
  104928. /**
  104929. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  104930. */
  104931. static readonly MODE_SIDEBYSIDE: number;
  104932. private _useDirectMapping;
  104933. /**
  104934. * The video texture being displayed on the sphere
  104935. */
  104936. protected _videoTexture: VideoTexture;
  104937. /**
  104938. * Gets the video texture being displayed on the sphere
  104939. */
  104940. readonly videoTexture: VideoTexture;
  104941. /**
  104942. * The skybox material
  104943. */
  104944. protected _material: BackgroundMaterial;
  104945. /**
  104946. * The surface used for the skybox
  104947. */
  104948. protected _mesh: Mesh;
  104949. /**
  104950. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  104951. * Also see the options.resolution property.
  104952. */
  104953. fovMultiplier: number;
  104954. private _videoMode;
  104955. /**
  104956. * Gets or set the current video mode for the video. It can be:
  104957. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  104958. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  104959. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  104960. */
  104961. videoMode: number;
  104962. /**
  104963. * Oberserver used in Stereoscopic VR Mode.
  104964. */
  104965. private _onBeforeCameraRenderObserver;
  104966. /**
  104967. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  104968. * @param name Element's name, child elements will append suffixes for their own names.
  104969. * @param urlsOrVideo defines the url(s) or the video element to use
  104970. * @param options An object containing optional or exposed sub element properties
  104971. */
  104972. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  104973. resolution?: number;
  104974. clickToPlay?: boolean;
  104975. autoPlay?: boolean;
  104976. loop?: boolean;
  104977. size?: number;
  104978. poster?: string;
  104979. faceForward?: boolean;
  104980. useDirectMapping?: boolean;
  104981. }, scene: Scene);
  104982. private _changeVideoMode;
  104983. /**
  104984. * Releases resources associated with this node.
  104985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104987. */
  104988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104989. }
  104990. }
  104991. declare module BABYLON {
  104992. /**
  104993. * This class can be used to get instrumentation data from a Babylon engine
  104994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104995. */
  104996. export class EngineInstrumentation implements IDisposable {
  104997. /**
  104998. * Define the instrumented engine.
  104999. */
  105000. engine: Engine;
  105001. private _captureGPUFrameTime;
  105002. private _gpuFrameTimeToken;
  105003. private _gpuFrameTime;
  105004. private _captureShaderCompilationTime;
  105005. private _shaderCompilationTime;
  105006. private _onBeginFrameObserver;
  105007. private _onEndFrameObserver;
  105008. private _onBeforeShaderCompilationObserver;
  105009. private _onAfterShaderCompilationObserver;
  105010. /**
  105011. * Gets the perf counter used for GPU frame time
  105012. */
  105013. readonly gpuFrameTimeCounter: PerfCounter;
  105014. /**
  105015. * Gets the GPU frame time capture status
  105016. */
  105017. /**
  105018. * Enable or disable the GPU frame time capture
  105019. */
  105020. captureGPUFrameTime: boolean;
  105021. /**
  105022. * Gets the perf counter used for shader compilation time
  105023. */
  105024. readonly shaderCompilationTimeCounter: PerfCounter;
  105025. /**
  105026. * Gets the shader compilation time capture status
  105027. */
  105028. /**
  105029. * Enable or disable the shader compilation time capture
  105030. */
  105031. captureShaderCompilationTime: boolean;
  105032. /**
  105033. * Instantiates a new engine instrumentation.
  105034. * This class can be used to get instrumentation data from a Babylon engine
  105035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105036. * @param engine Defines the engine to instrument
  105037. */
  105038. constructor(
  105039. /**
  105040. * Define the instrumented engine.
  105041. */
  105042. engine: Engine);
  105043. /**
  105044. * Dispose and release associated resources.
  105045. */
  105046. dispose(): void;
  105047. }
  105048. }
  105049. declare module BABYLON {
  105050. /**
  105051. * This class can be used to get instrumentation data from a Babylon engine
  105052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105053. */
  105054. export class SceneInstrumentation implements IDisposable {
  105055. /**
  105056. * Defines the scene to instrument
  105057. */
  105058. scene: Scene;
  105059. private _captureActiveMeshesEvaluationTime;
  105060. private _activeMeshesEvaluationTime;
  105061. private _captureRenderTargetsRenderTime;
  105062. private _renderTargetsRenderTime;
  105063. private _captureFrameTime;
  105064. private _frameTime;
  105065. private _captureRenderTime;
  105066. private _renderTime;
  105067. private _captureInterFrameTime;
  105068. private _interFrameTime;
  105069. private _captureParticlesRenderTime;
  105070. private _particlesRenderTime;
  105071. private _captureSpritesRenderTime;
  105072. private _spritesRenderTime;
  105073. private _capturePhysicsTime;
  105074. private _physicsTime;
  105075. private _captureAnimationsTime;
  105076. private _animationsTime;
  105077. private _captureCameraRenderTime;
  105078. private _cameraRenderTime;
  105079. private _onBeforeActiveMeshesEvaluationObserver;
  105080. private _onAfterActiveMeshesEvaluationObserver;
  105081. private _onBeforeRenderTargetsRenderObserver;
  105082. private _onAfterRenderTargetsRenderObserver;
  105083. private _onAfterRenderObserver;
  105084. private _onBeforeDrawPhaseObserver;
  105085. private _onAfterDrawPhaseObserver;
  105086. private _onBeforeAnimationsObserver;
  105087. private _onBeforeParticlesRenderingObserver;
  105088. private _onAfterParticlesRenderingObserver;
  105089. private _onBeforeSpritesRenderingObserver;
  105090. private _onAfterSpritesRenderingObserver;
  105091. private _onBeforePhysicsObserver;
  105092. private _onAfterPhysicsObserver;
  105093. private _onAfterAnimationsObserver;
  105094. private _onBeforeCameraRenderObserver;
  105095. private _onAfterCameraRenderObserver;
  105096. /**
  105097. * Gets the perf counter used for active meshes evaluation time
  105098. */
  105099. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105100. /**
  105101. * Gets the active meshes evaluation time capture status
  105102. */
  105103. /**
  105104. * Enable or disable the active meshes evaluation time capture
  105105. */
  105106. captureActiveMeshesEvaluationTime: boolean;
  105107. /**
  105108. * Gets the perf counter used for render targets render time
  105109. */
  105110. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105111. /**
  105112. * Gets the render targets render time capture status
  105113. */
  105114. /**
  105115. * Enable or disable the render targets render time capture
  105116. */
  105117. captureRenderTargetsRenderTime: boolean;
  105118. /**
  105119. * Gets the perf counter used for particles render time
  105120. */
  105121. readonly particlesRenderTimeCounter: PerfCounter;
  105122. /**
  105123. * Gets the particles render time capture status
  105124. */
  105125. /**
  105126. * Enable or disable the particles render time capture
  105127. */
  105128. captureParticlesRenderTime: boolean;
  105129. /**
  105130. * Gets the perf counter used for sprites render time
  105131. */
  105132. readonly spritesRenderTimeCounter: PerfCounter;
  105133. /**
  105134. * Gets the sprites render time capture status
  105135. */
  105136. /**
  105137. * Enable or disable the sprites render time capture
  105138. */
  105139. captureSpritesRenderTime: boolean;
  105140. /**
  105141. * Gets the perf counter used for physics time
  105142. */
  105143. readonly physicsTimeCounter: PerfCounter;
  105144. /**
  105145. * Gets the physics time capture status
  105146. */
  105147. /**
  105148. * Enable or disable the physics time capture
  105149. */
  105150. capturePhysicsTime: boolean;
  105151. /**
  105152. * Gets the perf counter used for animations time
  105153. */
  105154. readonly animationsTimeCounter: PerfCounter;
  105155. /**
  105156. * Gets the animations time capture status
  105157. */
  105158. /**
  105159. * Enable or disable the animations time capture
  105160. */
  105161. captureAnimationsTime: boolean;
  105162. /**
  105163. * Gets the perf counter used for frame time capture
  105164. */
  105165. readonly frameTimeCounter: PerfCounter;
  105166. /**
  105167. * Gets the frame time capture status
  105168. */
  105169. /**
  105170. * Enable or disable the frame time capture
  105171. */
  105172. captureFrameTime: boolean;
  105173. /**
  105174. * Gets the perf counter used for inter-frames time capture
  105175. */
  105176. readonly interFrameTimeCounter: PerfCounter;
  105177. /**
  105178. * Gets the inter-frames time capture status
  105179. */
  105180. /**
  105181. * Enable or disable the inter-frames time capture
  105182. */
  105183. captureInterFrameTime: boolean;
  105184. /**
  105185. * Gets the perf counter used for render time capture
  105186. */
  105187. readonly renderTimeCounter: PerfCounter;
  105188. /**
  105189. * Gets the render time capture status
  105190. */
  105191. /**
  105192. * Enable or disable the render time capture
  105193. */
  105194. captureRenderTime: boolean;
  105195. /**
  105196. * Gets the perf counter used for camera render time capture
  105197. */
  105198. readonly cameraRenderTimeCounter: PerfCounter;
  105199. /**
  105200. * Gets the camera render time capture status
  105201. */
  105202. /**
  105203. * Enable or disable the camera render time capture
  105204. */
  105205. captureCameraRenderTime: boolean;
  105206. /**
  105207. * Gets the perf counter used for draw calls
  105208. */
  105209. readonly drawCallsCounter: PerfCounter;
  105210. /**
  105211. * Gets the perf counter used for texture collisions
  105212. */
  105213. readonly textureCollisionsCounter: PerfCounter;
  105214. /**
  105215. * Instantiates a new scene instrumentation.
  105216. * This class can be used to get instrumentation data from a Babylon engine
  105217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105218. * @param scene Defines the scene to instrument
  105219. */
  105220. constructor(
  105221. /**
  105222. * Defines the scene to instrument
  105223. */
  105224. scene: Scene);
  105225. /**
  105226. * Dispose and release associated resources.
  105227. */
  105228. dispose(): void;
  105229. }
  105230. }
  105231. declare module BABYLON {
  105232. /** @hidden */
  105233. export var glowMapGenerationPixelShader: {
  105234. name: string;
  105235. shader: string;
  105236. };
  105237. }
  105238. declare module BABYLON {
  105239. /** @hidden */
  105240. export var glowMapGenerationVertexShader: {
  105241. name: string;
  105242. shader: string;
  105243. };
  105244. }
  105245. declare module BABYLON {
  105246. /**
  105247. * Effect layer options. This helps customizing the behaviour
  105248. * of the effect layer.
  105249. */
  105250. export interface IEffectLayerOptions {
  105251. /**
  105252. * Multiplication factor apply to the canvas size to compute the render target size
  105253. * used to generated the objects (the smaller the faster).
  105254. */
  105255. mainTextureRatio: number;
  105256. /**
  105257. * Enforces a fixed size texture to ensure effect stability across devices.
  105258. */
  105259. mainTextureFixedSize?: number;
  105260. /**
  105261. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105262. */
  105263. alphaBlendingMode: number;
  105264. /**
  105265. * The camera attached to the layer.
  105266. */
  105267. camera: Nullable<Camera>;
  105268. /**
  105269. * The rendering group to draw the layer in.
  105270. */
  105271. renderingGroupId: number;
  105272. }
  105273. /**
  105274. * The effect layer Helps adding post process effect blended with the main pass.
  105275. *
  105276. * This can be for instance use to generate glow or higlight effects on the scene.
  105277. *
  105278. * The effect layer class can not be used directly and is intented to inherited from to be
  105279. * customized per effects.
  105280. */
  105281. export abstract class EffectLayer {
  105282. private _vertexBuffers;
  105283. private _indexBuffer;
  105284. private _cachedDefines;
  105285. private _effectLayerMapGenerationEffect;
  105286. private _effectLayerOptions;
  105287. private _mergeEffect;
  105288. protected _scene: Scene;
  105289. protected _engine: Engine;
  105290. protected _maxSize: number;
  105291. protected _mainTextureDesiredSize: ISize;
  105292. protected _mainTexture: RenderTargetTexture;
  105293. protected _shouldRender: boolean;
  105294. protected _postProcesses: PostProcess[];
  105295. protected _textures: BaseTexture[];
  105296. protected _emissiveTextureAndColor: {
  105297. texture: Nullable<BaseTexture>;
  105298. color: Color4;
  105299. };
  105300. /**
  105301. * The name of the layer
  105302. */
  105303. name: string;
  105304. /**
  105305. * The clear color of the texture used to generate the glow map.
  105306. */
  105307. neutralColor: Color4;
  105308. /**
  105309. * Specifies wether the highlight layer is enabled or not.
  105310. */
  105311. isEnabled: boolean;
  105312. /**
  105313. * Gets the camera attached to the layer.
  105314. */
  105315. readonly camera: Nullable<Camera>;
  105316. /**
  105317. * Gets the rendering group id the layer should render in.
  105318. */
  105319. readonly renderingGroupId: number;
  105320. /**
  105321. * An event triggered when the effect layer has been disposed.
  105322. */
  105323. onDisposeObservable: Observable<EffectLayer>;
  105324. /**
  105325. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105326. */
  105327. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105328. /**
  105329. * An event triggered when the generated texture is being merged in the scene.
  105330. */
  105331. onBeforeComposeObservable: Observable<EffectLayer>;
  105332. /**
  105333. * An event triggered when the generated texture has been merged in the scene.
  105334. */
  105335. onAfterComposeObservable: Observable<EffectLayer>;
  105336. /**
  105337. * An event triggered when the efffect layer changes its size.
  105338. */
  105339. onSizeChangedObservable: Observable<EffectLayer>;
  105340. /** @hidden */
  105341. static _SceneComponentInitialization: (scene: Scene) => void;
  105342. /**
  105343. * Instantiates a new effect Layer and references it in the scene.
  105344. * @param name The name of the layer
  105345. * @param scene The scene to use the layer in
  105346. */
  105347. constructor(
  105348. /** The Friendly of the effect in the scene */
  105349. name: string, scene: Scene);
  105350. /**
  105351. * Get the effect name of the layer.
  105352. * @return The effect name
  105353. */
  105354. abstract getEffectName(): string;
  105355. /**
  105356. * Checks for the readiness of the element composing the layer.
  105357. * @param subMesh the mesh to check for
  105358. * @param useInstances specify wether or not to use instances to render the mesh
  105359. * @return true if ready otherwise, false
  105360. */
  105361. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105362. /**
  105363. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105364. * @returns true if the effect requires stencil during the main canvas render pass.
  105365. */
  105366. abstract needStencil(): boolean;
  105367. /**
  105368. * Create the merge effect. This is the shader use to blit the information back
  105369. * to the main canvas at the end of the scene rendering.
  105370. * @returns The effect containing the shader used to merge the effect on the main canvas
  105371. */
  105372. protected abstract _createMergeEffect(): Effect;
  105373. /**
  105374. * Creates the render target textures and post processes used in the effect layer.
  105375. */
  105376. protected abstract _createTextureAndPostProcesses(): void;
  105377. /**
  105378. * Implementation specific of rendering the generating effect on the main canvas.
  105379. * @param effect The effect used to render through
  105380. */
  105381. protected abstract _internalRender(effect: Effect): void;
  105382. /**
  105383. * Sets the required values for both the emissive texture and and the main color.
  105384. */
  105385. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105386. /**
  105387. * Free any resources and references associated to a mesh.
  105388. * Internal use
  105389. * @param mesh The mesh to free.
  105390. */
  105391. abstract _disposeMesh(mesh: Mesh): void;
  105392. /**
  105393. * Serializes this layer (Glow or Highlight for example)
  105394. * @returns a serialized layer object
  105395. */
  105396. abstract serialize?(): any;
  105397. /**
  105398. * Initializes the effect layer with the required options.
  105399. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105400. */
  105401. protected _init(options: Partial<IEffectLayerOptions>): void;
  105402. /**
  105403. * Generates the index buffer of the full screen quad blending to the main canvas.
  105404. */
  105405. private _generateIndexBuffer;
  105406. /**
  105407. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105408. */
  105409. private _genrateVertexBuffer;
  105410. /**
  105411. * Sets the main texture desired size which is the closest power of two
  105412. * of the engine canvas size.
  105413. */
  105414. private _setMainTextureSize;
  105415. /**
  105416. * Creates the main texture for the effect layer.
  105417. */
  105418. protected _createMainTexture(): void;
  105419. /**
  105420. * Adds specific effects defines.
  105421. * @param defines The defines to add specifics to.
  105422. */
  105423. protected _addCustomEffectDefines(defines: string[]): void;
  105424. /**
  105425. * Checks for the readiness of the element composing the layer.
  105426. * @param subMesh the mesh to check for
  105427. * @param useInstances specify wether or not to use instances to render the mesh
  105428. * @param emissiveTexture the associated emissive texture used to generate the glow
  105429. * @return true if ready otherwise, false
  105430. */
  105431. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105432. /**
  105433. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105434. */
  105435. render(): void;
  105436. /**
  105437. * Determine if a given mesh will be used in the current effect.
  105438. * @param mesh mesh to test
  105439. * @returns true if the mesh will be used
  105440. */
  105441. hasMesh(mesh: AbstractMesh): boolean;
  105442. /**
  105443. * Returns true if the layer contains information to display, otherwise false.
  105444. * @returns true if the glow layer should be rendered
  105445. */
  105446. shouldRender(): boolean;
  105447. /**
  105448. * Returns true if the mesh should render, otherwise false.
  105449. * @param mesh The mesh to render
  105450. * @returns true if it should render otherwise false
  105451. */
  105452. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105453. /**
  105454. * Returns true if the mesh can be rendered, otherwise false.
  105455. * @param mesh The mesh to render
  105456. * @param material The material used on the mesh
  105457. * @returns true if it can be rendered otherwise false
  105458. */
  105459. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105460. /**
  105461. * Returns true if the mesh should render, otherwise false.
  105462. * @param mesh The mesh to render
  105463. * @returns true if it should render otherwise false
  105464. */
  105465. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  105466. /**
  105467. * Renders the submesh passed in parameter to the generation map.
  105468. */
  105469. protected _renderSubMesh(subMesh: SubMesh): void;
  105470. /**
  105471. * Rebuild the required buffers.
  105472. * @hidden Internal use only.
  105473. */
  105474. _rebuild(): void;
  105475. /**
  105476. * Dispose only the render target textures and post process.
  105477. */
  105478. private _disposeTextureAndPostProcesses;
  105479. /**
  105480. * Dispose the highlight layer and free resources.
  105481. */
  105482. dispose(): void;
  105483. /**
  105484. * Gets the class name of the effect layer
  105485. * @returns the string with the class name of the effect layer
  105486. */
  105487. getClassName(): string;
  105488. /**
  105489. * Creates an effect layer from parsed effect layer data
  105490. * @param parsedEffectLayer defines effect layer data
  105491. * @param scene defines the current scene
  105492. * @param rootUrl defines the root URL containing the effect layer information
  105493. * @returns a parsed effect Layer
  105494. */
  105495. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  105496. }
  105497. }
  105498. declare module BABYLON {
  105499. interface AbstractScene {
  105500. /**
  105501. * The list of effect layers (highlights/glow) added to the scene
  105502. * @see http://doc.babylonjs.com/how_to/highlight_layer
  105503. * @see http://doc.babylonjs.com/how_to/glow_layer
  105504. */
  105505. effectLayers: Array<EffectLayer>;
  105506. /**
  105507. * Removes the given effect layer from this scene.
  105508. * @param toRemove defines the effect layer to remove
  105509. * @returns the index of the removed effect layer
  105510. */
  105511. removeEffectLayer(toRemove: EffectLayer): number;
  105512. /**
  105513. * Adds the given effect layer to this scene
  105514. * @param newEffectLayer defines the effect layer to add
  105515. */
  105516. addEffectLayer(newEffectLayer: EffectLayer): void;
  105517. }
  105518. /**
  105519. * Defines the layer scene component responsible to manage any effect layers
  105520. * in a given scene.
  105521. */
  105522. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  105523. /**
  105524. * The component name helpfull to identify the component in the list of scene components.
  105525. */
  105526. readonly name: string;
  105527. /**
  105528. * The scene the component belongs to.
  105529. */
  105530. scene: Scene;
  105531. private _engine;
  105532. private _renderEffects;
  105533. private _needStencil;
  105534. private _previousStencilState;
  105535. /**
  105536. * Creates a new instance of the component for the given scene
  105537. * @param scene Defines the scene to register the component in
  105538. */
  105539. constructor(scene: Scene);
  105540. /**
  105541. * Registers the component in a given scene
  105542. */
  105543. register(): void;
  105544. /**
  105545. * Rebuilds the elements related to this component in case of
  105546. * context lost for instance.
  105547. */
  105548. rebuild(): void;
  105549. /**
  105550. * Serializes the component data to the specified json object
  105551. * @param serializationObject The object to serialize to
  105552. */
  105553. serialize(serializationObject: any): void;
  105554. /**
  105555. * Adds all the element from the container to the scene
  105556. * @param container the container holding the elements
  105557. */
  105558. addFromContainer(container: AbstractScene): void;
  105559. /**
  105560. * Removes all the elements in the container from the scene
  105561. * @param container contains the elements to remove
  105562. * @param dispose if the removed element should be disposed (default: false)
  105563. */
  105564. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  105565. /**
  105566. * Disposes the component and the associated ressources.
  105567. */
  105568. dispose(): void;
  105569. private _isReadyForMesh;
  105570. private _renderMainTexture;
  105571. private _setStencil;
  105572. private _setStencilBack;
  105573. private _draw;
  105574. private _drawCamera;
  105575. private _drawRenderingGroup;
  105576. }
  105577. }
  105578. declare module BABYLON {
  105579. /** @hidden */
  105580. export var glowMapMergePixelShader: {
  105581. name: string;
  105582. shader: string;
  105583. };
  105584. }
  105585. declare module BABYLON {
  105586. /** @hidden */
  105587. export var glowMapMergeVertexShader: {
  105588. name: string;
  105589. shader: string;
  105590. };
  105591. }
  105592. declare module BABYLON {
  105593. interface AbstractScene {
  105594. /**
  105595. * Return a the first highlight layer of the scene with a given name.
  105596. * @param name The name of the highlight layer to look for.
  105597. * @return The highlight layer if found otherwise null.
  105598. */
  105599. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  105600. }
  105601. /**
  105602. * Glow layer options. This helps customizing the behaviour
  105603. * of the glow layer.
  105604. */
  105605. export interface IGlowLayerOptions {
  105606. /**
  105607. * Multiplication factor apply to the canvas size to compute the render target size
  105608. * used to generated the glowing objects (the smaller the faster).
  105609. */
  105610. mainTextureRatio: number;
  105611. /**
  105612. * Enforces a fixed size texture to ensure resize independant blur.
  105613. */
  105614. mainTextureFixedSize?: number;
  105615. /**
  105616. * How big is the kernel of the blur texture.
  105617. */
  105618. blurKernelSize: number;
  105619. /**
  105620. * The camera attached to the layer.
  105621. */
  105622. camera: Nullable<Camera>;
  105623. /**
  105624. * Enable MSAA by chosing the number of samples.
  105625. */
  105626. mainTextureSamples?: number;
  105627. /**
  105628. * The rendering group to draw the layer in.
  105629. */
  105630. renderingGroupId: number;
  105631. }
  105632. /**
  105633. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  105634. *
  105635. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  105636. * glowy meshes to your scene.
  105637. *
  105638. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  105639. */
  105640. export class GlowLayer extends EffectLayer {
  105641. /**
  105642. * Effect Name of the layer.
  105643. */
  105644. static readonly EffectName: string;
  105645. /**
  105646. * The default blur kernel size used for the glow.
  105647. */
  105648. static DefaultBlurKernelSize: number;
  105649. /**
  105650. * The default texture size ratio used for the glow.
  105651. */
  105652. static DefaultTextureRatio: number;
  105653. /**
  105654. * Sets the kernel size of the blur.
  105655. */
  105656. /**
  105657. * Gets the kernel size of the blur.
  105658. */
  105659. blurKernelSize: number;
  105660. /**
  105661. * Sets the glow intensity.
  105662. */
  105663. /**
  105664. * Gets the glow intensity.
  105665. */
  105666. intensity: number;
  105667. private _options;
  105668. private _intensity;
  105669. private _horizontalBlurPostprocess1;
  105670. private _verticalBlurPostprocess1;
  105671. private _horizontalBlurPostprocess2;
  105672. private _verticalBlurPostprocess2;
  105673. private _blurTexture1;
  105674. private _blurTexture2;
  105675. private _postProcesses1;
  105676. private _postProcesses2;
  105677. private _includedOnlyMeshes;
  105678. private _excludedMeshes;
  105679. /**
  105680. * Callback used to let the user override the color selection on a per mesh basis
  105681. */
  105682. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  105683. /**
  105684. * Callback used to let the user override the texture selection on a per mesh basis
  105685. */
  105686. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  105687. /**
  105688. * Instantiates a new glow Layer and references it to the scene.
  105689. * @param name The name of the layer
  105690. * @param scene The scene to use the layer in
  105691. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  105692. */
  105693. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  105694. /**
  105695. * Get the effect name of the layer.
  105696. * @return The effect name
  105697. */
  105698. getEffectName(): string;
  105699. /**
  105700. * Create the merge effect. This is the shader use to blit the information back
  105701. * to the main canvas at the end of the scene rendering.
  105702. */
  105703. protected _createMergeEffect(): Effect;
  105704. /**
  105705. * Creates the render target textures and post processes used in the glow layer.
  105706. */
  105707. protected _createTextureAndPostProcesses(): void;
  105708. /**
  105709. * Checks for the readiness of the element composing the layer.
  105710. * @param subMesh the mesh to check for
  105711. * @param useInstances specify wether or not to use instances to render the mesh
  105712. * @param emissiveTexture the associated emissive texture used to generate the glow
  105713. * @return true if ready otherwise, false
  105714. */
  105715. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105716. /**
  105717. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105718. */
  105719. needStencil(): boolean;
  105720. /**
  105721. * Returns true if the mesh can be rendered, otherwise false.
  105722. * @param mesh The mesh to render
  105723. * @param material The material used on the mesh
  105724. * @returns true if it can be rendered otherwise false
  105725. */
  105726. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105727. /**
  105728. * Implementation specific of rendering the generating effect on the main canvas.
  105729. * @param effect The effect used to render through
  105730. */
  105731. protected _internalRender(effect: Effect): void;
  105732. /**
  105733. * Sets the required values for both the emissive texture and and the main color.
  105734. */
  105735. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105736. /**
  105737. * Returns true if the mesh should render, otherwise false.
  105738. * @param mesh The mesh to render
  105739. * @returns true if it should render otherwise false
  105740. */
  105741. protected _shouldRenderMesh(mesh: Mesh): boolean;
  105742. /**
  105743. * Adds specific effects defines.
  105744. * @param defines The defines to add specifics to.
  105745. */
  105746. protected _addCustomEffectDefines(defines: string[]): void;
  105747. /**
  105748. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  105749. * @param mesh The mesh to exclude from the glow layer
  105750. */
  105751. addExcludedMesh(mesh: Mesh): void;
  105752. /**
  105753. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  105754. * @param mesh The mesh to remove
  105755. */
  105756. removeExcludedMesh(mesh: Mesh): void;
  105757. /**
  105758. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  105759. * @param mesh The mesh to include in the glow layer
  105760. */
  105761. addIncludedOnlyMesh(mesh: Mesh): void;
  105762. /**
  105763. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  105764. * @param mesh The mesh to remove
  105765. */
  105766. removeIncludedOnlyMesh(mesh: Mesh): void;
  105767. /**
  105768. * Determine if a given mesh will be used in the glow layer
  105769. * @param mesh The mesh to test
  105770. * @returns true if the mesh will be highlighted by the current glow layer
  105771. */
  105772. hasMesh(mesh: AbstractMesh): boolean;
  105773. /**
  105774. * Free any resources and references associated to a mesh.
  105775. * Internal use
  105776. * @param mesh The mesh to free.
  105777. * @hidden
  105778. */
  105779. _disposeMesh(mesh: Mesh): void;
  105780. /**
  105781. * Gets the class name of the effect layer
  105782. * @returns the string with the class name of the effect layer
  105783. */
  105784. getClassName(): string;
  105785. /**
  105786. * Serializes this glow layer
  105787. * @returns a serialized glow layer object
  105788. */
  105789. serialize(): any;
  105790. /**
  105791. * Creates a Glow Layer from parsed glow layer data
  105792. * @param parsedGlowLayer defines glow layer data
  105793. * @param scene defines the current scene
  105794. * @param rootUrl defines the root URL containing the glow layer information
  105795. * @returns a parsed Glow Layer
  105796. */
  105797. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  105798. }
  105799. }
  105800. declare module BABYLON {
  105801. /** @hidden */
  105802. export var glowBlurPostProcessPixelShader: {
  105803. name: string;
  105804. shader: string;
  105805. };
  105806. }
  105807. declare module BABYLON {
  105808. interface AbstractScene {
  105809. /**
  105810. * Return a the first highlight layer of the scene with a given name.
  105811. * @param name The name of the highlight layer to look for.
  105812. * @return The highlight layer if found otherwise null.
  105813. */
  105814. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  105815. }
  105816. /**
  105817. * Highlight layer options. This helps customizing the behaviour
  105818. * of the highlight layer.
  105819. */
  105820. export interface IHighlightLayerOptions {
  105821. /**
  105822. * Multiplication factor apply to the canvas size to compute the render target size
  105823. * used to generated the glowing objects (the smaller the faster).
  105824. */
  105825. mainTextureRatio: number;
  105826. /**
  105827. * Enforces a fixed size texture to ensure resize independant blur.
  105828. */
  105829. mainTextureFixedSize?: number;
  105830. /**
  105831. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  105832. * of the picture to blur (the smaller the faster).
  105833. */
  105834. blurTextureSizeRatio: number;
  105835. /**
  105836. * How big in texel of the blur texture is the vertical blur.
  105837. */
  105838. blurVerticalSize: number;
  105839. /**
  105840. * How big in texel of the blur texture is the horizontal blur.
  105841. */
  105842. blurHorizontalSize: number;
  105843. /**
  105844. * Alpha blending mode used to apply the blur. Default is combine.
  105845. */
  105846. alphaBlendingMode: number;
  105847. /**
  105848. * The camera attached to the layer.
  105849. */
  105850. camera: Nullable<Camera>;
  105851. /**
  105852. * Should we display highlight as a solid stroke?
  105853. */
  105854. isStroke?: boolean;
  105855. /**
  105856. * The rendering group to draw the layer in.
  105857. */
  105858. renderingGroupId: number;
  105859. }
  105860. /**
  105861. * The highlight layer Helps adding a glow effect around a mesh.
  105862. *
  105863. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  105864. * glowy meshes to your scene.
  105865. *
  105866. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  105867. */
  105868. export class HighlightLayer extends EffectLayer {
  105869. name: string;
  105870. /**
  105871. * Effect Name of the highlight layer.
  105872. */
  105873. static readonly EffectName: string;
  105874. /**
  105875. * The neutral color used during the preparation of the glow effect.
  105876. * This is black by default as the blend operation is a blend operation.
  105877. */
  105878. static NeutralColor: Color4;
  105879. /**
  105880. * Stencil value used for glowing meshes.
  105881. */
  105882. static GlowingMeshStencilReference: number;
  105883. /**
  105884. * Stencil value used for the other meshes in the scene.
  105885. */
  105886. static NormalMeshStencilReference: number;
  105887. /**
  105888. * Specifies whether or not the inner glow is ACTIVE in the layer.
  105889. */
  105890. innerGlow: boolean;
  105891. /**
  105892. * Specifies whether or not the outer glow is ACTIVE in the layer.
  105893. */
  105894. outerGlow: boolean;
  105895. /**
  105896. * Specifies the horizontal size of the blur.
  105897. */
  105898. /**
  105899. * Gets the horizontal size of the blur.
  105900. */
  105901. blurHorizontalSize: number;
  105902. /**
  105903. * Specifies the vertical size of the blur.
  105904. */
  105905. /**
  105906. * Gets the vertical size of the blur.
  105907. */
  105908. blurVerticalSize: number;
  105909. /**
  105910. * An event triggered when the highlight layer is being blurred.
  105911. */
  105912. onBeforeBlurObservable: Observable<HighlightLayer>;
  105913. /**
  105914. * An event triggered when the highlight layer has been blurred.
  105915. */
  105916. onAfterBlurObservable: Observable<HighlightLayer>;
  105917. private _instanceGlowingMeshStencilReference;
  105918. private _options;
  105919. private _downSamplePostprocess;
  105920. private _horizontalBlurPostprocess;
  105921. private _verticalBlurPostprocess;
  105922. private _blurTexture;
  105923. private _meshes;
  105924. private _excludedMeshes;
  105925. /**
  105926. * Instantiates a new highlight Layer and references it to the scene..
  105927. * @param name The name of the layer
  105928. * @param scene The scene to use the layer in
  105929. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  105930. */
  105931. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  105932. /**
  105933. * Get the effect name of the layer.
  105934. * @return The effect name
  105935. */
  105936. getEffectName(): string;
  105937. /**
  105938. * Create the merge effect. This is the shader use to blit the information back
  105939. * to the main canvas at the end of the scene rendering.
  105940. */
  105941. protected _createMergeEffect(): Effect;
  105942. /**
  105943. * Creates the render target textures and post processes used in the highlight layer.
  105944. */
  105945. protected _createTextureAndPostProcesses(): void;
  105946. /**
  105947. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105948. */
  105949. needStencil(): boolean;
  105950. /**
  105951. * Checks for the readiness of the element composing the layer.
  105952. * @param subMesh the mesh to check for
  105953. * @param useInstances specify wether or not to use instances to render the mesh
  105954. * @param emissiveTexture the associated emissive texture used to generate the glow
  105955. * @return true if ready otherwise, false
  105956. */
  105957. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105958. /**
  105959. * Implementation specific of rendering the generating effect on the main canvas.
  105960. * @param effect The effect used to render through
  105961. */
  105962. protected _internalRender(effect: Effect): void;
  105963. /**
  105964. * Returns true if the layer contains information to display, otherwise false.
  105965. */
  105966. shouldRender(): boolean;
  105967. /**
  105968. * Returns true if the mesh should render, otherwise false.
  105969. * @param mesh The mesh to render
  105970. * @returns true if it should render otherwise false
  105971. */
  105972. protected _shouldRenderMesh(mesh: Mesh): boolean;
  105973. /**
  105974. * Sets the required values for both the emissive texture and and the main color.
  105975. */
  105976. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105977. /**
  105978. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  105979. * @param mesh The mesh to exclude from the highlight layer
  105980. */
  105981. addExcludedMesh(mesh: Mesh): void;
  105982. /**
  105983. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  105984. * @param mesh The mesh to highlight
  105985. */
  105986. removeExcludedMesh(mesh: Mesh): void;
  105987. /**
  105988. * Determine if a given mesh will be highlighted by the current HighlightLayer
  105989. * @param mesh mesh to test
  105990. * @returns true if the mesh will be highlighted by the current HighlightLayer
  105991. */
  105992. hasMesh(mesh: AbstractMesh): boolean;
  105993. /**
  105994. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  105995. * @param mesh The mesh to highlight
  105996. * @param color The color of the highlight
  105997. * @param glowEmissiveOnly Extract the glow from the emissive texture
  105998. */
  105999. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106000. /**
  106001. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106002. * @param mesh The mesh to highlight
  106003. */
  106004. removeMesh(mesh: Mesh): void;
  106005. /**
  106006. * Force the stencil to the normal expected value for none glowing parts
  106007. */
  106008. private _defaultStencilReference;
  106009. /**
  106010. * Free any resources and references associated to a mesh.
  106011. * Internal use
  106012. * @param mesh The mesh to free.
  106013. * @hidden
  106014. */
  106015. _disposeMesh(mesh: Mesh): void;
  106016. /**
  106017. * Dispose the highlight layer and free resources.
  106018. */
  106019. dispose(): void;
  106020. /**
  106021. * Gets the class name of the effect layer
  106022. * @returns the string with the class name of the effect layer
  106023. */
  106024. getClassName(): string;
  106025. /**
  106026. * Serializes this Highlight layer
  106027. * @returns a serialized Highlight layer object
  106028. */
  106029. serialize(): any;
  106030. /**
  106031. * Creates a Highlight layer from parsed Highlight layer data
  106032. * @param parsedHightlightLayer defines the Highlight layer data
  106033. * @param scene defines the current scene
  106034. * @param rootUrl defines the root URL containing the Highlight layer information
  106035. * @returns a parsed Highlight layer
  106036. */
  106037. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106038. }
  106039. }
  106040. declare module BABYLON {
  106041. /** @hidden */
  106042. export var lensFlarePixelShader: {
  106043. name: string;
  106044. shader: string;
  106045. };
  106046. }
  106047. declare module BABYLON {
  106048. /** @hidden */
  106049. export var lensFlareVertexShader: {
  106050. name: string;
  106051. shader: string;
  106052. };
  106053. }
  106054. declare module BABYLON {
  106055. /**
  106056. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106057. * It is usually composed of several `lensFlare`.
  106058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106059. */
  106060. export class LensFlareSystem {
  106061. /**
  106062. * Define the name of the lens flare system
  106063. */
  106064. name: string;
  106065. /**
  106066. * List of lens flares used in this system.
  106067. */
  106068. lensFlares: LensFlare[];
  106069. /**
  106070. * Define a limit from the border the lens flare can be visible.
  106071. */
  106072. borderLimit: number;
  106073. /**
  106074. * Define a viewport border we do not want to see the lens flare in.
  106075. */
  106076. viewportBorder: number;
  106077. /**
  106078. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106079. */
  106080. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106081. /**
  106082. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106083. */
  106084. layerMask: number;
  106085. /**
  106086. * Define the id of the lens flare system in the scene.
  106087. * (equal to name by default)
  106088. */
  106089. id: string;
  106090. private _scene;
  106091. private _emitter;
  106092. private _vertexBuffers;
  106093. private _indexBuffer;
  106094. private _effect;
  106095. private _positionX;
  106096. private _positionY;
  106097. private _isEnabled;
  106098. /** @hidden */
  106099. static _SceneComponentInitialization: (scene: Scene) => void;
  106100. /**
  106101. * Instantiates a lens flare system.
  106102. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106103. * It is usually composed of several `lensFlare`.
  106104. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106105. * @param name Define the name of the lens flare system in the scene
  106106. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106107. * @param scene Define the scene the lens flare system belongs to
  106108. */
  106109. constructor(
  106110. /**
  106111. * Define the name of the lens flare system
  106112. */
  106113. name: string, emitter: any, scene: Scene);
  106114. /**
  106115. * Define if the lens flare system is enabled.
  106116. */
  106117. isEnabled: boolean;
  106118. /**
  106119. * Get the scene the effects belongs to.
  106120. * @returns the scene holding the lens flare system
  106121. */
  106122. getScene(): Scene;
  106123. /**
  106124. * Get the emitter of the lens flare system.
  106125. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106126. * @returns the emitter of the lens flare system
  106127. */
  106128. getEmitter(): any;
  106129. /**
  106130. * Set the emitter of the lens flare system.
  106131. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106132. * @param newEmitter Define the new emitter of the system
  106133. */
  106134. setEmitter(newEmitter: any): void;
  106135. /**
  106136. * Get the lens flare system emitter position.
  106137. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106138. * @returns the position
  106139. */
  106140. getEmitterPosition(): Vector3;
  106141. /**
  106142. * @hidden
  106143. */
  106144. computeEffectivePosition(globalViewport: Viewport): boolean;
  106145. /** @hidden */
  106146. _isVisible(): boolean;
  106147. /**
  106148. * @hidden
  106149. */
  106150. render(): boolean;
  106151. /**
  106152. * Dispose and release the lens flare with its associated resources.
  106153. */
  106154. dispose(): void;
  106155. /**
  106156. * Parse a lens flare system from a JSON repressentation
  106157. * @param parsedLensFlareSystem Define the JSON to parse
  106158. * @param scene Define the scene the parsed system should be instantiated in
  106159. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106160. * @returns the parsed system
  106161. */
  106162. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106163. /**
  106164. * Serialize the current Lens Flare System into a JSON representation.
  106165. * @returns the serialized JSON
  106166. */
  106167. serialize(): any;
  106168. }
  106169. }
  106170. declare module BABYLON {
  106171. /**
  106172. * This represents one of the lens effect in a `lensFlareSystem`.
  106173. * It controls one of the indiviual texture used in the effect.
  106174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106175. */
  106176. export class LensFlare {
  106177. /**
  106178. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106179. */
  106180. size: number;
  106181. /**
  106182. * 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.
  106183. */
  106184. position: number;
  106185. /**
  106186. * Define the lens color.
  106187. */
  106188. color: Color3;
  106189. /**
  106190. * Define the lens texture.
  106191. */
  106192. texture: Nullable<Texture>;
  106193. /**
  106194. * Define the alpha mode to render this particular lens.
  106195. */
  106196. alphaMode: number;
  106197. private _system;
  106198. /**
  106199. * Creates a new Lens Flare.
  106200. * This represents one of the lens effect in a `lensFlareSystem`.
  106201. * It controls one of the indiviual texture used in the effect.
  106202. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106203. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106204. * @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.
  106205. * @param color Define the lens color
  106206. * @param imgUrl Define the lens texture url
  106207. * @param system Define the `lensFlareSystem` this flare is part of
  106208. * @returns The newly created Lens Flare
  106209. */
  106210. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106211. /**
  106212. * Instantiates a new Lens Flare.
  106213. * This represents one of the lens effect in a `lensFlareSystem`.
  106214. * It controls one of the indiviual texture used in the effect.
  106215. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106216. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106217. * @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.
  106218. * @param color Define the lens color
  106219. * @param imgUrl Define the lens texture url
  106220. * @param system Define the `lensFlareSystem` this flare is part of
  106221. */
  106222. constructor(
  106223. /**
  106224. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106225. */
  106226. size: number,
  106227. /**
  106228. * 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.
  106229. */
  106230. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106231. /**
  106232. * Dispose and release the lens flare with its associated resources.
  106233. */
  106234. dispose(): void;
  106235. }
  106236. }
  106237. declare module BABYLON {
  106238. interface AbstractScene {
  106239. /**
  106240. * The list of lens flare system added to the scene
  106241. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106242. */
  106243. lensFlareSystems: Array<LensFlareSystem>;
  106244. /**
  106245. * Removes the given lens flare system from this scene.
  106246. * @param toRemove The lens flare system to remove
  106247. * @returns The index of the removed lens flare system
  106248. */
  106249. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106250. /**
  106251. * Adds the given lens flare system to this scene
  106252. * @param newLensFlareSystem The lens flare system to add
  106253. */
  106254. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106255. /**
  106256. * Gets a lens flare system using its name
  106257. * @param name defines the name to look for
  106258. * @returns the lens flare system or null if not found
  106259. */
  106260. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106261. /**
  106262. * Gets a lens flare system using its id
  106263. * @param id defines the id to look for
  106264. * @returns the lens flare system or null if not found
  106265. */
  106266. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106267. }
  106268. /**
  106269. * Defines the lens flare scene component responsible to manage any lens flares
  106270. * in a given scene.
  106271. */
  106272. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106273. /**
  106274. * The component name helpfull to identify the component in the list of scene components.
  106275. */
  106276. readonly name: string;
  106277. /**
  106278. * The scene the component belongs to.
  106279. */
  106280. scene: Scene;
  106281. /**
  106282. * Creates a new instance of the component for the given scene
  106283. * @param scene Defines the scene to register the component in
  106284. */
  106285. constructor(scene: Scene);
  106286. /**
  106287. * Registers the component in a given scene
  106288. */
  106289. register(): void;
  106290. /**
  106291. * Rebuilds the elements related to this component in case of
  106292. * context lost for instance.
  106293. */
  106294. rebuild(): void;
  106295. /**
  106296. * Adds all the element from the container to the scene
  106297. * @param container the container holding the elements
  106298. */
  106299. addFromContainer(container: AbstractScene): void;
  106300. /**
  106301. * Removes all the elements in the container from the scene
  106302. * @param container contains the elements to remove
  106303. * @param dispose if the removed element should be disposed (default: false)
  106304. */
  106305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106306. /**
  106307. * Serializes the component data to the specified json object
  106308. * @param serializationObject The object to serialize to
  106309. */
  106310. serialize(serializationObject: any): void;
  106311. /**
  106312. * Disposes the component and the associated ressources.
  106313. */
  106314. dispose(): void;
  106315. private _draw;
  106316. }
  106317. }
  106318. declare module BABYLON {
  106319. /**
  106320. * Defines the shadow generator component responsible to manage any shadow generators
  106321. * in a given scene.
  106322. */
  106323. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106324. /**
  106325. * The component name helpfull to identify the component in the list of scene components.
  106326. */
  106327. readonly name: string;
  106328. /**
  106329. * The scene the component belongs to.
  106330. */
  106331. scene: Scene;
  106332. /**
  106333. * Creates a new instance of the component for the given scene
  106334. * @param scene Defines the scene to register the component in
  106335. */
  106336. constructor(scene: Scene);
  106337. /**
  106338. * Registers the component in a given scene
  106339. */
  106340. register(): void;
  106341. /**
  106342. * Rebuilds the elements related to this component in case of
  106343. * context lost for instance.
  106344. */
  106345. rebuild(): void;
  106346. /**
  106347. * Serializes the component data to the specified json object
  106348. * @param serializationObject The object to serialize to
  106349. */
  106350. serialize(serializationObject: any): void;
  106351. /**
  106352. * Adds all the element from the container to the scene
  106353. * @param container the container holding the elements
  106354. */
  106355. addFromContainer(container: AbstractScene): void;
  106356. /**
  106357. * Removes all the elements in the container from the scene
  106358. * @param container contains the elements to remove
  106359. * @param dispose if the removed element should be disposed (default: false)
  106360. */
  106361. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106362. /**
  106363. * Rebuilds the elements related to this component in case of
  106364. * context lost for instance.
  106365. */
  106366. dispose(): void;
  106367. private _gatherRenderTargets;
  106368. }
  106369. }
  106370. declare module BABYLON {
  106371. /**
  106372. * A point light is a light defined by an unique point in world space.
  106373. * The light is emitted in every direction from this point.
  106374. * A good example of a point light is a standard light bulb.
  106375. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106376. */
  106377. export class PointLight extends ShadowLight {
  106378. private _shadowAngle;
  106379. /**
  106380. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106381. * This specifies what angle the shadow will use to be created.
  106382. *
  106383. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106384. */
  106385. /**
  106386. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106387. * This specifies what angle the shadow will use to be created.
  106388. *
  106389. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106390. */
  106391. shadowAngle: number;
  106392. /**
  106393. * Gets the direction if it has been set.
  106394. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106395. */
  106396. /**
  106397. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106398. */
  106399. direction: Vector3;
  106400. /**
  106401. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106402. * A PointLight emits the light in every direction.
  106403. * It can cast shadows.
  106404. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106405. * ```javascript
  106406. * var pointLight = new PointLight("pl", camera.position, scene);
  106407. * ```
  106408. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106409. * @param name The light friendly name
  106410. * @param position The position of the point light in the scene
  106411. * @param scene The scene the lights belongs to
  106412. */
  106413. constructor(name: string, position: Vector3, scene: Scene);
  106414. /**
  106415. * Returns the string "PointLight"
  106416. * @returns the class name
  106417. */
  106418. getClassName(): string;
  106419. /**
  106420. * Returns the integer 0.
  106421. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106422. */
  106423. getTypeID(): number;
  106424. /**
  106425. * Specifies wether or not the shadowmap should be a cube texture.
  106426. * @returns true if the shadowmap needs to be a cube texture.
  106427. */
  106428. needCube(): boolean;
  106429. /**
  106430. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106431. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106432. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106433. */
  106434. getShadowDirection(faceIndex?: number): Vector3;
  106435. /**
  106436. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106437. * - fov = PI / 2
  106438. * - aspect ratio : 1.0
  106439. * - z-near and far equal to the active camera minZ and maxZ.
  106440. * Returns the PointLight.
  106441. */
  106442. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106443. protected _buildUniformLayout(): void;
  106444. /**
  106445. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106446. * @param effect The effect to update
  106447. * @param lightIndex The index of the light in the effect to update
  106448. * @returns The point light
  106449. */
  106450. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106451. /**
  106452. * Prepares the list of defines specific to the light type.
  106453. * @param defines the list of defines
  106454. * @param lightIndex defines the index of the light for the effect
  106455. */
  106456. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106457. }
  106458. }
  106459. declare module BABYLON {
  106460. /**
  106461. * Header information of HDR texture files.
  106462. */
  106463. export interface HDRInfo {
  106464. /**
  106465. * The height of the texture in pixels.
  106466. */
  106467. height: number;
  106468. /**
  106469. * The width of the texture in pixels.
  106470. */
  106471. width: number;
  106472. /**
  106473. * The index of the beginning of the data in the binary file.
  106474. */
  106475. dataPosition: number;
  106476. }
  106477. /**
  106478. * This groups tools to convert HDR texture to native colors array.
  106479. */
  106480. export class HDRTools {
  106481. private static Ldexp;
  106482. private static Rgbe2float;
  106483. private static readStringLine;
  106484. /**
  106485. * Reads header information from an RGBE texture stored in a native array.
  106486. * More information on this format are available here:
  106487. * https://en.wikipedia.org/wiki/RGBE_image_format
  106488. *
  106489. * @param uint8array The binary file stored in native array.
  106490. * @return The header information.
  106491. */
  106492. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  106493. /**
  106494. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  106495. * This RGBE texture needs to store the information as a panorama.
  106496. *
  106497. * More information on this format are available here:
  106498. * https://en.wikipedia.org/wiki/RGBE_image_format
  106499. *
  106500. * @param buffer The binary file stored in an array buffer.
  106501. * @param size The expected size of the extracted cubemap.
  106502. * @return The Cube Map information.
  106503. */
  106504. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  106505. /**
  106506. * Returns the pixels data extracted from an RGBE texture.
  106507. * This pixels will be stored left to right up to down in the R G B order in one array.
  106508. *
  106509. * More information on this format are available here:
  106510. * https://en.wikipedia.org/wiki/RGBE_image_format
  106511. *
  106512. * @param uint8array The binary file stored in an array buffer.
  106513. * @param hdrInfo The header information of the file.
  106514. * @return The pixels data in RGB right to left up to down order.
  106515. */
  106516. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  106517. private static RGBE_ReadPixels_RLE;
  106518. }
  106519. }
  106520. declare module BABYLON {
  106521. /**
  106522. * This represents a texture coming from an HDR input.
  106523. *
  106524. * The only supported format is currently panorama picture stored in RGBE format.
  106525. * Example of such files can be found on HDRLib: http://hdrlib.com/
  106526. */
  106527. export class HDRCubeTexture extends BaseTexture {
  106528. private static _facesMapping;
  106529. private _generateHarmonics;
  106530. private _noMipmap;
  106531. private _textureMatrix;
  106532. private _size;
  106533. private _onLoad;
  106534. private _onError;
  106535. /**
  106536. * The texture URL.
  106537. */
  106538. url: string;
  106539. /**
  106540. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  106541. */
  106542. coordinatesMode: number;
  106543. protected _isBlocking: boolean;
  106544. /**
  106545. * Sets wether or not the texture is blocking during loading.
  106546. */
  106547. /**
  106548. * Gets wether or not the texture is blocking during loading.
  106549. */
  106550. isBlocking: boolean;
  106551. protected _rotationY: number;
  106552. /**
  106553. * Sets texture matrix rotation angle around Y axis in radians.
  106554. */
  106555. /**
  106556. * Gets texture matrix rotation angle around Y axis radians.
  106557. */
  106558. rotationY: number;
  106559. /**
  106560. * Gets or sets the center of the bounding box associated with the cube texture
  106561. * It must define where the camera used to render the texture was set
  106562. */
  106563. boundingBoxPosition: Vector3;
  106564. private _boundingBoxSize;
  106565. /**
  106566. * Gets or sets the size of the bounding box associated with the cube texture
  106567. * When defined, the cubemap will switch to local mode
  106568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  106569. * @example https://www.babylonjs-playground.com/#RNASML
  106570. */
  106571. boundingBoxSize: Vector3;
  106572. /**
  106573. * Instantiates an HDRTexture from the following parameters.
  106574. *
  106575. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  106576. * @param scene The scene the texture will be used in
  106577. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106578. * @param noMipmap Forces to not generate the mipmap if true
  106579. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  106580. * @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)
  106581. * @param reserved Reserved flag for internal use.
  106582. */
  106583. 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>);
  106584. /**
  106585. * Get the current class name of the texture useful for serialization or dynamic coding.
  106586. * @returns "HDRCubeTexture"
  106587. */
  106588. getClassName(): string;
  106589. /**
  106590. * Occurs when the file is raw .hdr file.
  106591. */
  106592. private loadTexture;
  106593. clone(): HDRCubeTexture;
  106594. delayLoad(): void;
  106595. /**
  106596. * Get the texture reflection matrix used to rotate/transform the reflection.
  106597. * @returns the reflection matrix
  106598. */
  106599. getReflectionTextureMatrix(): Matrix;
  106600. /**
  106601. * Set the texture reflection matrix used to rotate/transform the reflection.
  106602. * @param value Define the reflection matrix to set
  106603. */
  106604. setReflectionTextureMatrix(value: Matrix): void;
  106605. /**
  106606. * Parses a JSON representation of an HDR Texture in order to create the texture
  106607. * @param parsedTexture Define the JSON representation
  106608. * @param scene Define the scene the texture should be created in
  106609. * @param rootUrl Define the root url in case we need to load relative dependencies
  106610. * @returns the newly created texture after parsing
  106611. */
  106612. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  106613. serialize(): any;
  106614. }
  106615. }
  106616. declare module BABYLON {
  106617. /**
  106618. * Class used to control physics engine
  106619. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106620. */
  106621. export class PhysicsEngine implements IPhysicsEngine {
  106622. private _physicsPlugin;
  106623. /**
  106624. * Global value used to control the smallest number supported by the simulation
  106625. */
  106626. static Epsilon: number;
  106627. private _impostors;
  106628. private _joints;
  106629. /**
  106630. * Gets the gravity vector used by the simulation
  106631. */
  106632. gravity: Vector3;
  106633. /**
  106634. * Factory used to create the default physics plugin.
  106635. * @returns The default physics plugin
  106636. */
  106637. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  106638. /**
  106639. * Creates a new Physics Engine
  106640. * @param gravity defines the gravity vector used by the simulation
  106641. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  106642. */
  106643. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  106644. /**
  106645. * Sets the gravity vector used by the simulation
  106646. * @param gravity defines the gravity vector to use
  106647. */
  106648. setGravity(gravity: Vector3): void;
  106649. /**
  106650. * Set the time step of the physics engine.
  106651. * Default is 1/60.
  106652. * To slow it down, enter 1/600 for example.
  106653. * To speed it up, 1/30
  106654. * @param newTimeStep defines the new timestep to apply to this world.
  106655. */
  106656. setTimeStep(newTimeStep?: number): void;
  106657. /**
  106658. * Get the time step of the physics engine.
  106659. * @returns the current time step
  106660. */
  106661. getTimeStep(): number;
  106662. /**
  106663. * Release all resources
  106664. */
  106665. dispose(): void;
  106666. /**
  106667. * Gets the name of the current physics plugin
  106668. * @returns the name of the plugin
  106669. */
  106670. getPhysicsPluginName(): string;
  106671. /**
  106672. * Adding a new impostor for the impostor tracking.
  106673. * This will be done by the impostor itself.
  106674. * @param impostor the impostor to add
  106675. */
  106676. addImpostor(impostor: PhysicsImpostor): void;
  106677. /**
  106678. * Remove an impostor from the engine.
  106679. * This impostor and its mesh will not longer be updated by the physics engine.
  106680. * @param impostor the impostor to remove
  106681. */
  106682. removeImpostor(impostor: PhysicsImpostor): void;
  106683. /**
  106684. * Add a joint to the physics engine
  106685. * @param mainImpostor defines the main impostor to which the joint is added.
  106686. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106687. * @param joint defines the joint that will connect both impostors.
  106688. */
  106689. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106690. /**
  106691. * Removes a joint from the simulation
  106692. * @param mainImpostor defines the impostor used with the joint
  106693. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106694. * @param joint defines the joint to remove
  106695. */
  106696. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106697. /**
  106698. * Called by the scene. No need to call it.
  106699. * @param delta defines the timespam between frames
  106700. */
  106701. _step(delta: number): void;
  106702. /**
  106703. * Gets the current plugin used to run the simulation
  106704. * @returns current plugin
  106705. */
  106706. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106707. /**
  106708. * Gets the list of physic impostors
  106709. * @returns an array of PhysicsImpostor
  106710. */
  106711. getImpostors(): Array<PhysicsImpostor>;
  106712. /**
  106713. * Gets the impostor for a physics enabled object
  106714. * @param object defines the object impersonated by the impostor
  106715. * @returns the PhysicsImpostor or null if not found
  106716. */
  106717. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106718. /**
  106719. * Gets the impostor for a physics body object
  106720. * @param body defines physics body used by the impostor
  106721. * @returns the PhysicsImpostor or null if not found
  106722. */
  106723. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106724. /**
  106725. * Does a raycast in the physics world
  106726. * @param from when should the ray start?
  106727. * @param to when should the ray end?
  106728. * @returns PhysicsRaycastResult
  106729. */
  106730. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106731. }
  106732. }
  106733. declare module BABYLON {
  106734. /** @hidden */
  106735. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  106736. private _useDeltaForWorldStep;
  106737. world: any;
  106738. name: string;
  106739. private _physicsMaterials;
  106740. private _fixedTimeStep;
  106741. private _cannonRaycastResult;
  106742. private _raycastResult;
  106743. private _removeAfterStep;
  106744. BJSCANNON: any;
  106745. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  106746. setGravity(gravity: Vector3): void;
  106747. setTimeStep(timeStep: number): void;
  106748. getTimeStep(): number;
  106749. executeStep(delta: number): void;
  106750. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106751. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106752. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106753. private _processChildMeshes;
  106754. removePhysicsBody(impostor: PhysicsImpostor): void;
  106755. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106756. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106757. private _addMaterial;
  106758. private _checkWithEpsilon;
  106759. private _createShape;
  106760. private _createHeightmap;
  106761. private _minus90X;
  106762. private _plus90X;
  106763. private _tmpPosition;
  106764. private _tmpDeltaPosition;
  106765. private _tmpUnityRotation;
  106766. private _updatePhysicsBodyTransformation;
  106767. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106768. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106769. isSupported(): boolean;
  106770. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106771. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106772. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106773. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106774. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106775. getBodyMass(impostor: PhysicsImpostor): number;
  106776. getBodyFriction(impostor: PhysicsImpostor): number;
  106777. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106778. getBodyRestitution(impostor: PhysicsImpostor): number;
  106779. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106780. sleepBody(impostor: PhysicsImpostor): void;
  106781. wakeUpBody(impostor: PhysicsImpostor): void;
  106782. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  106783. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106784. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106785. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106786. getRadius(impostor: PhysicsImpostor): number;
  106787. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106788. dispose(): void;
  106789. private _extendNamespace;
  106790. /**
  106791. * Does a raycast in the physics world
  106792. * @param from when should the ray start?
  106793. * @param to when should the ray end?
  106794. * @returns PhysicsRaycastResult
  106795. */
  106796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106797. }
  106798. }
  106799. declare module BABYLON {
  106800. /** @hidden */
  106801. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  106802. world: any;
  106803. name: string;
  106804. BJSOIMO: any;
  106805. private _raycastResult;
  106806. constructor(iterations?: number, oimoInjection?: any);
  106807. setGravity(gravity: Vector3): void;
  106808. setTimeStep(timeStep: number): void;
  106809. getTimeStep(): number;
  106810. private _tmpImpostorsArray;
  106811. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106812. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106813. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106814. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106815. private _tmpPositionVector;
  106816. removePhysicsBody(impostor: PhysicsImpostor): void;
  106817. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106818. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106819. isSupported(): boolean;
  106820. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106821. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106822. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106823. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106826. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106827. getBodyMass(impostor: PhysicsImpostor): number;
  106828. getBodyFriction(impostor: PhysicsImpostor): number;
  106829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106830. getBodyRestitution(impostor: PhysicsImpostor): number;
  106831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106832. sleepBody(impostor: PhysicsImpostor): void;
  106833. wakeUpBody(impostor: PhysicsImpostor): void;
  106834. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106835. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  106836. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106837. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106838. getRadius(impostor: PhysicsImpostor): number;
  106839. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106840. dispose(): void;
  106841. /**
  106842. * Does a raycast in the physics world
  106843. * @param from when should the ray start?
  106844. * @param to when should the ray end?
  106845. * @returns PhysicsRaycastResult
  106846. */
  106847. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106848. }
  106849. }
  106850. declare module BABYLON {
  106851. /**
  106852. * Class containing static functions to help procedurally build meshes
  106853. */
  106854. export class RibbonBuilder {
  106855. /**
  106856. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106857. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106858. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106859. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106860. * * 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
  106861. * * 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
  106862. * * 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
  106863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106866. * * 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
  106867. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106868. * * 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
  106869. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106871. * @param name defines the name of the mesh
  106872. * @param options defines the options used to create the mesh
  106873. * @param scene defines the hosting scene
  106874. * @returns the ribbon mesh
  106875. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106877. */
  106878. static CreateRibbon(name: string, options: {
  106879. pathArray: Vector3[][];
  106880. closeArray?: boolean;
  106881. closePath?: boolean;
  106882. offset?: number;
  106883. updatable?: boolean;
  106884. sideOrientation?: number;
  106885. frontUVs?: Vector4;
  106886. backUVs?: Vector4;
  106887. instance?: Mesh;
  106888. invertUV?: boolean;
  106889. uvs?: Vector2[];
  106890. colors?: Color4[];
  106891. }, scene?: Nullable<Scene>): Mesh;
  106892. }
  106893. }
  106894. declare module BABYLON {
  106895. /**
  106896. * Class containing static functions to help procedurally build meshes
  106897. */
  106898. export class ShapeBuilder {
  106899. /**
  106900. * 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.
  106901. * * 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.
  106902. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106903. * * 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.
  106904. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106905. * * 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
  106906. * * 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
  106907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106912. * @param name defines the name of the mesh
  106913. * @param options defines the options used to create the mesh
  106914. * @param scene defines the hosting scene
  106915. * @returns the extruded shape mesh
  106916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106918. */
  106919. static ExtrudeShape(name: string, options: {
  106920. shape: Vector3[];
  106921. path: Vector3[];
  106922. scale?: number;
  106923. rotation?: number;
  106924. cap?: number;
  106925. updatable?: boolean;
  106926. sideOrientation?: number;
  106927. frontUVs?: Vector4;
  106928. backUVs?: Vector4;
  106929. instance?: Mesh;
  106930. invertUV?: boolean;
  106931. }, scene?: Nullable<Scene>): Mesh;
  106932. /**
  106933. * Creates an custom extruded shape mesh.
  106934. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106935. * * 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.
  106936. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106937. * * 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
  106938. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106939. * * 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
  106940. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106941. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106942. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106943. * * 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
  106944. * * 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
  106945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106950. * @param name defines the name of the mesh
  106951. * @param options defines the options used to create the mesh
  106952. * @param scene defines the hosting scene
  106953. * @returns the custom extruded shape mesh
  106954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106957. */
  106958. static ExtrudeShapeCustom(name: string, options: {
  106959. shape: Vector3[];
  106960. path: Vector3[];
  106961. scaleFunction?: any;
  106962. rotationFunction?: any;
  106963. ribbonCloseArray?: boolean;
  106964. ribbonClosePath?: boolean;
  106965. cap?: number;
  106966. updatable?: boolean;
  106967. sideOrientation?: number;
  106968. frontUVs?: Vector4;
  106969. backUVs?: Vector4;
  106970. instance?: Mesh;
  106971. invertUV?: boolean;
  106972. }, scene: Scene): Mesh;
  106973. private static _ExtrudeShapeGeneric;
  106974. }
  106975. }
  106976. declare module BABYLON {
  106977. /**
  106978. * AmmoJS Physics plugin
  106979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106980. * @see https://github.com/kripken/ammo.js/
  106981. */
  106982. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  106983. private _useDeltaForWorldStep;
  106984. /**
  106985. * Reference to the Ammo library
  106986. */
  106987. bjsAMMO: any;
  106988. /**
  106989. * Created ammoJS world which physics bodies are added to
  106990. */
  106991. world: any;
  106992. /**
  106993. * Name of the plugin
  106994. */
  106995. name: string;
  106996. private _timeStep;
  106997. private _fixedTimeStep;
  106998. private _maxSteps;
  106999. private _tmpQuaternion;
  107000. private _tmpAmmoTransform;
  107001. private _tmpAmmoQuaternion;
  107002. private _tmpAmmoConcreteContactResultCallback;
  107003. private _collisionConfiguration;
  107004. private _dispatcher;
  107005. private _overlappingPairCache;
  107006. private _solver;
  107007. private _softBodySolver;
  107008. private _tmpAmmoVectorA;
  107009. private _tmpAmmoVectorB;
  107010. private _tmpAmmoVectorC;
  107011. private _tmpAmmoVectorD;
  107012. private _tmpContactCallbackResult;
  107013. private _tmpAmmoVectorRCA;
  107014. private _tmpAmmoVectorRCB;
  107015. private _raycastResult;
  107016. private static readonly DISABLE_COLLISION_FLAG;
  107017. private static readonly KINEMATIC_FLAG;
  107018. private static readonly DISABLE_DEACTIVATION_FLAG;
  107019. /**
  107020. * Initializes the ammoJS plugin
  107021. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107022. * @param ammoInjection can be used to inject your own ammo reference
  107023. */
  107024. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107025. /**
  107026. * Sets the gravity of the physics world (m/(s^2))
  107027. * @param gravity Gravity to set
  107028. */
  107029. setGravity(gravity: Vector3): void;
  107030. /**
  107031. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107032. * @param timeStep timestep to use in seconds
  107033. */
  107034. setTimeStep(timeStep: number): void;
  107035. /**
  107036. * 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)
  107037. * @param fixedTimeStep fixedTimeStep to use in seconds
  107038. */
  107039. setFixedTimeStep(fixedTimeStep: number): void;
  107040. /**
  107041. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107042. * @param maxSteps the maximum number of steps by the physics engine per frame
  107043. */
  107044. setMaxSteps(maxSteps: number): void;
  107045. /**
  107046. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107047. * @returns the current timestep in seconds
  107048. */
  107049. getTimeStep(): number;
  107050. private _isImpostorInContact;
  107051. private _isImpostorPairInContact;
  107052. private _stepSimulation;
  107053. /**
  107054. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107055. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107056. * After the step the babylon meshes are set to the position of the physics imposters
  107057. * @param delta amount of time to step forward
  107058. * @param impostors array of imposters to update before/after the step
  107059. */
  107060. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107061. /**
  107062. * Update babylon mesh to match physics world object
  107063. * @param impostor imposter to match
  107064. */
  107065. private _afterSoftStep;
  107066. /**
  107067. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107068. * @param impostor imposter to match
  107069. */
  107070. private _ropeStep;
  107071. /**
  107072. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107073. * @param impostor imposter to match
  107074. */
  107075. private _softbodyOrClothStep;
  107076. private _tmpVector;
  107077. private _tmpMatrix;
  107078. /**
  107079. * Applies an impulse on the imposter
  107080. * @param impostor imposter to apply impulse to
  107081. * @param force amount of force to be applied to the imposter
  107082. * @param contactPoint the location to apply the impulse on the imposter
  107083. */
  107084. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107085. /**
  107086. * Applies a force on the imposter
  107087. * @param impostor imposter to apply force
  107088. * @param force amount of force to be applied to the imposter
  107089. * @param contactPoint the location to apply the force on the imposter
  107090. */
  107091. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107092. /**
  107093. * Creates a physics body using the plugin
  107094. * @param impostor the imposter to create the physics body on
  107095. */
  107096. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107097. /**
  107098. * Removes the physics body from the imposter and disposes of the body's memory
  107099. * @param impostor imposter to remove the physics body from
  107100. */
  107101. removePhysicsBody(impostor: PhysicsImpostor): void;
  107102. /**
  107103. * Generates a joint
  107104. * @param impostorJoint the imposter joint to create the joint with
  107105. */
  107106. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107107. /**
  107108. * Removes a joint
  107109. * @param impostorJoint the imposter joint to remove the joint from
  107110. */
  107111. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107112. private _addMeshVerts;
  107113. /**
  107114. * Initialise the soft body vertices to match its object's (mesh) vertices
  107115. * Softbody vertices (nodes) are in world space and to match this
  107116. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107117. * @param impostor to create the softbody for
  107118. */
  107119. private _softVertexData;
  107120. /**
  107121. * Create an impostor's soft body
  107122. * @param impostor to create the softbody for
  107123. */
  107124. private _createSoftbody;
  107125. /**
  107126. * Create cloth for an impostor
  107127. * @param impostor to create the softbody for
  107128. */
  107129. private _createCloth;
  107130. /**
  107131. * Create rope for an impostor
  107132. * @param impostor to create the softbody for
  107133. */
  107134. private _createRope;
  107135. private _addHullVerts;
  107136. private _createShape;
  107137. /**
  107138. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107139. * @param impostor imposter containing the physics body and babylon object
  107140. */
  107141. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107142. /**
  107143. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107144. * @param impostor imposter containing the physics body and babylon object
  107145. * @param newPosition new position
  107146. * @param newRotation new rotation
  107147. */
  107148. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107149. /**
  107150. * If this plugin is supported
  107151. * @returns true if its supported
  107152. */
  107153. isSupported(): boolean;
  107154. /**
  107155. * Sets the linear velocity of the physics body
  107156. * @param impostor imposter to set the velocity on
  107157. * @param velocity velocity to set
  107158. */
  107159. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107160. /**
  107161. * Sets the angular velocity of the physics body
  107162. * @param impostor imposter to set the velocity on
  107163. * @param velocity velocity to set
  107164. */
  107165. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107166. /**
  107167. * gets the linear velocity
  107168. * @param impostor imposter to get linear velocity from
  107169. * @returns linear velocity
  107170. */
  107171. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107172. /**
  107173. * gets the angular velocity
  107174. * @param impostor imposter to get angular velocity from
  107175. * @returns angular velocity
  107176. */
  107177. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107178. /**
  107179. * Sets the mass of physics body
  107180. * @param impostor imposter to set the mass on
  107181. * @param mass mass to set
  107182. */
  107183. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107184. /**
  107185. * Gets the mass of the physics body
  107186. * @param impostor imposter to get the mass from
  107187. * @returns mass
  107188. */
  107189. getBodyMass(impostor: PhysicsImpostor): number;
  107190. /**
  107191. * Gets friction of the impostor
  107192. * @param impostor impostor to get friction from
  107193. * @returns friction value
  107194. */
  107195. getBodyFriction(impostor: PhysicsImpostor): number;
  107196. /**
  107197. * Sets friction of the impostor
  107198. * @param impostor impostor to set friction on
  107199. * @param friction friction value
  107200. */
  107201. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107202. /**
  107203. * Gets restitution of the impostor
  107204. * @param impostor impostor to get restitution from
  107205. * @returns restitution value
  107206. */
  107207. getBodyRestitution(impostor: PhysicsImpostor): number;
  107208. /**
  107209. * Sets resitution of the impostor
  107210. * @param impostor impostor to set resitution on
  107211. * @param restitution resitution value
  107212. */
  107213. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107214. /**
  107215. * Gets pressure inside the impostor
  107216. * @param impostor impostor to get pressure from
  107217. * @returns pressure value
  107218. */
  107219. getBodyPressure(impostor: PhysicsImpostor): number;
  107220. /**
  107221. * Sets pressure inside a soft body impostor
  107222. * Cloth and rope must remain 0 pressure
  107223. * @param impostor impostor to set pressure on
  107224. * @param pressure pressure value
  107225. */
  107226. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107227. /**
  107228. * Gets stiffness of the impostor
  107229. * @param impostor impostor to get stiffness from
  107230. * @returns pressure value
  107231. */
  107232. getBodyStiffness(impostor: PhysicsImpostor): number;
  107233. /**
  107234. * Sets stiffness of the impostor
  107235. * @param impostor impostor to set stiffness on
  107236. * @param stiffness stiffness value from 0 to 1
  107237. */
  107238. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107239. /**
  107240. * Gets velocityIterations of the impostor
  107241. * @param impostor impostor to get velocity iterations from
  107242. * @returns velocityIterations value
  107243. */
  107244. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107245. /**
  107246. * Sets velocityIterations of the impostor
  107247. * @param impostor impostor to set velocity iterations on
  107248. * @param velocityIterations velocityIterations value
  107249. */
  107250. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107251. /**
  107252. * Gets positionIterations of the impostor
  107253. * @param impostor impostor to get position iterations from
  107254. * @returns positionIterations value
  107255. */
  107256. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107257. /**
  107258. * Sets positionIterations of the impostor
  107259. * @param impostor impostor to set position on
  107260. * @param positionIterations positionIterations value
  107261. */
  107262. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107263. /**
  107264. * Append an anchor to a cloth object
  107265. * @param impostor is the cloth impostor to add anchor to
  107266. * @param otherImpostor is the rigid impostor to anchor to
  107267. * @param width ratio across width from 0 to 1
  107268. * @param height ratio up height from 0 to 1
  107269. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107270. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107271. */
  107272. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107273. /**
  107274. * Append an hook to a rope object
  107275. * @param impostor is the rope impostor to add hook to
  107276. * @param otherImpostor is the rigid impostor to hook to
  107277. * @param length ratio along the rope from 0 to 1
  107278. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107279. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107280. */
  107281. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107282. /**
  107283. * Sleeps the physics body and stops it from being active
  107284. * @param impostor impostor to sleep
  107285. */
  107286. sleepBody(impostor: PhysicsImpostor): void;
  107287. /**
  107288. * Activates the physics body
  107289. * @param impostor impostor to activate
  107290. */
  107291. wakeUpBody(impostor: PhysicsImpostor): void;
  107292. /**
  107293. * Updates the distance parameters of the joint
  107294. * @param joint joint to update
  107295. * @param maxDistance maximum distance of the joint
  107296. * @param minDistance minimum distance of the joint
  107297. */
  107298. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107299. /**
  107300. * Sets a motor on the joint
  107301. * @param joint joint to set motor on
  107302. * @param speed speed of the motor
  107303. * @param maxForce maximum force of the motor
  107304. * @param motorIndex index of the motor
  107305. */
  107306. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107307. /**
  107308. * Sets the motors limit
  107309. * @param joint joint to set limit on
  107310. * @param upperLimit upper limit
  107311. * @param lowerLimit lower limit
  107312. */
  107313. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107314. /**
  107315. * Syncs the position and rotation of a mesh with the impostor
  107316. * @param mesh mesh to sync
  107317. * @param impostor impostor to update the mesh with
  107318. */
  107319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107320. /**
  107321. * Gets the radius of the impostor
  107322. * @param impostor impostor to get radius from
  107323. * @returns the radius
  107324. */
  107325. getRadius(impostor: PhysicsImpostor): number;
  107326. /**
  107327. * Gets the box size of the impostor
  107328. * @param impostor impostor to get box size from
  107329. * @param result the resulting box size
  107330. */
  107331. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107332. /**
  107333. * Disposes of the impostor
  107334. */
  107335. dispose(): void;
  107336. /**
  107337. * Does a raycast in the physics world
  107338. * @param from when should the ray start?
  107339. * @param to when should the ray end?
  107340. * @returns PhysicsRaycastResult
  107341. */
  107342. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107343. }
  107344. }
  107345. declare module BABYLON {
  107346. interface AbstractScene {
  107347. /**
  107348. * The list of reflection probes added to the scene
  107349. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107350. */
  107351. reflectionProbes: Array<ReflectionProbe>;
  107352. /**
  107353. * Removes the given reflection probe from this scene.
  107354. * @param toRemove The reflection probe to remove
  107355. * @returns The index of the removed reflection probe
  107356. */
  107357. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107358. /**
  107359. * Adds the given reflection probe to this scene.
  107360. * @param newReflectionProbe The reflection probe to add
  107361. */
  107362. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107363. }
  107364. /**
  107365. * Class used to generate realtime reflection / refraction cube textures
  107366. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107367. */
  107368. export class ReflectionProbe {
  107369. /** defines the name of the probe */
  107370. name: string;
  107371. private _scene;
  107372. private _renderTargetTexture;
  107373. private _projectionMatrix;
  107374. private _viewMatrix;
  107375. private _target;
  107376. private _add;
  107377. private _attachedMesh;
  107378. private _invertYAxis;
  107379. /** Gets or sets probe position (center of the cube map) */
  107380. position: Vector3;
  107381. /**
  107382. * Creates a new reflection probe
  107383. * @param name defines the name of the probe
  107384. * @param size defines the texture resolution (for each face)
  107385. * @param scene defines the hosting scene
  107386. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107387. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107388. */
  107389. constructor(
  107390. /** defines the name of the probe */
  107391. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107392. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107393. samples: number;
  107394. /** Gets or sets the refresh rate to use (on every frame by default) */
  107395. refreshRate: number;
  107396. /**
  107397. * Gets the hosting scene
  107398. * @returns a Scene
  107399. */
  107400. getScene(): Scene;
  107401. /** Gets the internal CubeTexture used to render to */
  107402. readonly cubeTexture: RenderTargetTexture;
  107403. /** Gets the list of meshes to render */
  107404. readonly renderList: Nullable<AbstractMesh[]>;
  107405. /**
  107406. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107407. * @param mesh defines the mesh to attach to
  107408. */
  107409. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107410. /**
  107411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107412. * @param renderingGroupId The rendering group id corresponding to its index
  107413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107414. */
  107415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107416. /**
  107417. * Clean all associated resources
  107418. */
  107419. dispose(): void;
  107420. /**
  107421. * Converts the reflection probe information to a readable string for debug purpose.
  107422. * @param fullDetails Supports for multiple levels of logging within scene loading
  107423. * @returns the human readable reflection probe info
  107424. */
  107425. toString(fullDetails?: boolean): string;
  107426. /**
  107427. * Get the class name of the relfection probe.
  107428. * @returns "ReflectionProbe"
  107429. */
  107430. getClassName(): string;
  107431. /**
  107432. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107433. * @returns The JSON representation of the texture
  107434. */
  107435. serialize(): any;
  107436. /**
  107437. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107438. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107439. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107440. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107441. * @returns The parsed reflection probe if successful
  107442. */
  107443. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107444. }
  107445. }
  107446. declare module BABYLON {
  107447. /** @hidden */
  107448. export var _BabylonLoaderRegistered: boolean;
  107449. }
  107450. declare module BABYLON {
  107451. /**
  107452. * The Physically based simple base material of BJS.
  107453. *
  107454. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107455. * It is used as the base class for both the specGloss and metalRough conventions.
  107456. */
  107457. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107458. /**
  107459. * Number of Simultaneous lights allowed on the material.
  107460. */
  107461. maxSimultaneousLights: number;
  107462. /**
  107463. * If sets to true, disables all the lights affecting the material.
  107464. */
  107465. disableLighting: boolean;
  107466. /**
  107467. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  107468. */
  107469. environmentTexture: BaseTexture;
  107470. /**
  107471. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107472. */
  107473. invertNormalMapX: boolean;
  107474. /**
  107475. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107476. */
  107477. invertNormalMapY: boolean;
  107478. /**
  107479. * Normal map used in the model.
  107480. */
  107481. normalTexture: BaseTexture;
  107482. /**
  107483. * Emissivie color used to self-illuminate the model.
  107484. */
  107485. emissiveColor: Color3;
  107486. /**
  107487. * Emissivie texture used to self-illuminate the model.
  107488. */
  107489. emissiveTexture: BaseTexture;
  107490. /**
  107491. * Occlusion Channel Strenght.
  107492. */
  107493. occlusionStrength: number;
  107494. /**
  107495. * Occlusion Texture of the material (adding extra occlusion effects).
  107496. */
  107497. occlusionTexture: BaseTexture;
  107498. /**
  107499. * Defines the alpha limits in alpha test mode.
  107500. */
  107501. alphaCutOff: number;
  107502. /**
  107503. * Gets the current double sided mode.
  107504. */
  107505. /**
  107506. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107507. */
  107508. doubleSided: boolean;
  107509. /**
  107510. * Stores the pre-calculated light information of a mesh in a texture.
  107511. */
  107512. lightmapTexture: BaseTexture;
  107513. /**
  107514. * If true, the light map contains occlusion information instead of lighting info.
  107515. */
  107516. useLightmapAsShadowmap: boolean;
  107517. /**
  107518. * Instantiates a new PBRMaterial instance.
  107519. *
  107520. * @param name The material name
  107521. * @param scene The scene the material will be use in.
  107522. */
  107523. constructor(name: string, scene: Scene);
  107524. getClassName(): string;
  107525. }
  107526. }
  107527. declare module BABYLON {
  107528. /**
  107529. * The PBR material of BJS following the metal roughness convention.
  107530. *
  107531. * This fits to the PBR convention in the GLTF definition:
  107532. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  107533. */
  107534. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  107535. /**
  107536. * The base color has two different interpretations depending on the value of metalness.
  107537. * When the material is a metal, the base color is the specific measured reflectance value
  107538. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  107539. * of the material.
  107540. */
  107541. baseColor: Color3;
  107542. /**
  107543. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  107544. * well as opacity information in the alpha channel.
  107545. */
  107546. baseTexture: BaseTexture;
  107547. /**
  107548. * Specifies the metallic scalar value of the material.
  107549. * Can also be used to scale the metalness values of the metallic texture.
  107550. */
  107551. metallic: number;
  107552. /**
  107553. * Specifies the roughness scalar value of the material.
  107554. * Can also be used to scale the roughness values of the metallic texture.
  107555. */
  107556. roughness: number;
  107557. /**
  107558. * Texture containing both the metallic value in the B channel and the
  107559. * roughness value in the G channel to keep better precision.
  107560. */
  107561. metallicRoughnessTexture: BaseTexture;
  107562. /**
  107563. * Instantiates a new PBRMetalRoughnessMaterial instance.
  107564. *
  107565. * @param name The material name
  107566. * @param scene The scene the material will be use in.
  107567. */
  107568. constructor(name: string, scene: Scene);
  107569. /**
  107570. * Return the currrent class name of the material.
  107571. */
  107572. getClassName(): string;
  107573. /**
  107574. * Makes a duplicate of the current material.
  107575. * @param name - name to use for the new material.
  107576. */
  107577. clone(name: string): PBRMetallicRoughnessMaterial;
  107578. /**
  107579. * Serialize the material to a parsable JSON object.
  107580. */
  107581. serialize(): any;
  107582. /**
  107583. * Parses a JSON object correponding to the serialize function.
  107584. */
  107585. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  107586. }
  107587. }
  107588. declare module BABYLON {
  107589. /**
  107590. * The PBR material of BJS following the specular glossiness convention.
  107591. *
  107592. * This fits to the PBR convention in the GLTF definition:
  107593. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  107594. */
  107595. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  107596. /**
  107597. * Specifies the diffuse color of the material.
  107598. */
  107599. diffuseColor: Color3;
  107600. /**
  107601. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  107602. * channel.
  107603. */
  107604. diffuseTexture: BaseTexture;
  107605. /**
  107606. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  107607. */
  107608. specularColor: Color3;
  107609. /**
  107610. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  107611. */
  107612. glossiness: number;
  107613. /**
  107614. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  107615. */
  107616. specularGlossinessTexture: BaseTexture;
  107617. /**
  107618. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  107619. *
  107620. * @param name The material name
  107621. * @param scene The scene the material will be use in.
  107622. */
  107623. constructor(name: string, scene: Scene);
  107624. /**
  107625. * Return the currrent class name of the material.
  107626. */
  107627. getClassName(): string;
  107628. /**
  107629. * Makes a duplicate of the current material.
  107630. * @param name - name to use for the new material.
  107631. */
  107632. clone(name: string): PBRSpecularGlossinessMaterial;
  107633. /**
  107634. * Serialize the material to a parsable JSON object.
  107635. */
  107636. serialize(): any;
  107637. /**
  107638. * Parses a JSON object correponding to the serialize function.
  107639. */
  107640. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  107641. }
  107642. }
  107643. declare module BABYLON {
  107644. /**
  107645. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  107646. * It can help converting any input color in a desired output one. This can then be used to create effects
  107647. * from sepia, black and white to sixties or futuristic rendering...
  107648. *
  107649. * The only supported format is currently 3dl.
  107650. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  107651. */
  107652. export class ColorGradingTexture extends BaseTexture {
  107653. /**
  107654. * The current texture matrix. (will always be identity in color grading texture)
  107655. */
  107656. private _textureMatrix;
  107657. /**
  107658. * The texture URL.
  107659. */
  107660. url: string;
  107661. /**
  107662. * Empty line regex stored for GC.
  107663. */
  107664. private static _noneEmptyLineRegex;
  107665. private _engine;
  107666. /**
  107667. * Instantiates a ColorGradingTexture from the following parameters.
  107668. *
  107669. * @param url The location of the color gradind data (currently only supporting 3dl)
  107670. * @param scene The scene the texture will be used in
  107671. */
  107672. constructor(url: string, scene: Scene);
  107673. /**
  107674. * Returns the texture matrix used in most of the material.
  107675. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  107676. */
  107677. getTextureMatrix(): Matrix;
  107678. /**
  107679. * Occurs when the file being loaded is a .3dl LUT file.
  107680. */
  107681. private load3dlTexture;
  107682. /**
  107683. * Starts the loading process of the texture.
  107684. */
  107685. private loadTexture;
  107686. /**
  107687. * Clones the color gradind texture.
  107688. */
  107689. clone(): ColorGradingTexture;
  107690. /**
  107691. * Called during delayed load for textures.
  107692. */
  107693. delayLoad(): void;
  107694. /**
  107695. * Parses a color grading texture serialized by Babylon.
  107696. * @param parsedTexture The texture information being parsedTexture
  107697. * @param scene The scene to load the texture in
  107698. * @param rootUrl The root url of the data assets to load
  107699. * @return A color gradind texture
  107700. */
  107701. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  107702. /**
  107703. * Serializes the LUT texture to json format.
  107704. */
  107705. serialize(): any;
  107706. }
  107707. }
  107708. declare module BABYLON {
  107709. /**
  107710. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  107711. */
  107712. export class EquiRectangularCubeTexture extends BaseTexture {
  107713. /** The six faces of the cube. */
  107714. private static _FacesMapping;
  107715. private _noMipmap;
  107716. private _onLoad;
  107717. private _onError;
  107718. /** The size of the cubemap. */
  107719. private _size;
  107720. /** The buffer of the image. */
  107721. private _buffer;
  107722. /** The width of the input image. */
  107723. private _width;
  107724. /** The height of the input image. */
  107725. private _height;
  107726. /** The URL to the image. */
  107727. url: string;
  107728. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  107729. coordinatesMode: number;
  107730. /**
  107731. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  107732. * @param url The location of the image
  107733. * @param scene The scene the texture will be used in
  107734. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107735. * @param noMipmap Forces to not generate the mipmap if true
  107736. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  107737. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  107738. * @param onLoad — defines a callback called when texture is loaded
  107739. * @param onError — defines a callback called if there is an error
  107740. */
  107741. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  107742. /**
  107743. * Load the image data, by putting the image on a canvas and extracting its buffer.
  107744. */
  107745. private loadImage;
  107746. /**
  107747. * Convert the image buffer into a cubemap and create a CubeTexture.
  107748. */
  107749. private loadTexture;
  107750. /**
  107751. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  107752. * @param buffer The ArrayBuffer that should be converted.
  107753. * @returns The buffer as Float32Array.
  107754. */
  107755. private getFloat32ArrayFromArrayBuffer;
  107756. /**
  107757. * Get the current class name of the texture useful for serialization or dynamic coding.
  107758. * @returns "EquiRectangularCubeTexture"
  107759. */
  107760. getClassName(): string;
  107761. /**
  107762. * Create a clone of the current EquiRectangularCubeTexture and return it.
  107763. * @returns A clone of the current EquiRectangularCubeTexture.
  107764. */
  107765. clone(): EquiRectangularCubeTexture;
  107766. }
  107767. }
  107768. declare module BABYLON {
  107769. /**
  107770. * Based on jsTGALoader - Javascript loader for TGA file
  107771. * By Vincent Thibault
  107772. * @see http://blog.robrowser.com/javascript-tga-loader.html
  107773. */
  107774. export class TGATools {
  107775. private static _TYPE_INDEXED;
  107776. private static _TYPE_RGB;
  107777. private static _TYPE_GREY;
  107778. private static _TYPE_RLE_INDEXED;
  107779. private static _TYPE_RLE_RGB;
  107780. private static _TYPE_RLE_GREY;
  107781. private static _ORIGIN_MASK;
  107782. private static _ORIGIN_SHIFT;
  107783. private static _ORIGIN_BL;
  107784. private static _ORIGIN_BR;
  107785. private static _ORIGIN_UL;
  107786. private static _ORIGIN_UR;
  107787. /**
  107788. * Gets the header of a TGA file
  107789. * @param data defines the TGA data
  107790. * @returns the header
  107791. */
  107792. static GetTGAHeader(data: Uint8Array): any;
  107793. /**
  107794. * Uploads TGA content to a Babylon Texture
  107795. * @hidden
  107796. */
  107797. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  107798. /** @hidden */
  107799. 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;
  107800. /** @hidden */
  107801. 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;
  107802. /** @hidden */
  107803. 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;
  107804. /** @hidden */
  107805. 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;
  107806. /** @hidden */
  107807. 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;
  107808. /** @hidden */
  107809. 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;
  107810. }
  107811. }
  107812. declare module BABYLON {
  107813. /**
  107814. * Implementation of the TGA Texture Loader.
  107815. * @hidden
  107816. */
  107817. export class _TGATextureLoader implements IInternalTextureLoader {
  107818. /**
  107819. * Defines wether the loader supports cascade loading the different faces.
  107820. */
  107821. readonly supportCascades: boolean;
  107822. /**
  107823. * This returns if the loader support the current file information.
  107824. * @param extension defines the file extension of the file being loaded
  107825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107826. * @param fallback defines the fallback internal texture if any
  107827. * @param isBase64 defines whether the texture is encoded as a base64
  107828. * @param isBuffer defines whether the texture data are stored as a buffer
  107829. * @returns true if the loader can load the specified file
  107830. */
  107831. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  107832. /**
  107833. * Transform the url before loading if required.
  107834. * @param rootUrl the url of the texture
  107835. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107836. * @returns the transformed texture
  107837. */
  107838. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  107839. /**
  107840. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  107841. * @param rootUrl the url of the texture
  107842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  107843. * @returns the fallback texture
  107844. */
  107845. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  107846. /**
  107847. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  107848. * @param data contains the texture data
  107849. * @param texture defines the BabylonJS internal texture
  107850. * @param createPolynomials will be true if polynomials have been requested
  107851. * @param onLoad defines the callback to trigger once the texture is ready
  107852. * @param onError defines the callback to trigger in case of error
  107853. */
  107854. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  107855. /**
  107856. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  107857. * @param data contains the texture data
  107858. * @param texture defines the BabylonJS internal texture
  107859. * @param callback defines the method to call once ready to upload
  107860. */
  107861. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  107862. }
  107863. }
  107864. declare module BABYLON {
  107865. /**
  107866. * 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.
  107867. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  107868. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  107869. */
  107870. export class CustomProceduralTexture extends ProceduralTexture {
  107871. private _animate;
  107872. private _time;
  107873. private _config;
  107874. private _texturePath;
  107875. /**
  107876. * Instantiates a new Custom Procedural Texture.
  107877. * 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.
  107878. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  107879. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  107880. * @param name Define the name of the texture
  107881. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  107882. * @param size Define the size of the texture to create
  107883. * @param scene Define the scene the texture belongs to
  107884. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  107885. * @param generateMipMaps Define if the texture should creates mip maps or not
  107886. */
  107887. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  107888. private _loadJson;
  107889. /**
  107890. * Is the texture ready to be used ? (rendered at least once)
  107891. * @returns true if ready, otherwise, false.
  107892. */
  107893. isReady(): boolean;
  107894. /**
  107895. * Render the texture to its associated render target.
  107896. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  107897. */
  107898. render(useCameraPostProcess?: boolean): void;
  107899. /**
  107900. * Update the list of dependant textures samplers in the shader.
  107901. */
  107902. updateTextures(): void;
  107903. /**
  107904. * Update the uniform values of the procedural texture in the shader.
  107905. */
  107906. updateShaderUniforms(): void;
  107907. /**
  107908. * Define if the texture animates or not.
  107909. */
  107910. animate: boolean;
  107911. }
  107912. }
  107913. declare module BABYLON {
  107914. /** @hidden */
  107915. export var noisePixelShader: {
  107916. name: string;
  107917. shader: string;
  107918. };
  107919. }
  107920. declare module BABYLON {
  107921. /**
  107922. * Class used to generate noise procedural textures
  107923. */
  107924. export class NoiseProceduralTexture extends ProceduralTexture {
  107925. private _time;
  107926. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  107927. brightness: number;
  107928. /** Defines the number of octaves to process */
  107929. octaves: number;
  107930. /** Defines the level of persistence (0.8 by default) */
  107931. persistence: number;
  107932. /** Gets or sets animation speed factor (default is 1) */
  107933. animationSpeedFactor: number;
  107934. /**
  107935. * Creates a new NoiseProceduralTexture
  107936. * @param name defines the name fo the texture
  107937. * @param size defines the size of the texture (default is 256)
  107938. * @param scene defines the hosting scene
  107939. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  107940. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  107941. */
  107942. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  107943. private _updateShaderUniforms;
  107944. protected _getDefines(): string;
  107945. /** Generate the current state of the procedural texture */
  107946. render(useCameraPostProcess?: boolean): void;
  107947. /**
  107948. * Serializes this noise procedural texture
  107949. * @returns a serialized noise procedural texture object
  107950. */
  107951. serialize(): any;
  107952. /**
  107953. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  107954. * @param parsedTexture defines parsed texture data
  107955. * @param scene defines the current scene
  107956. * @param rootUrl defines the root URL containing noise procedural texture information
  107957. * @returns a parsed NoiseProceduralTexture
  107958. */
  107959. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  107960. }
  107961. }
  107962. declare module BABYLON {
  107963. /**
  107964. * Raw cube texture where the raw buffers are passed in
  107965. */
  107966. export class RawCubeTexture extends CubeTexture {
  107967. /**
  107968. * Creates a cube texture where the raw buffers are passed in.
  107969. * @param scene defines the scene the texture is attached to
  107970. * @param data defines the array of data to use to create each face
  107971. * @param size defines the size of the textures
  107972. * @param format defines the format of the data
  107973. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  107974. * @param generateMipMaps defines if the engine should generate the mip levels
  107975. * @param invertY defines if data must be stored with Y axis inverted
  107976. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  107977. * @param compression defines the compression used (null by default)
  107978. */
  107979. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  107980. /**
  107981. * Updates the raw cube texture.
  107982. * @param data defines the data to store
  107983. * @param format defines the data format
  107984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107985. * @param invertY defines if data must be stored with Y axis inverted
  107986. * @param compression defines the compression used (null by default)
  107987. * @param level defines which level of the texture to update
  107988. */
  107989. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  107990. /**
  107991. * Updates a raw cube texture with RGBD encoded data.
  107992. * @param data defines the array of data [mipmap][face] to use to create each face
  107993. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  107994. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  107995. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  107996. * @returns a promsie that resolves when the operation is complete
  107997. */
  107998. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  107999. /**
  108000. * Clones the raw cube texture.
  108001. * @return a new cube texture
  108002. */
  108003. clone(): CubeTexture;
  108004. /** @hidden */
  108005. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108006. }
  108007. }
  108008. declare module BABYLON {
  108009. /**
  108010. * Class used to store 3D textures containing user data
  108011. */
  108012. export class RawTexture3D extends Texture {
  108013. /** Gets or sets the texture format to use */
  108014. format: number;
  108015. private _engine;
  108016. /**
  108017. * Create a new RawTexture3D
  108018. * @param data defines the data of the texture
  108019. * @param width defines the width of the texture
  108020. * @param height defines the height of the texture
  108021. * @param depth defines the depth of the texture
  108022. * @param format defines the texture format to use
  108023. * @param scene defines the hosting scene
  108024. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108025. * @param invertY defines if texture must be stored with Y axis inverted
  108026. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108027. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108028. */
  108029. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108030. /** Gets or sets the texture format to use */
  108031. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108032. /**
  108033. * Update the texture with new data
  108034. * @param data defines the data to store in the texture
  108035. */
  108036. update(data: ArrayBufferView): void;
  108037. }
  108038. }
  108039. declare module BABYLON {
  108040. /**
  108041. * Creates a refraction texture used by refraction channel of the standard material.
  108042. * It is like a mirror but to see through a material.
  108043. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108044. */
  108045. export class RefractionTexture extends RenderTargetTexture {
  108046. /**
  108047. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108048. * 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.
  108049. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108050. */
  108051. refractionPlane: Plane;
  108052. /**
  108053. * Define how deep under the surface we should see.
  108054. */
  108055. depth: number;
  108056. /**
  108057. * Creates a refraction texture used by refraction channel of the standard material.
  108058. * It is like a mirror but to see through a material.
  108059. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108060. * @param name Define the texture name
  108061. * @param size Define the size of the underlying texture
  108062. * @param scene Define the scene the refraction belongs to
  108063. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108064. */
  108065. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108066. /**
  108067. * Clone the refraction texture.
  108068. * @returns the cloned texture
  108069. */
  108070. clone(): RefractionTexture;
  108071. /**
  108072. * Serialize the texture to a JSON representation you could use in Parse later on
  108073. * @returns the serialized JSON representation
  108074. */
  108075. serialize(): any;
  108076. }
  108077. }
  108078. declare module BABYLON {
  108079. /**
  108080. * Configuration for Draco compression
  108081. */
  108082. export interface IDracoCompressionConfiguration {
  108083. /**
  108084. * Configuration for the decoder.
  108085. */
  108086. decoder?: {
  108087. /**
  108088. * The url to the WebAssembly module.
  108089. */
  108090. wasmUrl?: string;
  108091. /**
  108092. * The url to the WebAssembly binary.
  108093. */
  108094. wasmBinaryUrl?: string;
  108095. /**
  108096. * The url to the fallback JavaScript module.
  108097. */
  108098. fallbackUrl?: string;
  108099. };
  108100. }
  108101. /**
  108102. * Draco compression (https://google.github.io/draco/)
  108103. *
  108104. * This class wraps the Draco module.
  108105. *
  108106. * **Encoder**
  108107. *
  108108. * The encoder is not currently implemented.
  108109. *
  108110. * **Decoder**
  108111. *
  108112. * 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.
  108113. *
  108114. * To update the configuration, use the following code:
  108115. * ```javascript
  108116. * DracoCompression.Configuration = {
  108117. * decoder: {
  108118. * wasmUrl: "<url to the WebAssembly library>",
  108119. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108120. * fallbackUrl: "<url to the fallback JavaScript library>",
  108121. * }
  108122. * };
  108123. * ```
  108124. *
  108125. * 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.
  108126. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108127. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108128. *
  108129. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108130. * ```javascript
  108131. * var dracoCompression = new DracoCompression();
  108132. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108133. * [VertexBuffer.PositionKind]: 0
  108134. * });
  108135. * ```
  108136. *
  108137. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108138. */
  108139. export class DracoCompression implements IDisposable {
  108140. private static _DecoderModulePromise;
  108141. /**
  108142. * The configuration. Defaults to the following urls:
  108143. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108144. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108145. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108146. */
  108147. static Configuration: IDracoCompressionConfiguration;
  108148. /**
  108149. * Returns true if the decoder is available.
  108150. */
  108151. static readonly DecoderAvailable: boolean;
  108152. /**
  108153. * Constructor
  108154. */
  108155. constructor();
  108156. /**
  108157. * Stop all async operations and release resources.
  108158. */
  108159. dispose(): void;
  108160. /**
  108161. * Decode Draco compressed mesh data to vertex data.
  108162. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108163. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108164. * @returns A promise that resolves with the decoded vertex data
  108165. */
  108166. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108167. [kind: string]: number;
  108168. }): Promise<VertexData>;
  108169. private static _GetDecoderModule;
  108170. private static _LoadScriptAsync;
  108171. private static _LoadFileAsync;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /**
  108176. * Class for building Constructive Solid Geometry
  108177. */
  108178. export class CSG {
  108179. private polygons;
  108180. /**
  108181. * The world matrix
  108182. */
  108183. matrix: Matrix;
  108184. /**
  108185. * Stores the position
  108186. */
  108187. position: Vector3;
  108188. /**
  108189. * Stores the rotation
  108190. */
  108191. rotation: Vector3;
  108192. /**
  108193. * Stores the rotation quaternion
  108194. */
  108195. rotationQuaternion: Nullable<Quaternion>;
  108196. /**
  108197. * Stores the scaling vector
  108198. */
  108199. scaling: Vector3;
  108200. /**
  108201. * Convert the Mesh to CSG
  108202. * @param mesh The Mesh to convert to CSG
  108203. * @returns A new CSG from the Mesh
  108204. */
  108205. static FromMesh(mesh: Mesh): CSG;
  108206. /**
  108207. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108208. * @param polygons Polygons used to construct a CSG solid
  108209. */
  108210. private static FromPolygons;
  108211. /**
  108212. * Clones, or makes a deep copy, of the CSG
  108213. * @returns A new CSG
  108214. */
  108215. clone(): CSG;
  108216. /**
  108217. * Unions this CSG with another CSG
  108218. * @param csg The CSG to union against this CSG
  108219. * @returns The unioned CSG
  108220. */
  108221. union(csg: CSG): CSG;
  108222. /**
  108223. * Unions this CSG with another CSG in place
  108224. * @param csg The CSG to union against this CSG
  108225. */
  108226. unionInPlace(csg: CSG): void;
  108227. /**
  108228. * Subtracts this CSG with another CSG
  108229. * @param csg The CSG to subtract against this CSG
  108230. * @returns A new CSG
  108231. */
  108232. subtract(csg: CSG): CSG;
  108233. /**
  108234. * Subtracts this CSG with another CSG in place
  108235. * @param csg The CSG to subtact against this CSG
  108236. */
  108237. subtractInPlace(csg: CSG): void;
  108238. /**
  108239. * Intersect this CSG with another CSG
  108240. * @param csg The CSG to intersect against this CSG
  108241. * @returns A new CSG
  108242. */
  108243. intersect(csg: CSG): CSG;
  108244. /**
  108245. * Intersects this CSG with another CSG in place
  108246. * @param csg The CSG to intersect against this CSG
  108247. */
  108248. intersectInPlace(csg: CSG): void;
  108249. /**
  108250. * Return a new CSG solid with solid and empty space switched. This solid is
  108251. * not modified.
  108252. * @returns A new CSG solid with solid and empty space switched
  108253. */
  108254. inverse(): CSG;
  108255. /**
  108256. * Inverses the CSG in place
  108257. */
  108258. inverseInPlace(): void;
  108259. /**
  108260. * This is used to keep meshes transformations so they can be restored
  108261. * when we build back a Babylon Mesh
  108262. * NB : All CSG operations are performed in world coordinates
  108263. * @param csg The CSG to copy the transform attributes from
  108264. * @returns This CSG
  108265. */
  108266. copyTransformAttributes(csg: CSG): CSG;
  108267. /**
  108268. * Build Raw mesh from CSG
  108269. * Coordinates here are in world space
  108270. * @param name The name of the mesh geometry
  108271. * @param scene The Scene
  108272. * @param keepSubMeshes Specifies if the submeshes should be kept
  108273. * @returns A new Mesh
  108274. */
  108275. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108276. /**
  108277. * Build Mesh from CSG taking material and transforms into account
  108278. * @param name The name of the Mesh
  108279. * @param material The material of the Mesh
  108280. * @param scene The Scene
  108281. * @param keepSubMeshes Specifies if submeshes should be kept
  108282. * @returns The new Mesh
  108283. */
  108284. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108285. }
  108286. }
  108287. declare module BABYLON {
  108288. /**
  108289. * Class used to create a trail following a mesh
  108290. */
  108291. export class TrailMesh extends Mesh {
  108292. private _generator;
  108293. private _autoStart;
  108294. private _running;
  108295. private _diameter;
  108296. private _length;
  108297. private _sectionPolygonPointsCount;
  108298. private _sectionVectors;
  108299. private _sectionNormalVectors;
  108300. private _beforeRenderObserver;
  108301. /**
  108302. * @constructor
  108303. * @param name The value used by scene.getMeshByName() to do a lookup.
  108304. * @param generator The mesh to generate a trail.
  108305. * @param scene The scene to add this mesh to.
  108306. * @param diameter Diameter of trailing mesh. Default is 1.
  108307. * @param length Length of trailing mesh. Default is 60.
  108308. * @param autoStart Automatically start trailing mesh. Default true.
  108309. */
  108310. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108311. /**
  108312. * "TrailMesh"
  108313. * @returns "TrailMesh"
  108314. */
  108315. getClassName(): string;
  108316. private _createMesh;
  108317. /**
  108318. * Start trailing mesh.
  108319. */
  108320. start(): void;
  108321. /**
  108322. * Stop trailing mesh.
  108323. */
  108324. stop(): void;
  108325. /**
  108326. * Update trailing mesh geometry.
  108327. */
  108328. update(): void;
  108329. /**
  108330. * Returns a new TrailMesh object.
  108331. * @param name is a string, the name given to the new mesh
  108332. * @param newGenerator use new generator object for cloned trail mesh
  108333. * @returns a new mesh
  108334. */
  108335. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108336. /**
  108337. * Serializes this trail mesh
  108338. * @param serializationObject object to write serialization to
  108339. */
  108340. serialize(serializationObject: any): void;
  108341. /**
  108342. * Parses a serialized trail mesh
  108343. * @param parsedMesh the serialized mesh
  108344. * @param scene the scene to create the trail mesh in
  108345. * @returns the created trail mesh
  108346. */
  108347. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108348. }
  108349. }
  108350. declare module BABYLON {
  108351. /**
  108352. * Class containing static functions to help procedurally build meshes
  108353. */
  108354. export class TorusKnotBuilder {
  108355. /**
  108356. * Creates a torus knot mesh
  108357. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108358. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108359. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108360. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108364. * @param name defines the name of the mesh
  108365. * @param options defines the options used to create the mesh
  108366. * @param scene defines the hosting scene
  108367. * @returns the torus knot mesh
  108368. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108369. */
  108370. static CreateTorusKnot(name: string, options: {
  108371. radius?: number;
  108372. tube?: number;
  108373. radialSegments?: number;
  108374. tubularSegments?: number;
  108375. p?: number;
  108376. q?: number;
  108377. updatable?: boolean;
  108378. sideOrientation?: number;
  108379. frontUVs?: Vector4;
  108380. backUVs?: Vector4;
  108381. }, scene: any): Mesh;
  108382. }
  108383. }
  108384. declare module BABYLON {
  108385. /**
  108386. * Polygon
  108387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108388. */
  108389. export class Polygon {
  108390. /**
  108391. * Creates a rectangle
  108392. * @param xmin bottom X coord
  108393. * @param ymin bottom Y coord
  108394. * @param xmax top X coord
  108395. * @param ymax top Y coord
  108396. * @returns points that make the resulting rectation
  108397. */
  108398. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108399. /**
  108400. * Creates a circle
  108401. * @param radius radius of circle
  108402. * @param cx scale in x
  108403. * @param cy scale in y
  108404. * @param numberOfSides number of sides that make up the circle
  108405. * @returns points that make the resulting circle
  108406. */
  108407. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108408. /**
  108409. * Creates a polygon from input string
  108410. * @param input Input polygon data
  108411. * @returns the parsed points
  108412. */
  108413. static Parse(input: string): Vector2[];
  108414. /**
  108415. * Starts building a polygon from x and y coordinates
  108416. * @param x x coordinate
  108417. * @param y y coordinate
  108418. * @returns the started path2
  108419. */
  108420. static StartingAt(x: number, y: number): Path2;
  108421. }
  108422. /**
  108423. * Builds a polygon
  108424. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108425. */
  108426. export class PolygonMeshBuilder {
  108427. private _points;
  108428. private _outlinepoints;
  108429. private _holes;
  108430. private _name;
  108431. private _scene;
  108432. private _epoints;
  108433. private _eholes;
  108434. private _addToepoint;
  108435. /**
  108436. * Babylon reference to the earcut plugin.
  108437. */
  108438. bjsEarcut: any;
  108439. /**
  108440. * Creates a PolygonMeshBuilder
  108441. * @param name name of the builder
  108442. * @param contours Path of the polygon
  108443. * @param scene scene to add to when creating the mesh
  108444. * @param earcutInjection can be used to inject your own earcut reference
  108445. */
  108446. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  108447. /**
  108448. * Adds a whole within the polygon
  108449. * @param hole Array of points defining the hole
  108450. * @returns this
  108451. */
  108452. addHole(hole: Vector2[]): PolygonMeshBuilder;
  108453. /**
  108454. * Creates the polygon
  108455. * @param updatable If the mesh should be updatable
  108456. * @param depth The depth of the mesh created
  108457. * @returns the created mesh
  108458. */
  108459. build(updatable?: boolean, depth?: number): Mesh;
  108460. /**
  108461. * Creates the polygon
  108462. * @param depth The depth of the mesh created
  108463. * @returns the created VertexData
  108464. */
  108465. buildVertexData(depth?: number): VertexData;
  108466. /**
  108467. * Adds a side to the polygon
  108468. * @param positions points that make the polygon
  108469. * @param normals normals of the polygon
  108470. * @param uvs uvs of the polygon
  108471. * @param indices indices of the polygon
  108472. * @param bounds bounds of the polygon
  108473. * @param points points of the polygon
  108474. * @param depth depth of the polygon
  108475. * @param flip flip of the polygon
  108476. */
  108477. private addSide;
  108478. }
  108479. }
  108480. declare module BABYLON {
  108481. /**
  108482. * Class containing static functions to help procedurally build meshes
  108483. */
  108484. export class PolygonBuilder {
  108485. /**
  108486. * Creates a polygon mesh
  108487. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  108488. * * 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
  108489. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  108492. * * Remember you can only change the shape positions, not their number when updating a polygon
  108493. * @param name defines the name of the mesh
  108494. * @param options defines the options used to create the mesh
  108495. * @param scene defines the hosting scene
  108496. * @param earcutInjection can be used to inject your own earcut reference
  108497. * @returns the polygon mesh
  108498. */
  108499. static CreatePolygon(name: string, options: {
  108500. shape: Vector3[];
  108501. holes?: Vector3[][];
  108502. depth?: number;
  108503. faceUV?: Vector4[];
  108504. faceColors?: Color4[];
  108505. updatable?: boolean;
  108506. sideOrientation?: number;
  108507. frontUVs?: Vector4;
  108508. backUVs?: Vector4;
  108509. }, scene: Scene, earcutInjection?: any): Mesh;
  108510. /**
  108511. * Creates an extruded polygon mesh, with depth in the Y direction.
  108512. * * 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)
  108513. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108514. * @param name defines the name of the mesh
  108515. * @param options defines the options used to create the mesh
  108516. * @param scene defines the hosting scene
  108517. * @param earcutInjection can be used to inject your own earcut reference
  108518. * @returns the polygon mesh
  108519. */
  108520. static ExtrudePolygon(name: string, options: {
  108521. shape: Vector3[];
  108522. holes?: Vector3[][];
  108523. depth?: number;
  108524. faceUV?: Vector4[];
  108525. faceColors?: Color4[];
  108526. updatable?: boolean;
  108527. sideOrientation?: number;
  108528. frontUVs?: Vector4;
  108529. backUVs?: Vector4;
  108530. }, scene: Scene, earcutInjection?: any): Mesh;
  108531. }
  108532. }
  108533. declare module BABYLON {
  108534. /**
  108535. * Class containing static functions to help procedurally build meshes
  108536. */
  108537. export class LatheBuilder {
  108538. /**
  108539. * Creates lathe mesh.
  108540. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  108541. * * 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
  108542. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  108543. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  108544. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  108545. * * 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
  108546. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  108547. * * 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
  108548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108550. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108552. * @param name defines the name of the mesh
  108553. * @param options defines the options used to create the mesh
  108554. * @param scene defines the hosting scene
  108555. * @returns the lathe mesh
  108556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  108557. */
  108558. static CreateLathe(name: string, options: {
  108559. shape: Vector3[];
  108560. radius?: number;
  108561. tessellation?: number;
  108562. clip?: number;
  108563. arc?: number;
  108564. closed?: boolean;
  108565. updatable?: boolean;
  108566. sideOrientation?: number;
  108567. frontUVs?: Vector4;
  108568. backUVs?: Vector4;
  108569. cap?: number;
  108570. invertUV?: boolean;
  108571. }, scene: Scene): Mesh;
  108572. }
  108573. }
  108574. declare module BABYLON {
  108575. /**
  108576. * Class containing static functions to help procedurally build meshes
  108577. */
  108578. export class TubeBuilder {
  108579. /**
  108580. * Creates a tube mesh.
  108581. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108582. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  108583. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  108584. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  108585. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  108586. * * 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)
  108587. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  108588. * * 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
  108589. * * 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
  108590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108594. * @param name defines the name of the mesh
  108595. * @param options defines the options used to create the mesh
  108596. * @param scene defines the hosting scene
  108597. * @returns the tube mesh
  108598. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108599. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  108600. */
  108601. static CreateTube(name: string, options: {
  108602. path: Vector3[];
  108603. radius?: number;
  108604. tessellation?: number;
  108605. radiusFunction?: {
  108606. (i: number, distance: number): number;
  108607. };
  108608. cap?: number;
  108609. arc?: number;
  108610. updatable?: boolean;
  108611. sideOrientation?: number;
  108612. frontUVs?: Vector4;
  108613. backUVs?: Vector4;
  108614. instance?: Mesh;
  108615. invertUV?: boolean;
  108616. }, scene: Scene): Mesh;
  108617. }
  108618. }
  108619. declare module BABYLON {
  108620. /**
  108621. * Class containing static functions to help procedurally build meshes
  108622. */
  108623. export class IcoSphereBuilder {
  108624. /**
  108625. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108626. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108627. * * 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`)
  108628. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108629. * * 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
  108630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108633. * @param name defines the name of the mesh
  108634. * @param options defines the options used to create the mesh
  108635. * @param scene defines the hosting scene
  108636. * @returns the icosahedron mesh
  108637. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108638. */
  108639. static CreateIcoSphere(name: string, options: {
  108640. radius?: number;
  108641. radiusX?: number;
  108642. radiusY?: number;
  108643. radiusZ?: number;
  108644. flat?: boolean;
  108645. subdivisions?: number;
  108646. sideOrientation?: number;
  108647. frontUVs?: Vector4;
  108648. backUVs?: Vector4;
  108649. updatable?: boolean;
  108650. }, scene: Scene): Mesh;
  108651. }
  108652. }
  108653. declare module BABYLON {
  108654. /**
  108655. * Class containing static functions to help procedurally build meshes
  108656. */
  108657. export class DecalBuilder {
  108658. /**
  108659. * Creates a decal mesh.
  108660. * 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
  108661. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  108662. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  108663. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  108664. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  108665. * @param name defines the name of the mesh
  108666. * @param sourceMesh defines the mesh where the decal must be applied
  108667. * @param options defines the options used to create the mesh
  108668. * @param scene defines the hosting scene
  108669. * @returns the decal mesh
  108670. * @see https://doc.babylonjs.com/how_to/decals
  108671. */
  108672. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  108673. position?: Vector3;
  108674. normal?: Vector3;
  108675. size?: Vector3;
  108676. angle?: number;
  108677. }): Mesh;
  108678. }
  108679. }
  108680. declare module BABYLON {
  108681. /**
  108682. * Class containing static functions to help procedurally build meshes
  108683. */
  108684. export class MeshBuilder {
  108685. /**
  108686. * Creates a box mesh
  108687. * * The parameter `size` sets the size (float) of each box side (default 1)
  108688. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108689. * * 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)
  108690. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108694. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108695. * @param name defines the name of the mesh
  108696. * @param options defines the options used to create the mesh
  108697. * @param scene defines the hosting scene
  108698. * @returns the box mesh
  108699. */
  108700. static CreateBox(name: string, options: {
  108701. size?: number;
  108702. width?: number;
  108703. height?: number;
  108704. depth?: number;
  108705. faceUV?: Vector4[];
  108706. faceColors?: Color4[];
  108707. sideOrientation?: number;
  108708. frontUVs?: Vector4;
  108709. backUVs?: Vector4;
  108710. updatable?: boolean;
  108711. }, scene?: Nullable<Scene>): Mesh;
  108712. /**
  108713. * Creates a sphere mesh
  108714. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108715. * * 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`)
  108716. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108717. * * 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
  108718. * * 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)
  108719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108722. * @param name defines the name of the mesh
  108723. * @param options defines the options used to create the mesh
  108724. * @param scene defines the hosting scene
  108725. * @returns the sphere mesh
  108726. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108727. */
  108728. static CreateSphere(name: string, options: {
  108729. segments?: number;
  108730. diameter?: number;
  108731. diameterX?: number;
  108732. diameterY?: number;
  108733. diameterZ?: number;
  108734. arc?: number;
  108735. slice?: number;
  108736. sideOrientation?: number;
  108737. frontUVs?: Vector4;
  108738. backUVs?: Vector4;
  108739. updatable?: boolean;
  108740. }, scene: any): Mesh;
  108741. /**
  108742. * Creates a plane polygonal mesh. By default, this is a disc
  108743. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108744. * * 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
  108745. * * 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
  108746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108749. * @param name defines the name of the mesh
  108750. * @param options defines the options used to create the mesh
  108751. * @param scene defines the hosting scene
  108752. * @returns the plane polygonal mesh
  108753. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108754. */
  108755. static CreateDisc(name: string, options: {
  108756. radius?: number;
  108757. tessellation?: number;
  108758. arc?: number;
  108759. updatable?: boolean;
  108760. sideOrientation?: number;
  108761. frontUVs?: Vector4;
  108762. backUVs?: Vector4;
  108763. }, scene?: Nullable<Scene>): Mesh;
  108764. /**
  108765. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108766. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108767. * * 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`)
  108768. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108769. * * 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
  108770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108773. * @param name defines the name of the mesh
  108774. * @param options defines the options used to create the mesh
  108775. * @param scene defines the hosting scene
  108776. * @returns the icosahedron mesh
  108777. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108778. */
  108779. static CreateIcoSphere(name: string, options: {
  108780. radius?: number;
  108781. radiusX?: number;
  108782. radiusY?: number;
  108783. radiusZ?: number;
  108784. flat?: boolean;
  108785. subdivisions?: number;
  108786. sideOrientation?: number;
  108787. frontUVs?: Vector4;
  108788. backUVs?: Vector4;
  108789. updatable?: boolean;
  108790. }, scene: Scene): Mesh;
  108791. /**
  108792. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108793. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108794. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108795. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108796. * * 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
  108797. * * 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
  108798. * * 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
  108799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108802. * * 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
  108803. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108804. * * 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
  108805. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108807. * @param name defines the name of the mesh
  108808. * @param options defines the options used to create the mesh
  108809. * @param scene defines the hosting scene
  108810. * @returns the ribbon mesh
  108811. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108812. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108813. */
  108814. static CreateRibbon(name: string, options: {
  108815. pathArray: Vector3[][];
  108816. closeArray?: boolean;
  108817. closePath?: boolean;
  108818. offset?: number;
  108819. updatable?: boolean;
  108820. sideOrientation?: number;
  108821. frontUVs?: Vector4;
  108822. backUVs?: Vector4;
  108823. instance?: Mesh;
  108824. invertUV?: boolean;
  108825. uvs?: Vector2[];
  108826. colors?: Color4[];
  108827. }, scene?: Nullable<Scene>): Mesh;
  108828. /**
  108829. * Creates a cylinder or a cone mesh
  108830. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108831. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108832. * * 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.
  108833. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108834. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108835. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108836. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108837. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108838. * * 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).
  108839. * * 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
  108840. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108841. * * 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
  108842. * * 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.
  108843. * * If `enclose` is false, a ring surface is one element.
  108844. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108845. * * 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
  108846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108849. * @param name defines the name of the mesh
  108850. * @param options defines the options used to create the mesh
  108851. * @param scene defines the hosting scene
  108852. * @returns the cylinder mesh
  108853. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108854. */
  108855. static CreateCylinder(name: string, options: {
  108856. height?: number;
  108857. diameterTop?: number;
  108858. diameterBottom?: number;
  108859. diameter?: number;
  108860. tessellation?: number;
  108861. subdivisions?: number;
  108862. arc?: number;
  108863. faceColors?: Color4[];
  108864. faceUV?: Vector4[];
  108865. updatable?: boolean;
  108866. hasRings?: boolean;
  108867. enclose?: boolean;
  108868. sideOrientation?: number;
  108869. frontUVs?: Vector4;
  108870. backUVs?: Vector4;
  108871. }, scene: any): Mesh;
  108872. /**
  108873. * Creates a torus mesh
  108874. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108875. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108876. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108880. * @param name defines the name of the mesh
  108881. * @param options defines the options used to create the mesh
  108882. * @param scene defines the hosting scene
  108883. * @returns the torus mesh
  108884. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108885. */
  108886. static CreateTorus(name: string, options: {
  108887. diameter?: number;
  108888. thickness?: number;
  108889. tessellation?: number;
  108890. updatable?: boolean;
  108891. sideOrientation?: number;
  108892. frontUVs?: Vector4;
  108893. backUVs?: Vector4;
  108894. }, scene: any): Mesh;
  108895. /**
  108896. * Creates a torus knot mesh
  108897. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108898. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108899. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108900. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108904. * @param name defines the name of the mesh
  108905. * @param options defines the options used to create the mesh
  108906. * @param scene defines the hosting scene
  108907. * @returns the torus knot mesh
  108908. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108909. */
  108910. static CreateTorusKnot(name: string, options: {
  108911. radius?: number;
  108912. tube?: number;
  108913. radialSegments?: number;
  108914. tubularSegments?: number;
  108915. p?: number;
  108916. q?: number;
  108917. updatable?: boolean;
  108918. sideOrientation?: number;
  108919. frontUVs?: Vector4;
  108920. backUVs?: Vector4;
  108921. }, scene: any): Mesh;
  108922. /**
  108923. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108924. * * 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
  108925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108926. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108927. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108928. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108929. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108930. * * 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
  108931. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108934. * @param name defines the name of the new line system
  108935. * @param options defines the options used to create the line system
  108936. * @param scene defines the hosting scene
  108937. * @returns a new line system mesh
  108938. */
  108939. static CreateLineSystem(name: string, options: {
  108940. lines: Vector3[][];
  108941. updatable?: boolean;
  108942. instance?: Nullable<LinesMesh>;
  108943. colors?: Nullable<Color4[][]>;
  108944. useVertexAlpha?: boolean;
  108945. }, scene: Nullable<Scene>): LinesMesh;
  108946. /**
  108947. * Creates a line mesh
  108948. * 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
  108949. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108950. * * The parameter `points` is an array successive Vector3
  108951. * * 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
  108952. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108953. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108954. * * When updating an instance, remember that only point positions can change, not the number of points
  108955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108957. * @param name defines the name of the new line system
  108958. * @param options defines the options used to create the line system
  108959. * @param scene defines the hosting scene
  108960. * @returns a new line mesh
  108961. */
  108962. static CreateLines(name: string, options: {
  108963. points: Vector3[];
  108964. updatable?: boolean;
  108965. instance?: Nullable<LinesMesh>;
  108966. colors?: Color4[];
  108967. useVertexAlpha?: boolean;
  108968. }, scene?: Nullable<Scene>): LinesMesh;
  108969. /**
  108970. * Creates a dashed line mesh
  108971. * * 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
  108972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108973. * * The parameter `points` is an array successive Vector3
  108974. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108975. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108976. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108977. * * 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
  108978. * * When updating an instance, remember that only point positions can change, not the number of points
  108979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108980. * @param name defines the name of the mesh
  108981. * @param options defines the options used to create the mesh
  108982. * @param scene defines the hosting scene
  108983. * @returns the dashed line mesh
  108984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108985. */
  108986. static CreateDashedLines(name: string, options: {
  108987. points: Vector3[];
  108988. dashSize?: number;
  108989. gapSize?: number;
  108990. dashNb?: number;
  108991. updatable?: boolean;
  108992. instance?: LinesMesh;
  108993. }, scene?: Nullable<Scene>): LinesMesh;
  108994. /**
  108995. * 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.
  108996. * * 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.
  108997. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108998. * * 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.
  108999. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109000. * * 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
  109001. * * 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
  109002. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109007. * @param name defines the name of the mesh
  109008. * @param options defines the options used to create the mesh
  109009. * @param scene defines the hosting scene
  109010. * @returns the extruded shape mesh
  109011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109013. */
  109014. static ExtrudeShape(name: string, options: {
  109015. shape: Vector3[];
  109016. path: Vector3[];
  109017. scale?: number;
  109018. rotation?: number;
  109019. cap?: number;
  109020. updatable?: boolean;
  109021. sideOrientation?: number;
  109022. frontUVs?: Vector4;
  109023. backUVs?: Vector4;
  109024. instance?: Mesh;
  109025. invertUV?: boolean;
  109026. }, scene?: Nullable<Scene>): Mesh;
  109027. /**
  109028. * Creates an custom extruded shape mesh.
  109029. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109030. * * 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.
  109031. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109032. * * 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
  109033. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109034. * * 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
  109035. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109036. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109037. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109038. * * 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
  109039. * * 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
  109040. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109043. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109045. * @param name defines the name of the mesh
  109046. * @param options defines the options used to create the mesh
  109047. * @param scene defines the hosting scene
  109048. * @returns the custom extruded shape mesh
  109049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109050. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109052. */
  109053. static ExtrudeShapeCustom(name: string, options: {
  109054. shape: Vector3[];
  109055. path: Vector3[];
  109056. scaleFunction?: any;
  109057. rotationFunction?: any;
  109058. ribbonCloseArray?: boolean;
  109059. ribbonClosePath?: boolean;
  109060. cap?: number;
  109061. updatable?: boolean;
  109062. sideOrientation?: number;
  109063. frontUVs?: Vector4;
  109064. backUVs?: Vector4;
  109065. instance?: Mesh;
  109066. invertUV?: boolean;
  109067. }, scene: Scene): Mesh;
  109068. /**
  109069. * Creates lathe mesh.
  109070. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109071. * * 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
  109072. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109073. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109074. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109075. * * 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
  109076. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109077. * * 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
  109078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109082. * @param name defines the name of the mesh
  109083. * @param options defines the options used to create the mesh
  109084. * @param scene defines the hosting scene
  109085. * @returns the lathe mesh
  109086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109087. */
  109088. static CreateLathe(name: string, options: {
  109089. shape: Vector3[];
  109090. radius?: number;
  109091. tessellation?: number;
  109092. clip?: number;
  109093. arc?: number;
  109094. closed?: boolean;
  109095. updatable?: boolean;
  109096. sideOrientation?: number;
  109097. frontUVs?: Vector4;
  109098. backUVs?: Vector4;
  109099. cap?: number;
  109100. invertUV?: boolean;
  109101. }, scene: Scene): Mesh;
  109102. /**
  109103. * Creates a plane mesh
  109104. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109105. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109106. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109110. * @param name defines the name of the mesh
  109111. * @param options defines the options used to create the mesh
  109112. * @param scene defines the hosting scene
  109113. * @returns the plane mesh
  109114. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109115. */
  109116. static CreatePlane(name: string, options: {
  109117. size?: number;
  109118. width?: number;
  109119. height?: number;
  109120. sideOrientation?: number;
  109121. frontUVs?: Vector4;
  109122. backUVs?: Vector4;
  109123. updatable?: boolean;
  109124. sourcePlane?: Plane;
  109125. }, scene: Scene): Mesh;
  109126. /**
  109127. * Creates a ground mesh
  109128. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109129. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109131. * @param name defines the name of the mesh
  109132. * @param options defines the options used to create the mesh
  109133. * @param scene defines the hosting scene
  109134. * @returns the ground mesh
  109135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109136. */
  109137. static CreateGround(name: string, options: {
  109138. width?: number;
  109139. height?: number;
  109140. subdivisions?: number;
  109141. subdivisionsX?: number;
  109142. subdivisionsY?: number;
  109143. updatable?: boolean;
  109144. }, scene: any): Mesh;
  109145. /**
  109146. * Creates a tiled ground mesh
  109147. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109148. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109149. * * 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
  109150. * * 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
  109151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109152. * @param name defines the name of the mesh
  109153. * @param options defines the options used to create the mesh
  109154. * @param scene defines the hosting scene
  109155. * @returns the tiled ground mesh
  109156. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109157. */
  109158. static CreateTiledGround(name: string, options: {
  109159. xmin: number;
  109160. zmin: number;
  109161. xmax: number;
  109162. zmax: number;
  109163. subdivisions?: {
  109164. w: number;
  109165. h: number;
  109166. };
  109167. precision?: {
  109168. w: number;
  109169. h: number;
  109170. };
  109171. updatable?: boolean;
  109172. }, scene: Scene): Mesh;
  109173. /**
  109174. * Creates a ground mesh from a height map
  109175. * * The parameter `url` sets the URL of the height map image resource.
  109176. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109177. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109178. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109179. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109180. * * 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.
  109181. * * 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).
  109182. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109184. * @param name defines the name of the mesh
  109185. * @param url defines the url to the height map
  109186. * @param options defines the options used to create the mesh
  109187. * @param scene defines the hosting scene
  109188. * @returns the ground mesh
  109189. * @see https://doc.babylonjs.com/babylon101/height_map
  109190. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109191. */
  109192. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109193. width?: number;
  109194. height?: number;
  109195. subdivisions?: number;
  109196. minHeight?: number;
  109197. maxHeight?: number;
  109198. colorFilter?: Color3;
  109199. alphaFilter?: number;
  109200. updatable?: boolean;
  109201. onReady?: (mesh: GroundMesh) => void;
  109202. }, scene: Scene): GroundMesh;
  109203. /**
  109204. * Creates a polygon mesh
  109205. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109206. * * 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
  109207. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109210. * * Remember you can only change the shape positions, not their number when updating a polygon
  109211. * @param name defines the name of the mesh
  109212. * @param options defines the options used to create the mesh
  109213. * @param scene defines the hosting scene
  109214. * @param earcutInjection can be used to inject your own earcut reference
  109215. * @returns the polygon mesh
  109216. */
  109217. static CreatePolygon(name: string, options: {
  109218. shape: Vector3[];
  109219. holes?: Vector3[][];
  109220. depth?: number;
  109221. faceUV?: Vector4[];
  109222. faceColors?: Color4[];
  109223. updatable?: boolean;
  109224. sideOrientation?: number;
  109225. frontUVs?: Vector4;
  109226. backUVs?: Vector4;
  109227. }, scene: Scene, earcutInjection?: any): Mesh;
  109228. /**
  109229. * Creates an extruded polygon mesh, with depth in the Y direction.
  109230. * * 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)
  109231. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109232. * @param name defines the name of the mesh
  109233. * @param options defines the options used to create the mesh
  109234. * @param scene defines the hosting scene
  109235. * @param earcutInjection can be used to inject your own earcut reference
  109236. * @returns the polygon mesh
  109237. */
  109238. static ExtrudePolygon(name: string, options: {
  109239. shape: Vector3[];
  109240. holes?: Vector3[][];
  109241. depth?: number;
  109242. faceUV?: Vector4[];
  109243. faceColors?: Color4[];
  109244. updatable?: boolean;
  109245. sideOrientation?: number;
  109246. frontUVs?: Vector4;
  109247. backUVs?: Vector4;
  109248. }, scene: Scene, earcutInjection?: any): Mesh;
  109249. /**
  109250. * Creates a tube mesh.
  109251. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109252. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109253. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109254. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109255. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109256. * * 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)
  109257. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109258. * * 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
  109259. * * 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
  109260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109264. * @param name defines the name of the mesh
  109265. * @param options defines the options used to create the mesh
  109266. * @param scene defines the hosting scene
  109267. * @returns the tube mesh
  109268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109269. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109270. */
  109271. static CreateTube(name: string, options: {
  109272. path: Vector3[];
  109273. radius?: number;
  109274. tessellation?: number;
  109275. radiusFunction?: {
  109276. (i: number, distance: number): number;
  109277. };
  109278. cap?: number;
  109279. arc?: number;
  109280. updatable?: boolean;
  109281. sideOrientation?: number;
  109282. frontUVs?: Vector4;
  109283. backUVs?: Vector4;
  109284. instance?: Mesh;
  109285. invertUV?: boolean;
  109286. }, scene: Scene): Mesh;
  109287. /**
  109288. * Creates a polyhedron mesh
  109289. * * 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
  109290. * * The parameter `size` (positive float, default 1) sets the polygon size
  109291. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109292. * * 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`
  109293. * * 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
  109294. * * 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)`)
  109295. * * 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
  109296. * * 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
  109297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109300. * @param name defines the name of the mesh
  109301. * @param options defines the options used to create the mesh
  109302. * @param scene defines the hosting scene
  109303. * @returns the polyhedron mesh
  109304. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109305. */
  109306. static CreatePolyhedron(name: string, options: {
  109307. type?: number;
  109308. size?: number;
  109309. sizeX?: number;
  109310. sizeY?: number;
  109311. sizeZ?: number;
  109312. custom?: any;
  109313. faceUV?: Vector4[];
  109314. faceColors?: Color4[];
  109315. flat?: boolean;
  109316. updatable?: boolean;
  109317. sideOrientation?: number;
  109318. frontUVs?: Vector4;
  109319. backUVs?: Vector4;
  109320. }, scene: Scene): Mesh;
  109321. /**
  109322. * Creates a decal mesh.
  109323. * 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
  109324. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109325. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109326. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109327. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109328. * @param name defines the name of the mesh
  109329. * @param sourceMesh defines the mesh where the decal must be applied
  109330. * @param options defines the options used to create the mesh
  109331. * @param scene defines the hosting scene
  109332. * @returns the decal mesh
  109333. * @see https://doc.babylonjs.com/how_to/decals
  109334. */
  109335. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109336. position?: Vector3;
  109337. normal?: Vector3;
  109338. size?: Vector3;
  109339. angle?: number;
  109340. }): Mesh;
  109341. }
  109342. }
  109343. declare module BABYLON {
  109344. /**
  109345. * A simplifier interface for future simplification implementations
  109346. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109347. */
  109348. export interface ISimplifier {
  109349. /**
  109350. * Simplification of a given mesh according to the given settings.
  109351. * Since this requires computation, it is assumed that the function runs async.
  109352. * @param settings The settings of the simplification, including quality and distance
  109353. * @param successCallback A callback that will be called after the mesh was simplified.
  109354. * @param errorCallback in case of an error, this callback will be called. optional.
  109355. */
  109356. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109357. }
  109358. /**
  109359. * Expected simplification settings.
  109360. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109361. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109362. */
  109363. export interface ISimplificationSettings {
  109364. /**
  109365. * Gets or sets the expected quality
  109366. */
  109367. quality: number;
  109368. /**
  109369. * Gets or sets the distance when this optimized version should be used
  109370. */
  109371. distance: number;
  109372. /**
  109373. * Gets an already optimized mesh
  109374. */
  109375. optimizeMesh?: boolean;
  109376. }
  109377. /**
  109378. * Class used to specify simplification options
  109379. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109380. */
  109381. export class SimplificationSettings implements ISimplificationSettings {
  109382. /** expected quality */
  109383. quality: number;
  109384. /** distance when this optimized version should be used */
  109385. distance: number;
  109386. /** already optimized mesh */
  109387. optimizeMesh?: boolean | undefined;
  109388. /**
  109389. * Creates a SimplificationSettings
  109390. * @param quality expected quality
  109391. * @param distance distance when this optimized version should be used
  109392. * @param optimizeMesh already optimized mesh
  109393. */
  109394. constructor(
  109395. /** expected quality */
  109396. quality: number,
  109397. /** distance when this optimized version should be used */
  109398. distance: number,
  109399. /** already optimized mesh */
  109400. optimizeMesh?: boolean | undefined);
  109401. }
  109402. /**
  109403. * Interface used to define a simplification task
  109404. */
  109405. export interface ISimplificationTask {
  109406. /**
  109407. * Array of settings
  109408. */
  109409. settings: Array<ISimplificationSettings>;
  109410. /**
  109411. * Simplification type
  109412. */
  109413. simplificationType: SimplificationType;
  109414. /**
  109415. * Mesh to simplify
  109416. */
  109417. mesh: Mesh;
  109418. /**
  109419. * Callback called on success
  109420. */
  109421. successCallback?: () => void;
  109422. /**
  109423. * Defines if parallel processing can be used
  109424. */
  109425. parallelProcessing: boolean;
  109426. }
  109427. /**
  109428. * Queue used to order the simplification tasks
  109429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109430. */
  109431. export class SimplificationQueue {
  109432. private _simplificationArray;
  109433. /**
  109434. * Gets a boolean indicating that the process is still running
  109435. */
  109436. running: boolean;
  109437. /**
  109438. * Creates a new queue
  109439. */
  109440. constructor();
  109441. /**
  109442. * Adds a new simplification task
  109443. * @param task defines a task to add
  109444. */
  109445. addTask(task: ISimplificationTask): void;
  109446. /**
  109447. * Execute next task
  109448. */
  109449. executeNext(): void;
  109450. /**
  109451. * Execute a simplification task
  109452. * @param task defines the task to run
  109453. */
  109454. runSimplification(task: ISimplificationTask): void;
  109455. private getSimplifier;
  109456. }
  109457. /**
  109458. * The implemented types of simplification
  109459. * At the moment only Quadratic Error Decimation is implemented
  109460. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109461. */
  109462. export enum SimplificationType {
  109463. /** Quadratic error decimation */
  109464. QUADRATIC = 0
  109465. }
  109466. }
  109467. declare module BABYLON {
  109468. interface Scene {
  109469. /** @hidden (Backing field) */
  109470. _simplificationQueue: SimplificationQueue;
  109471. /**
  109472. * Gets or sets the simplification queue attached to the scene
  109473. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109474. */
  109475. simplificationQueue: SimplificationQueue;
  109476. }
  109477. interface Mesh {
  109478. /**
  109479. * Simplify the mesh according to the given array of settings.
  109480. * Function will return immediately and will simplify async
  109481. * @param settings a collection of simplification settings
  109482. * @param parallelProcessing should all levels calculate parallel or one after the other
  109483. * @param simplificationType the type of simplification to run
  109484. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  109485. * @returns the current mesh
  109486. */
  109487. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  109488. }
  109489. /**
  109490. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  109491. * created in a scene
  109492. */
  109493. export class SimplicationQueueSceneComponent implements ISceneComponent {
  109494. /**
  109495. * The component name helpfull to identify the component in the list of scene components.
  109496. */
  109497. readonly name: string;
  109498. /**
  109499. * The scene the component belongs to.
  109500. */
  109501. scene: Scene;
  109502. /**
  109503. * Creates a new instance of the component for the given scene
  109504. * @param scene Defines the scene to register the component in
  109505. */
  109506. constructor(scene: Scene);
  109507. /**
  109508. * Registers the component in a given scene
  109509. */
  109510. register(): void;
  109511. /**
  109512. * Rebuilds the elements related to this component in case of
  109513. * context lost for instance.
  109514. */
  109515. rebuild(): void;
  109516. /**
  109517. * Disposes the component and the associated ressources
  109518. */
  109519. dispose(): void;
  109520. private _beforeCameraUpdate;
  109521. }
  109522. }
  109523. declare module BABYLON {
  109524. /**
  109525. * Class used to enable access to IndexedDB
  109526. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109527. */
  109528. export class Database implements IOfflineProvider {
  109529. private _callbackManifestChecked;
  109530. private _currentSceneUrl;
  109531. private _db;
  109532. private _enableSceneOffline;
  109533. private _enableTexturesOffline;
  109534. private _manifestVersionFound;
  109535. private _mustUpdateRessources;
  109536. private _hasReachedQuota;
  109537. private _isSupported;
  109538. private _idbFactory;
  109539. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  109540. private static IsUASupportingBlobStorage;
  109541. /**
  109542. * Gets a boolean indicating if Database storate is enabled (off by default)
  109543. */
  109544. static IDBStorageEnabled: boolean;
  109545. /**
  109546. * Gets a boolean indicating if scene must be saved in the database
  109547. */
  109548. readonly enableSceneOffline: boolean;
  109549. /**
  109550. * Gets a boolean indicating if textures must be saved in the database
  109551. */
  109552. readonly enableTexturesOffline: boolean;
  109553. /**
  109554. * Creates a new Database
  109555. * @param urlToScene defines the url to load the scene
  109556. * @param callbackManifestChecked defines the callback to use when manifest is checked
  109557. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  109558. */
  109559. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  109560. private static _ParseURL;
  109561. private static _ReturnFullUrlLocation;
  109562. private _checkManifestFile;
  109563. /**
  109564. * Open the database and make it available
  109565. * @param successCallback defines the callback to call on success
  109566. * @param errorCallback defines the callback to call on error
  109567. */
  109568. open(successCallback: () => void, errorCallback: () => void): void;
  109569. /**
  109570. * Loads an image from the database
  109571. * @param url defines the url to load from
  109572. * @param image defines the target DOM image
  109573. */
  109574. loadImage(url: string, image: HTMLImageElement): void;
  109575. private _loadImageFromDBAsync;
  109576. private _saveImageIntoDBAsync;
  109577. private _checkVersionFromDB;
  109578. private _loadVersionFromDBAsync;
  109579. private _saveVersionIntoDBAsync;
  109580. /**
  109581. * Loads a file from database
  109582. * @param url defines the URL to load from
  109583. * @param sceneLoaded defines a callback to call on success
  109584. * @param progressCallBack defines a callback to call when progress changed
  109585. * @param errorCallback defines a callback to call on error
  109586. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  109587. */
  109588. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  109589. private _loadFileAsync;
  109590. private _saveFileAsync;
  109591. /**
  109592. * Validates if xhr data is correct
  109593. * @param xhr defines the request to validate
  109594. * @param dataType defines the expected data type
  109595. * @returns true if data is correct
  109596. */
  109597. private static _ValidateXHRData;
  109598. }
  109599. }
  109600. declare module BABYLON {
  109601. /** @hidden */
  109602. export var gpuUpdateParticlesPixelShader: {
  109603. name: string;
  109604. shader: string;
  109605. };
  109606. }
  109607. declare module BABYLON {
  109608. /** @hidden */
  109609. export var gpuUpdateParticlesVertexShader: {
  109610. name: string;
  109611. shader: string;
  109612. };
  109613. }
  109614. declare module BABYLON {
  109615. /** @hidden */
  109616. export var clipPlaneFragmentDeclaration2: {
  109617. name: string;
  109618. shader: string;
  109619. };
  109620. }
  109621. declare module BABYLON {
  109622. /** @hidden */
  109623. export var gpuRenderParticlesPixelShader: {
  109624. name: string;
  109625. shader: string;
  109626. };
  109627. }
  109628. declare module BABYLON {
  109629. /** @hidden */
  109630. export var clipPlaneVertexDeclaration2: {
  109631. name: string;
  109632. shader: string;
  109633. };
  109634. }
  109635. declare module BABYLON {
  109636. /** @hidden */
  109637. export var gpuRenderParticlesVertexShader: {
  109638. name: string;
  109639. shader: string;
  109640. };
  109641. }
  109642. declare module BABYLON {
  109643. /**
  109644. * This represents a GPU particle system in Babylon
  109645. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  109646. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  109647. */
  109648. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  109649. /**
  109650. * The layer mask we are rendering the particles through.
  109651. */
  109652. layerMask: number;
  109653. private _capacity;
  109654. private _activeCount;
  109655. private _currentActiveCount;
  109656. private _accumulatedCount;
  109657. private _renderEffect;
  109658. private _updateEffect;
  109659. private _buffer0;
  109660. private _buffer1;
  109661. private _spriteBuffer;
  109662. private _updateVAO;
  109663. private _renderVAO;
  109664. private _targetIndex;
  109665. private _sourceBuffer;
  109666. private _targetBuffer;
  109667. private _engine;
  109668. private _currentRenderId;
  109669. private _started;
  109670. private _stopped;
  109671. private _timeDelta;
  109672. private _randomTexture;
  109673. private _randomTexture2;
  109674. private _attributesStrideSize;
  109675. private _updateEffectOptions;
  109676. private _randomTextureSize;
  109677. private _actualFrame;
  109678. private readonly _rawTextureWidth;
  109679. /**
  109680. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  109681. */
  109682. static readonly IsSupported: boolean;
  109683. /**
  109684. * An event triggered when the system is disposed.
  109685. */
  109686. onDisposeObservable: Observable<GPUParticleSystem>;
  109687. /**
  109688. * Gets the maximum number of particles active at the same time.
  109689. * @returns The max number of active particles.
  109690. */
  109691. getCapacity(): number;
  109692. /**
  109693. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  109694. * to override the particles.
  109695. */
  109696. forceDepthWrite: boolean;
  109697. /**
  109698. * Gets or set the number of active particles
  109699. */
  109700. activeParticleCount: number;
  109701. private _preWarmDone;
  109702. /**
  109703. * Is this system ready to be used/rendered
  109704. * @return true if the system is ready
  109705. */
  109706. isReady(): boolean;
  109707. /**
  109708. * Gets if the system has been started. (Note: this will still be true after stop is called)
  109709. * @returns True if it has been started, otherwise false.
  109710. */
  109711. isStarted(): boolean;
  109712. /**
  109713. * Starts the particle system and begins to emit
  109714. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  109715. */
  109716. start(delay?: number): void;
  109717. /**
  109718. * Stops the particle system.
  109719. */
  109720. stop(): void;
  109721. /**
  109722. * Remove all active particles
  109723. */
  109724. reset(): void;
  109725. /**
  109726. * Returns the string "GPUParticleSystem"
  109727. * @returns a string containing the class name
  109728. */
  109729. getClassName(): string;
  109730. private _colorGradientsTexture;
  109731. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  109732. /**
  109733. * Adds a new color gradient
  109734. * @param gradient defines the gradient to use (between 0 and 1)
  109735. * @param color1 defines the color to affect to the specified gradient
  109736. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  109737. * @returns the current particle system
  109738. */
  109739. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  109740. /**
  109741. * Remove a specific color gradient
  109742. * @param gradient defines the gradient to remove
  109743. * @returns the current particle system
  109744. */
  109745. removeColorGradient(gradient: number): GPUParticleSystem;
  109746. private _angularSpeedGradientsTexture;
  109747. private _sizeGradientsTexture;
  109748. private _velocityGradientsTexture;
  109749. private _limitVelocityGradientsTexture;
  109750. private _dragGradientsTexture;
  109751. private _addFactorGradient;
  109752. /**
  109753. * Adds a new size gradient
  109754. * @param gradient defines the gradient to use (between 0 and 1)
  109755. * @param factor defines the size factor to affect to the specified gradient
  109756. * @returns the current particle system
  109757. */
  109758. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  109759. /**
  109760. * Remove a specific size gradient
  109761. * @param gradient defines the gradient to remove
  109762. * @returns the current particle system
  109763. */
  109764. removeSizeGradient(gradient: number): GPUParticleSystem;
  109765. /**
  109766. * Adds a new angular speed gradient
  109767. * @param gradient defines the gradient to use (between 0 and 1)
  109768. * @param factor defines the angular speed to affect to the specified gradient
  109769. * @returns the current particle system
  109770. */
  109771. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  109772. /**
  109773. * Remove a specific angular speed gradient
  109774. * @param gradient defines the gradient to remove
  109775. * @returns the current particle system
  109776. */
  109777. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  109778. /**
  109779. * Adds a new velocity gradient
  109780. * @param gradient defines the gradient to use (between 0 and 1)
  109781. * @param factor defines the velocity to affect to the specified gradient
  109782. * @returns the current particle system
  109783. */
  109784. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  109785. /**
  109786. * Remove a specific velocity gradient
  109787. * @param gradient defines the gradient to remove
  109788. * @returns the current particle system
  109789. */
  109790. removeVelocityGradient(gradient: number): GPUParticleSystem;
  109791. /**
  109792. * Adds a new limit velocity gradient
  109793. * @param gradient defines the gradient to use (between 0 and 1)
  109794. * @param factor defines the limit velocity value to affect to the specified gradient
  109795. * @returns the current particle system
  109796. */
  109797. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  109798. /**
  109799. * Remove a specific limit velocity gradient
  109800. * @param gradient defines the gradient to remove
  109801. * @returns the current particle system
  109802. */
  109803. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  109804. /**
  109805. * Adds a new drag gradient
  109806. * @param gradient defines the gradient to use (between 0 and 1)
  109807. * @param factor defines the drag value to affect to the specified gradient
  109808. * @returns the current particle system
  109809. */
  109810. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  109811. /**
  109812. * Remove a specific drag gradient
  109813. * @param gradient defines the gradient to remove
  109814. * @returns the current particle system
  109815. */
  109816. removeDragGradient(gradient: number): GPUParticleSystem;
  109817. /**
  109818. * Not supported by GPUParticleSystem
  109819. * @param gradient defines the gradient to use (between 0 and 1)
  109820. * @param factor defines the emit rate value to affect to the specified gradient
  109821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109822. * @returns the current particle system
  109823. */
  109824. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109825. /**
  109826. * Not supported by GPUParticleSystem
  109827. * @param gradient defines the gradient to remove
  109828. * @returns the current particle system
  109829. */
  109830. removeEmitRateGradient(gradient: number): IParticleSystem;
  109831. /**
  109832. * Not supported by GPUParticleSystem
  109833. * @param gradient defines the gradient to use (between 0 and 1)
  109834. * @param factor defines the start size value to affect to the specified gradient
  109835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109836. * @returns the current particle system
  109837. */
  109838. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109839. /**
  109840. * Not supported by GPUParticleSystem
  109841. * @param gradient defines the gradient to remove
  109842. * @returns the current particle system
  109843. */
  109844. removeStartSizeGradient(gradient: number): IParticleSystem;
  109845. /**
  109846. * Not supported by GPUParticleSystem
  109847. * @param gradient defines the gradient to use (between 0 and 1)
  109848. * @param min defines the color remap minimal range
  109849. * @param max defines the color remap maximal range
  109850. * @returns the current particle system
  109851. */
  109852. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  109853. /**
  109854. * Not supported by GPUParticleSystem
  109855. * @param gradient defines the gradient to remove
  109856. * @returns the current particle system
  109857. */
  109858. removeColorRemapGradient(): IParticleSystem;
  109859. /**
  109860. * Not supported by GPUParticleSystem
  109861. * @param gradient defines the gradient to use (between 0 and 1)
  109862. * @param min defines the alpha remap minimal range
  109863. * @param max defines the alpha remap maximal range
  109864. * @returns the current particle system
  109865. */
  109866. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  109867. /**
  109868. * Not supported by GPUParticleSystem
  109869. * @param gradient defines the gradient to remove
  109870. * @returns the current particle system
  109871. */
  109872. removeAlphaRemapGradient(): IParticleSystem;
  109873. /**
  109874. * Not supported by GPUParticleSystem
  109875. * @param gradient defines the gradient to use (between 0 and 1)
  109876. * @param color defines the color to affect to the specified gradient
  109877. * @returns the current particle system
  109878. */
  109879. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  109880. /**
  109881. * Not supported by GPUParticleSystem
  109882. * @param gradient defines the gradient to remove
  109883. * @returns the current particle system
  109884. */
  109885. removeRampGradient(): IParticleSystem;
  109886. /**
  109887. * Not supported by GPUParticleSystem
  109888. * @returns the list of ramp gradients
  109889. */
  109890. getRampGradients(): Nullable<Array<Color3Gradient>>;
  109891. /**
  109892. * Not supported by GPUParticleSystem
  109893. * Gets or sets a boolean indicating that ramp gradients must be used
  109894. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  109895. */
  109896. useRampGradients: boolean;
  109897. /**
  109898. * Not supported by GPUParticleSystem
  109899. * @param gradient defines the gradient to use (between 0 and 1)
  109900. * @param factor defines the life time factor to affect to the specified gradient
  109901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109902. * @returns the current particle system
  109903. */
  109904. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  109905. /**
  109906. * Not supported by GPUParticleSystem
  109907. * @param gradient defines the gradient to remove
  109908. * @returns the current particle system
  109909. */
  109910. removeLifeTimeGradient(gradient: number): IParticleSystem;
  109911. /**
  109912. * Instantiates a GPU particle system.
  109913. * 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.
  109914. * @param name The name of the particle system
  109915. * @param options The options used to create the system
  109916. * @param scene The scene the particle system belongs to
  109917. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  109918. */
  109919. constructor(name: string, options: Partial<{
  109920. capacity: number;
  109921. randomTextureSize: number;
  109922. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  109923. protected _reset(): void;
  109924. private _createUpdateVAO;
  109925. private _createRenderVAO;
  109926. private _initialize;
  109927. /** @hidden */
  109928. _recreateUpdateEffect(): void;
  109929. /** @hidden */
  109930. _recreateRenderEffect(): void;
  109931. /**
  109932. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109933. * @param preWarm defines if we are in the pre-warmimg phase
  109934. */
  109935. animate(preWarm?: boolean): void;
  109936. private _createFactorGradientTexture;
  109937. private _createSizeGradientTexture;
  109938. private _createAngularSpeedGradientTexture;
  109939. private _createVelocityGradientTexture;
  109940. private _createLimitVelocityGradientTexture;
  109941. private _createDragGradientTexture;
  109942. private _createColorGradientTexture;
  109943. /**
  109944. * Renders the particle system in its current state
  109945. * @param preWarm defines if the system should only update the particles but not render them
  109946. * @returns the current number of particles
  109947. */
  109948. render(preWarm?: boolean): number;
  109949. /**
  109950. * Rebuilds the particle system
  109951. */
  109952. rebuild(): void;
  109953. private _releaseBuffers;
  109954. private _releaseVAOs;
  109955. /**
  109956. * Disposes the particle system and free the associated resources
  109957. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109958. */
  109959. dispose(disposeTexture?: boolean): void;
  109960. /**
  109961. * Clones the particle system.
  109962. * @param name The name of the cloned object
  109963. * @param newEmitter The new emitter to use
  109964. * @returns the cloned particle system
  109965. */
  109966. clone(name: string, newEmitter: any): GPUParticleSystem;
  109967. /**
  109968. * Serializes the particle system to a JSON object.
  109969. * @returns the JSON object
  109970. */
  109971. serialize(): any;
  109972. /**
  109973. * Parses a JSON object to create a GPU particle system.
  109974. * @param parsedParticleSystem The JSON object to parse
  109975. * @param scene The scene to create the particle system in
  109976. * @param rootUrl The root url to use to load external dependencies like texture
  109977. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109978. * @returns the parsed GPU particle system
  109979. */
  109980. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  109981. }
  109982. }
  109983. declare module BABYLON {
  109984. /**
  109985. * Represents a set of particle systems working together to create a specific effect
  109986. */
  109987. export class ParticleSystemSet implements IDisposable {
  109988. private _emitterCreationOptions;
  109989. private _emitterNode;
  109990. /**
  109991. * Gets the particle system list
  109992. */
  109993. systems: IParticleSystem[];
  109994. /**
  109995. * Gets the emitter node used with this set
  109996. */
  109997. readonly emitterNode: Nullable<TransformNode>;
  109998. /**
  109999. * Creates a new emitter mesh as a sphere
  110000. * @param options defines the options used to create the sphere
  110001. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110002. * @param scene defines the hosting scene
  110003. */
  110004. setEmitterAsSphere(options: {
  110005. diameter: number;
  110006. segments: number;
  110007. color: Color3;
  110008. }, renderingGroupId: number, scene: Scene): void;
  110009. /**
  110010. * Starts all particle systems of the set
  110011. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110012. */
  110013. start(emitter?: AbstractMesh): void;
  110014. /**
  110015. * Release all associated resources
  110016. */
  110017. dispose(): void;
  110018. /**
  110019. * Serialize the set into a JSON compatible object
  110020. * @returns a JSON compatible representation of the set
  110021. */
  110022. serialize(): any;
  110023. /**
  110024. * Parse a new ParticleSystemSet from a serialized source
  110025. * @param data defines a JSON compatible representation of the set
  110026. * @param scene defines the hosting scene
  110027. * @param gpu defines if we want GPU particles or CPU particles
  110028. * @returns a new ParticleSystemSet
  110029. */
  110030. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110031. }
  110032. }
  110033. declare module BABYLON {
  110034. /**
  110035. * This class is made for on one-liner static method to help creating particle system set.
  110036. */
  110037. export class ParticleHelper {
  110038. /**
  110039. * Gets or sets base Assets URL
  110040. */
  110041. static BaseAssetsUrl: string;
  110042. /**
  110043. * Create a default particle system that you can tweak
  110044. * @param emitter defines the emitter to use
  110045. * @param capacity defines the system capacity (default is 500 particles)
  110046. * @param scene defines the hosting scene
  110047. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110048. * @returns the new Particle system
  110049. */
  110050. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110051. /**
  110052. * This is the main static method (one-liner) of this helper to create different particle systems
  110053. * @param type This string represents the type to the particle system to create
  110054. * @param scene The scene where the particle system should live
  110055. * @param gpu If the system will use gpu
  110056. * @returns the ParticleSystemSet created
  110057. */
  110058. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110059. /**
  110060. * Static function used to export a particle system to a ParticleSystemSet variable.
  110061. * Please note that the emitter shape is not exported
  110062. * @param systems defines the particle systems to export
  110063. * @returns the created particle system set
  110064. */
  110065. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110066. }
  110067. }
  110068. declare module BABYLON {
  110069. interface Engine {
  110070. /**
  110071. * Create an effect to use with particle systems.
  110072. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110073. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110074. * @param uniformsNames defines a list of attribute names
  110075. * @param samplers defines an array of string used to represent textures
  110076. * @param defines defines the string containing the defines to use to compile the shaders
  110077. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110078. * @param onCompiled defines a function to call when the effect creation is successful
  110079. * @param onError defines a function to call when the effect creation has failed
  110080. * @returns the new Effect
  110081. */
  110082. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110083. }
  110084. interface Mesh {
  110085. /**
  110086. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110087. * @returns an array of IParticleSystem
  110088. */
  110089. getEmittedParticleSystems(): IParticleSystem[];
  110090. /**
  110091. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110092. * @returns an array of IParticleSystem
  110093. */
  110094. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110095. }
  110096. /**
  110097. * @hidden
  110098. */
  110099. export var _IDoNeedToBeInTheBuild: number;
  110100. }
  110101. declare module BABYLON {
  110102. interface Scene {
  110103. /** @hidden (Backing field) */
  110104. _physicsEngine: Nullable<IPhysicsEngine>;
  110105. /**
  110106. * Gets the current physics engine
  110107. * @returns a IPhysicsEngine or null if none attached
  110108. */
  110109. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110110. /**
  110111. * Enables physics to the current scene
  110112. * @param gravity defines the scene's gravity for the physics engine
  110113. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110114. * @return a boolean indicating if the physics engine was initialized
  110115. */
  110116. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110117. /**
  110118. * Disables and disposes the physics engine associated with the scene
  110119. */
  110120. disablePhysicsEngine(): void;
  110121. /**
  110122. * Gets a boolean indicating if there is an active physics engine
  110123. * @returns a boolean indicating if there is an active physics engine
  110124. */
  110125. isPhysicsEnabled(): boolean;
  110126. /**
  110127. * Deletes a physics compound impostor
  110128. * @param compound defines the compound to delete
  110129. */
  110130. deleteCompoundImpostor(compound: any): void;
  110131. /**
  110132. * An event triggered when physic simulation is about to be run
  110133. */
  110134. onBeforePhysicsObservable: Observable<Scene>;
  110135. /**
  110136. * An event triggered when physic simulation has been done
  110137. */
  110138. onAfterPhysicsObservable: Observable<Scene>;
  110139. }
  110140. interface AbstractMesh {
  110141. /** @hidden */
  110142. _physicsImpostor: Nullable<PhysicsImpostor>;
  110143. /**
  110144. * Gets or sets impostor used for physic simulation
  110145. * @see http://doc.babylonjs.com/features/physics_engine
  110146. */
  110147. physicsImpostor: Nullable<PhysicsImpostor>;
  110148. /**
  110149. * Gets the current physics impostor
  110150. * @see http://doc.babylonjs.com/features/physics_engine
  110151. * @returns a physics impostor or null
  110152. */
  110153. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110154. /** Apply a physic impulse to the mesh
  110155. * @param force defines the force to apply
  110156. * @param contactPoint defines where to apply the force
  110157. * @returns the current mesh
  110158. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110159. */
  110160. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110161. /**
  110162. * Creates a physic joint between two meshes
  110163. * @param otherMesh defines the other mesh to use
  110164. * @param pivot1 defines the pivot to use on this mesh
  110165. * @param pivot2 defines the pivot to use on the other mesh
  110166. * @param options defines additional options (can be plugin dependent)
  110167. * @returns the current mesh
  110168. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110169. */
  110170. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110171. /** @hidden */
  110172. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110173. }
  110174. /**
  110175. * Defines the physics engine scene component responsible to manage a physics engine
  110176. */
  110177. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110178. /**
  110179. * The component name helpful to identify the component in the list of scene components.
  110180. */
  110181. readonly name: string;
  110182. /**
  110183. * The scene the component belongs to.
  110184. */
  110185. scene: Scene;
  110186. /**
  110187. * Creates a new instance of the component for the given scene
  110188. * @param scene Defines the scene to register the component in
  110189. */
  110190. constructor(scene: Scene);
  110191. /**
  110192. * Registers the component in a given scene
  110193. */
  110194. register(): void;
  110195. /**
  110196. * Rebuilds the elements related to this component in case of
  110197. * context lost for instance.
  110198. */
  110199. rebuild(): void;
  110200. /**
  110201. * Disposes the component and the associated ressources
  110202. */
  110203. dispose(): void;
  110204. }
  110205. }
  110206. declare module BABYLON {
  110207. /**
  110208. * A helper for physics simulations
  110209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110210. */
  110211. export class PhysicsHelper {
  110212. private _scene;
  110213. private _physicsEngine;
  110214. /**
  110215. * Initializes the Physics helper
  110216. * @param scene Babylon.js scene
  110217. */
  110218. constructor(scene: Scene);
  110219. /**
  110220. * Applies a radial explosion impulse
  110221. * @param origin the origin of the explosion
  110222. * @param radiusOrEventOptions the radius or the options of radial explosion
  110223. * @param strength the explosion strength
  110224. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110225. * @returns A physics radial explosion event, or null
  110226. */
  110227. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110228. /**
  110229. * Applies a radial explosion force
  110230. * @param origin the origin of the explosion
  110231. * @param radiusOrEventOptions the radius or the options of radial explosion
  110232. * @param strength the explosion strength
  110233. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110234. * @returns A physics radial explosion event, or null
  110235. */
  110236. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110237. /**
  110238. * Creates a gravitational field
  110239. * @param origin the origin of the explosion
  110240. * @param radiusOrEventOptions the radius or the options of radial explosion
  110241. * @param strength the explosion strength
  110242. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110243. * @returns A physics gravitational field event, or null
  110244. */
  110245. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110246. /**
  110247. * Creates a physics updraft event
  110248. * @param origin the origin of the updraft
  110249. * @param radiusOrEventOptions the radius or the options of the updraft
  110250. * @param strength the strength of the updraft
  110251. * @param height the height of the updraft
  110252. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110253. * @returns A physics updraft event, or null
  110254. */
  110255. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110256. /**
  110257. * Creates a physics vortex event
  110258. * @param origin the of the vortex
  110259. * @param radiusOrEventOptions the radius or the options of the vortex
  110260. * @param strength the strength of the vortex
  110261. * @param height the height of the vortex
  110262. * @returns a Physics vortex event, or null
  110263. * A physics vortex event or null
  110264. */
  110265. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110266. }
  110267. /**
  110268. * Represents a physics radial explosion event
  110269. */
  110270. class PhysicsRadialExplosionEvent {
  110271. private _scene;
  110272. private _options;
  110273. private _sphere;
  110274. private _dataFetched;
  110275. /**
  110276. * Initializes a radial explosioin event
  110277. * @param _scene BabylonJS scene
  110278. * @param _options The options for the vortex event
  110279. */
  110280. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110281. /**
  110282. * Returns the data related to the radial explosion event (sphere).
  110283. * @returns The radial explosion event data
  110284. */
  110285. getData(): PhysicsRadialExplosionEventData;
  110286. /**
  110287. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110288. * @param impostor A physics imposter
  110289. * @param origin the origin of the explosion
  110290. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110291. */
  110292. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110293. /**
  110294. * Triggers affecterd impostors callbacks
  110295. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110296. */
  110297. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110298. /**
  110299. * Disposes the sphere.
  110300. * @param force Specifies if the sphere should be disposed by force
  110301. */
  110302. dispose(force?: boolean): void;
  110303. /*** Helpers ***/
  110304. private _prepareSphere;
  110305. private _intersectsWithSphere;
  110306. }
  110307. /**
  110308. * Represents a gravitational field event
  110309. */
  110310. class PhysicsGravitationalFieldEvent {
  110311. private _physicsHelper;
  110312. private _scene;
  110313. private _origin;
  110314. private _options;
  110315. private _tickCallback;
  110316. private _sphere;
  110317. private _dataFetched;
  110318. /**
  110319. * Initializes the physics gravitational field event
  110320. * @param _physicsHelper A physics helper
  110321. * @param _scene BabylonJS scene
  110322. * @param _origin The origin position of the gravitational field event
  110323. * @param _options The options for the vortex event
  110324. */
  110325. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110326. /**
  110327. * Returns the data related to the gravitational field event (sphere).
  110328. * @returns A gravitational field event
  110329. */
  110330. getData(): PhysicsGravitationalFieldEventData;
  110331. /**
  110332. * Enables the gravitational field.
  110333. */
  110334. enable(): void;
  110335. /**
  110336. * Disables the gravitational field.
  110337. */
  110338. disable(): void;
  110339. /**
  110340. * Disposes the sphere.
  110341. * @param force The force to dispose from the gravitational field event
  110342. */
  110343. dispose(force?: boolean): void;
  110344. private _tick;
  110345. }
  110346. /**
  110347. * Represents a physics updraft event
  110348. */
  110349. class PhysicsUpdraftEvent {
  110350. private _scene;
  110351. private _origin;
  110352. private _options;
  110353. private _physicsEngine;
  110354. private _originTop;
  110355. private _originDirection;
  110356. private _tickCallback;
  110357. private _cylinder;
  110358. private _cylinderPosition;
  110359. private _dataFetched;
  110360. /**
  110361. * Initializes the physics updraft event
  110362. * @param _scene BabylonJS scene
  110363. * @param _origin The origin position of the updraft
  110364. * @param _options The options for the updraft event
  110365. */
  110366. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110367. /**
  110368. * Returns the data related to the updraft event (cylinder).
  110369. * @returns A physics updraft event
  110370. */
  110371. getData(): PhysicsUpdraftEventData;
  110372. /**
  110373. * Enables the updraft.
  110374. */
  110375. enable(): void;
  110376. /**
  110377. * Disables the updraft.
  110378. */
  110379. disable(): void;
  110380. /**
  110381. * Disposes the cylinder.
  110382. * @param force Specifies if the updraft should be disposed by force
  110383. */
  110384. dispose(force?: boolean): void;
  110385. private getImpostorHitData;
  110386. private _tick;
  110387. /*** Helpers ***/
  110388. private _prepareCylinder;
  110389. private _intersectsWithCylinder;
  110390. }
  110391. /**
  110392. * Represents a physics vortex event
  110393. */
  110394. class PhysicsVortexEvent {
  110395. private _scene;
  110396. private _origin;
  110397. private _options;
  110398. private _physicsEngine;
  110399. private _originTop;
  110400. private _tickCallback;
  110401. private _cylinder;
  110402. private _cylinderPosition;
  110403. private _dataFetched;
  110404. /**
  110405. * Initializes the physics vortex event
  110406. * @param _scene The BabylonJS scene
  110407. * @param _origin The origin position of the vortex
  110408. * @param _options The options for the vortex event
  110409. */
  110410. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110411. /**
  110412. * Returns the data related to the vortex event (cylinder).
  110413. * @returns The physics vortex event data
  110414. */
  110415. getData(): PhysicsVortexEventData;
  110416. /**
  110417. * Enables the vortex.
  110418. */
  110419. enable(): void;
  110420. /**
  110421. * Disables the cortex.
  110422. */
  110423. disable(): void;
  110424. /**
  110425. * Disposes the sphere.
  110426. * @param force
  110427. */
  110428. dispose(force?: boolean): void;
  110429. private getImpostorHitData;
  110430. private _tick;
  110431. /*** Helpers ***/
  110432. private _prepareCylinder;
  110433. private _intersectsWithCylinder;
  110434. }
  110435. /**
  110436. * Options fot the radial explosion event
  110437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110438. */
  110439. export class PhysicsRadialExplosionEventOptions {
  110440. /**
  110441. * The radius of the sphere for the radial explosion.
  110442. */
  110443. radius: number;
  110444. /**
  110445. * The strenth of the explosion.
  110446. */
  110447. strength: number;
  110448. /**
  110449. * The strenght of the force in correspondence to the distance of the affected object
  110450. */
  110451. falloff: PhysicsRadialImpulseFalloff;
  110452. /**
  110453. * Sphere options for the radial explosion.
  110454. */
  110455. sphere: {
  110456. segments: number;
  110457. diameter: number;
  110458. };
  110459. /**
  110460. * Sphere options for the radial explosion.
  110461. */
  110462. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  110463. }
  110464. /**
  110465. * Options fot the updraft event
  110466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110467. */
  110468. export class PhysicsUpdraftEventOptions {
  110469. /**
  110470. * The radius of the cylinder for the vortex
  110471. */
  110472. radius: number;
  110473. /**
  110474. * The strenth of the updraft.
  110475. */
  110476. strength: number;
  110477. /**
  110478. * The height of the cylinder for the updraft.
  110479. */
  110480. height: number;
  110481. /**
  110482. * The mode for the the updraft.
  110483. */
  110484. updraftMode: PhysicsUpdraftMode;
  110485. }
  110486. /**
  110487. * Options fot the vortex event
  110488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110489. */
  110490. export class PhysicsVortexEventOptions {
  110491. /**
  110492. * The radius of the cylinder for the vortex
  110493. */
  110494. radius: number;
  110495. /**
  110496. * The strenth of the vortex.
  110497. */
  110498. strength: number;
  110499. /**
  110500. * The height of the cylinder for the vortex.
  110501. */
  110502. height: number;
  110503. /**
  110504. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  110505. */
  110506. centripetalForceThreshold: number;
  110507. /**
  110508. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  110509. */
  110510. centripetalForceMultiplier: number;
  110511. /**
  110512. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  110513. */
  110514. centrifugalForceMultiplier: number;
  110515. /**
  110516. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  110517. */
  110518. updraftForceMultiplier: number;
  110519. }
  110520. /**
  110521. * The strenght of the force in correspondence to the distance of the affected object
  110522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110523. */
  110524. export enum PhysicsRadialImpulseFalloff {
  110525. /** Defines that impulse is constant in strength across it's whole radius */
  110526. Constant = 0,
  110527. /** Defines that impulse gets weaker if it's further from the origin */
  110528. Linear = 1
  110529. }
  110530. /**
  110531. * The strength of the force in correspondence to the distance of the affected object
  110532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110533. */
  110534. export enum PhysicsUpdraftMode {
  110535. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  110536. Center = 0,
  110537. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  110538. Perpendicular = 1
  110539. }
  110540. /**
  110541. * Interface for a physics hit data
  110542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110543. */
  110544. export interface PhysicsHitData {
  110545. /**
  110546. * The force applied at the contact point
  110547. */
  110548. force: Vector3;
  110549. /**
  110550. * The contact point
  110551. */
  110552. contactPoint: Vector3;
  110553. /**
  110554. * The distance from the origin to the contact point
  110555. */
  110556. distanceFromOrigin: number;
  110557. }
  110558. /**
  110559. * Interface for radial explosion event data
  110560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110561. */
  110562. export interface PhysicsRadialExplosionEventData {
  110563. /**
  110564. * A sphere used for the radial explosion event
  110565. */
  110566. sphere: Mesh;
  110567. }
  110568. /**
  110569. * Interface for gravitational field event data
  110570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110571. */
  110572. export interface PhysicsGravitationalFieldEventData {
  110573. /**
  110574. * A sphere mesh used for the gravitational field event
  110575. */
  110576. sphere: Mesh;
  110577. }
  110578. /**
  110579. * Interface for updraft event data
  110580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110581. */
  110582. export interface PhysicsUpdraftEventData {
  110583. /**
  110584. * A cylinder used for the updraft event
  110585. */
  110586. cylinder: Mesh;
  110587. }
  110588. /**
  110589. * Interface for vortex event data
  110590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110591. */
  110592. export interface PhysicsVortexEventData {
  110593. /**
  110594. * A cylinder used for the vortex event
  110595. */
  110596. cylinder: Mesh;
  110597. }
  110598. /**
  110599. * Interface for an affected physics impostor
  110600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110601. */
  110602. export interface PhysicsAffectedImpostorWithData {
  110603. /**
  110604. * The impostor affected by the effect
  110605. */
  110606. impostor: PhysicsImpostor;
  110607. /**
  110608. * The data about the hit/horce from the explosion
  110609. */
  110610. hitData: PhysicsHitData;
  110611. }
  110612. }
  110613. declare module BABYLON {
  110614. /** @hidden */
  110615. export var blackAndWhitePixelShader: {
  110616. name: string;
  110617. shader: string;
  110618. };
  110619. }
  110620. declare module BABYLON {
  110621. /**
  110622. * Post process used to render in black and white
  110623. */
  110624. export class BlackAndWhitePostProcess extends PostProcess {
  110625. /**
  110626. * Linear about to convert he result to black and white (default: 1)
  110627. */
  110628. degree: number;
  110629. /**
  110630. * Creates a black and white post process
  110631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  110632. * @param name The name of the effect.
  110633. * @param options The required width/height ratio to downsize to before computing the render pass.
  110634. * @param camera The camera to apply the render pass to.
  110635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110636. * @param engine The engine which the post process will be applied. (default: current engine)
  110637. * @param reusable If the post process can be reused on the same frame. (default: false)
  110638. */
  110639. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110640. }
  110641. }
  110642. declare module BABYLON {
  110643. /**
  110644. * This represents a set of one or more post processes in Babylon.
  110645. * A post process can be used to apply a shader to a texture after it is rendered.
  110646. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110647. */
  110648. export class PostProcessRenderEffect {
  110649. private _postProcesses;
  110650. private _getPostProcesses;
  110651. private _singleInstance;
  110652. private _cameras;
  110653. private _indicesForCamera;
  110654. /**
  110655. * Name of the effect
  110656. * @hidden
  110657. */
  110658. _name: string;
  110659. /**
  110660. * Instantiates a post process render effect.
  110661. * A post process can be used to apply a shader to a texture after it is rendered.
  110662. * @param engine The engine the effect is tied to
  110663. * @param name The name of the effect
  110664. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  110665. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  110666. */
  110667. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  110668. /**
  110669. * Checks if all the post processes in the effect are supported.
  110670. */
  110671. readonly isSupported: boolean;
  110672. /**
  110673. * Updates the current state of the effect
  110674. * @hidden
  110675. */
  110676. _update(): void;
  110677. /**
  110678. * Attaches the effect on cameras
  110679. * @param cameras The camera to attach to.
  110680. * @hidden
  110681. */
  110682. _attachCameras(cameras: Camera): void;
  110683. /**
  110684. * Attaches the effect on cameras
  110685. * @param cameras The camera to attach to.
  110686. * @hidden
  110687. */
  110688. _attachCameras(cameras: Camera[]): void;
  110689. /**
  110690. * Detatches the effect on cameras
  110691. * @param cameras The camera to detatch from.
  110692. * @hidden
  110693. */
  110694. _detachCameras(cameras: Camera): void;
  110695. /**
  110696. * Detatches the effect on cameras
  110697. * @param cameras The camera to detatch from.
  110698. * @hidden
  110699. */
  110700. _detachCameras(cameras: Camera[]): void;
  110701. /**
  110702. * Enables the effect on given cameras
  110703. * @param cameras The camera to enable.
  110704. * @hidden
  110705. */
  110706. _enable(cameras: Camera): void;
  110707. /**
  110708. * Enables the effect on given cameras
  110709. * @param cameras The camera to enable.
  110710. * @hidden
  110711. */
  110712. _enable(cameras: Nullable<Camera[]>): void;
  110713. /**
  110714. * Disables the effect on the given cameras
  110715. * @param cameras The camera to disable.
  110716. * @hidden
  110717. */
  110718. _disable(cameras: Camera): void;
  110719. /**
  110720. * Disables the effect on the given cameras
  110721. * @param cameras The camera to disable.
  110722. * @hidden
  110723. */
  110724. _disable(cameras: Nullable<Camera[]>): void;
  110725. /**
  110726. * Gets a list of the post processes contained in the effect.
  110727. * @param camera The camera to get the post processes on.
  110728. * @returns The list of the post processes in the effect.
  110729. */
  110730. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  110731. }
  110732. }
  110733. declare module BABYLON {
  110734. /** @hidden */
  110735. export var extractHighlightsPixelShader: {
  110736. name: string;
  110737. shader: string;
  110738. };
  110739. }
  110740. declare module BABYLON {
  110741. /**
  110742. * 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.
  110743. */
  110744. export class ExtractHighlightsPostProcess extends PostProcess {
  110745. /**
  110746. * The luminance threshold, pixels below this value will be set to black.
  110747. */
  110748. threshold: number;
  110749. /** @hidden */
  110750. _exposure: number;
  110751. /**
  110752. * Post process which has the input texture to be used when performing highlight extraction
  110753. * @hidden
  110754. */
  110755. _inputPostProcess: Nullable<PostProcess>;
  110756. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110757. }
  110758. }
  110759. declare module BABYLON {
  110760. /** @hidden */
  110761. export var bloomMergePixelShader: {
  110762. name: string;
  110763. shader: string;
  110764. };
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110769. */
  110770. export class BloomMergePostProcess extends PostProcess {
  110771. /** Weight of the bloom to be added to the original input. */
  110772. weight: number;
  110773. /**
  110774. * Creates a new instance of @see BloomMergePostProcess
  110775. * @param name The name of the effect.
  110776. * @param originalFromInput Post process which's input will be used for the merge.
  110777. * @param blurred Blurred highlights post process which's output will be used.
  110778. * @param weight Weight of the bloom to be added to the original input.
  110779. * @param options The required width/height ratio to downsize to before computing the render pass.
  110780. * @param camera The camera to apply the render pass to.
  110781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110782. * @param engine The engine which the post process will be applied. (default: current engine)
  110783. * @param reusable If the post process can be reused on the same frame. (default: false)
  110784. * @param textureType Type of textures used when performing the post process. (default: 0)
  110785. * @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)
  110786. */
  110787. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  110788. /** Weight of the bloom to be added to the original input. */
  110789. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110790. }
  110791. }
  110792. declare module BABYLON {
  110793. /**
  110794. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  110795. */
  110796. export class BloomEffect extends PostProcessRenderEffect {
  110797. private bloomScale;
  110798. /**
  110799. * @hidden Internal
  110800. */
  110801. _effects: Array<PostProcess>;
  110802. /**
  110803. * @hidden Internal
  110804. */
  110805. _downscale: ExtractHighlightsPostProcess;
  110806. private _blurX;
  110807. private _blurY;
  110808. private _merge;
  110809. /**
  110810. * The luminance threshold to find bright areas of the image to bloom.
  110811. */
  110812. threshold: number;
  110813. /**
  110814. * The strength of the bloom.
  110815. */
  110816. weight: number;
  110817. /**
  110818. * Specifies the size of the bloom blur kernel, relative to the final output size
  110819. */
  110820. kernel: number;
  110821. /**
  110822. * Creates a new instance of @see BloomEffect
  110823. * @param scene The scene the effect belongs to.
  110824. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  110825. * @param bloomKernel The size of the kernel to be used when applying the blur.
  110826. * @param bloomWeight The the strength of bloom.
  110827. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110828. * @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)
  110829. */
  110830. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  110831. /**
  110832. * Disposes each of the internal effects for a given camera.
  110833. * @param camera The camera to dispose the effect on.
  110834. */
  110835. disposeEffects(camera: Camera): void;
  110836. /**
  110837. * @hidden Internal
  110838. */
  110839. _updateEffects(): void;
  110840. /**
  110841. * Internal
  110842. * @returns if all the contained post processes are ready.
  110843. * @hidden
  110844. */
  110845. _isReady(): boolean;
  110846. }
  110847. }
  110848. declare module BABYLON {
  110849. /** @hidden */
  110850. export var chromaticAberrationPixelShader: {
  110851. name: string;
  110852. shader: string;
  110853. };
  110854. }
  110855. declare module BABYLON {
  110856. /**
  110857. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  110858. */
  110859. export class ChromaticAberrationPostProcess extends PostProcess {
  110860. /**
  110861. * The amount of seperation of rgb channels (default: 30)
  110862. */
  110863. aberrationAmount: number;
  110864. /**
  110865. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  110866. */
  110867. radialIntensity: number;
  110868. /**
  110869. * 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))
  110870. */
  110871. direction: Vector2;
  110872. /**
  110873. * 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))
  110874. */
  110875. centerPosition: Vector2;
  110876. /**
  110877. * Creates a new instance ChromaticAberrationPostProcess
  110878. * @param name The name of the effect.
  110879. * @param screenWidth The width of the screen to apply the effect on.
  110880. * @param screenHeight The height of the screen to apply the effect on.
  110881. * @param options The required width/height ratio to downsize to before computing the render pass.
  110882. * @param camera The camera to apply the render pass to.
  110883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110884. * @param engine The engine which the post process will be applied. (default: current engine)
  110885. * @param reusable If the post process can be reused on the same frame. (default: false)
  110886. * @param textureType Type of textures used when performing the post process. (default: 0)
  110887. * @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)
  110888. */
  110889. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110890. }
  110891. }
  110892. declare module BABYLON {
  110893. /** @hidden */
  110894. export var circleOfConfusionPixelShader: {
  110895. name: string;
  110896. shader: string;
  110897. };
  110898. }
  110899. declare module BABYLON {
  110900. /**
  110901. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  110902. */
  110903. export class CircleOfConfusionPostProcess extends PostProcess {
  110904. /**
  110905. * 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.
  110906. */
  110907. lensSize: number;
  110908. /**
  110909. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110910. */
  110911. fStop: number;
  110912. /**
  110913. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110914. */
  110915. focusDistance: number;
  110916. /**
  110917. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  110918. */
  110919. focalLength: number;
  110920. private _depthTexture;
  110921. /**
  110922. * Creates a new instance CircleOfConfusionPostProcess
  110923. * @param name The name of the effect.
  110924. * @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.
  110925. * @param options The required width/height ratio to downsize to before computing the render pass.
  110926. * @param camera The camera to apply the render pass to.
  110927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110928. * @param engine The engine which the post process will be applied. (default: current engine)
  110929. * @param reusable If the post process can be reused on the same frame. (default: false)
  110930. * @param textureType Type of textures used when performing the post process. (default: 0)
  110931. * @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)
  110932. */
  110933. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110934. /**
  110935. * 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.
  110936. */
  110937. depthTexture: RenderTargetTexture;
  110938. }
  110939. }
  110940. declare module BABYLON {
  110941. /** @hidden */
  110942. export var colorCorrectionPixelShader: {
  110943. name: string;
  110944. shader: string;
  110945. };
  110946. }
  110947. declare module BABYLON {
  110948. /**
  110949. *
  110950. * This post-process allows the modification of rendered colors by using
  110951. * a 'look-up table' (LUT). This effect is also called Color Grading.
  110952. *
  110953. * The object needs to be provided an url to a texture containing the color
  110954. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  110955. * Use an image editing software to tweak the LUT to match your needs.
  110956. *
  110957. * For an example of a color LUT, see here:
  110958. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  110959. * For explanations on color grading, see here:
  110960. * @see http://udn.epicgames.com/Three/ColorGrading.html
  110961. *
  110962. */
  110963. export class ColorCorrectionPostProcess extends PostProcess {
  110964. private _colorTableTexture;
  110965. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110966. }
  110967. }
  110968. declare module BABYLON {
  110969. /** @hidden */
  110970. export var convolutionPixelShader: {
  110971. name: string;
  110972. shader: string;
  110973. };
  110974. }
  110975. declare module BABYLON {
  110976. /**
  110977. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  110978. * input texture to perform effects such as edge detection or sharpening
  110979. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110980. */
  110981. export class ConvolutionPostProcess extends PostProcess {
  110982. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110983. kernel: number[];
  110984. /**
  110985. * Creates a new instance ConvolutionPostProcess
  110986. * @param name The name of the effect.
  110987. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  110988. * @param options The required width/height ratio to downsize to before computing the render pass.
  110989. * @param camera The camera to apply the render pass to.
  110990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110991. * @param engine The engine which the post process will be applied. (default: current engine)
  110992. * @param reusable If the post process can be reused on the same frame. (default: false)
  110993. * @param textureType Type of textures used when performing the post process. (default: 0)
  110994. */
  110995. constructor(name: string,
  110996. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  110997. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110998. /**
  110999. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111000. */
  111001. static EdgeDetect0Kernel: number[];
  111002. /**
  111003. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111004. */
  111005. static EdgeDetect1Kernel: number[];
  111006. /**
  111007. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111008. */
  111009. static EdgeDetect2Kernel: number[];
  111010. /**
  111011. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111012. */
  111013. static SharpenKernel: number[];
  111014. /**
  111015. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111016. */
  111017. static EmbossKernel: number[];
  111018. /**
  111019. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111020. */
  111021. static GaussianKernel: number[];
  111022. }
  111023. }
  111024. declare module BABYLON {
  111025. /**
  111026. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111027. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111028. * based on samples that have a large difference in distance than the center pixel.
  111029. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111030. */
  111031. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111032. direction: Vector2;
  111033. /**
  111034. * Creates a new instance CircleOfConfusionPostProcess
  111035. * @param name The name of the effect.
  111036. * @param scene The scene the effect belongs to.
  111037. * @param direction The direction the blur should be applied.
  111038. * @param kernel The size of the kernel used to blur.
  111039. * @param options The required width/height ratio to downsize to before computing the render pass.
  111040. * @param camera The camera to apply the render pass to.
  111041. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111042. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111044. * @param engine The engine which the post process will be applied. (default: current engine)
  111045. * @param reusable If the post process can be reused on the same frame. (default: false)
  111046. * @param textureType Type of textures used when performing the post process. (default: 0)
  111047. * @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)
  111048. */
  111049. 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);
  111050. }
  111051. }
  111052. declare module BABYLON {
  111053. /** @hidden */
  111054. export var depthOfFieldMergePixelShader: {
  111055. name: string;
  111056. shader: string;
  111057. };
  111058. }
  111059. declare module BABYLON {
  111060. /**
  111061. * Options to be set when merging outputs from the default pipeline.
  111062. */
  111063. export class DepthOfFieldMergePostProcessOptions {
  111064. /**
  111065. * The original image to merge on top of
  111066. */
  111067. originalFromInput: PostProcess;
  111068. /**
  111069. * Parameters to perform the merge of the depth of field effect
  111070. */
  111071. depthOfField?: {
  111072. circleOfConfusion: PostProcess;
  111073. blurSteps: Array<PostProcess>;
  111074. };
  111075. /**
  111076. * Parameters to perform the merge of bloom effect
  111077. */
  111078. bloom?: {
  111079. blurred: PostProcess;
  111080. weight: number;
  111081. };
  111082. }
  111083. /**
  111084. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111085. */
  111086. export class DepthOfFieldMergePostProcess extends PostProcess {
  111087. private blurSteps;
  111088. /**
  111089. * Creates a new instance of DepthOfFieldMergePostProcess
  111090. * @param name The name of the effect.
  111091. * @param originalFromInput Post process which's input will be used for the merge.
  111092. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111093. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111094. * @param options The required width/height ratio to downsize to before computing the render pass.
  111095. * @param camera The camera to apply the render pass to.
  111096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111097. * @param engine The engine which the post process will be applied. (default: current engine)
  111098. * @param reusable If the post process can be reused on the same frame. (default: false)
  111099. * @param textureType Type of textures used when performing the post process. (default: 0)
  111100. * @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)
  111101. */
  111102. 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);
  111103. /**
  111104. * Updates the effect with the current post process compile time values and recompiles the shader.
  111105. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111106. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111107. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111108. * @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
  111109. * @param onCompiled Called when the shader has been compiled.
  111110. * @param onError Called if there is an error when compiling a shader.
  111111. */
  111112. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111113. }
  111114. }
  111115. declare module BABYLON {
  111116. /**
  111117. * Specifies the level of max blur that should be applied when using the depth of field effect
  111118. */
  111119. export enum DepthOfFieldEffectBlurLevel {
  111120. /**
  111121. * Subtle blur
  111122. */
  111123. Low = 0,
  111124. /**
  111125. * Medium blur
  111126. */
  111127. Medium = 1,
  111128. /**
  111129. * Large blur
  111130. */
  111131. High = 2
  111132. }
  111133. /**
  111134. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111135. */
  111136. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111137. private _circleOfConfusion;
  111138. /**
  111139. * @hidden Internal, blurs from high to low
  111140. */
  111141. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111142. private _depthOfFieldBlurY;
  111143. private _dofMerge;
  111144. /**
  111145. * @hidden Internal post processes in depth of field effect
  111146. */
  111147. _effects: Array<PostProcess>;
  111148. /**
  111149. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111150. */
  111151. focalLength: number;
  111152. /**
  111153. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111154. */
  111155. fStop: number;
  111156. /**
  111157. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111158. */
  111159. focusDistance: number;
  111160. /**
  111161. * 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.
  111162. */
  111163. lensSize: number;
  111164. /**
  111165. * Creates a new instance DepthOfFieldEffect
  111166. * @param scene The scene the effect belongs to.
  111167. * @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.
  111168. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111169. * @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)
  111170. */
  111171. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111172. /**
  111173. * 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.
  111174. */
  111175. depthTexture: RenderTargetTexture;
  111176. /**
  111177. * Disposes each of the internal effects for a given camera.
  111178. * @param camera The camera to dispose the effect on.
  111179. */
  111180. disposeEffects(camera: Camera): void;
  111181. /**
  111182. * @hidden Internal
  111183. */
  111184. _updateEffects(): void;
  111185. /**
  111186. * Internal
  111187. * @returns if all the contained post processes are ready.
  111188. * @hidden
  111189. */
  111190. _isReady(): boolean;
  111191. }
  111192. }
  111193. declare module BABYLON {
  111194. /** @hidden */
  111195. export var displayPassPixelShader: {
  111196. name: string;
  111197. shader: string;
  111198. };
  111199. }
  111200. declare module BABYLON {
  111201. /**
  111202. * DisplayPassPostProcess which produces an output the same as it's input
  111203. */
  111204. export class DisplayPassPostProcess extends PostProcess {
  111205. /**
  111206. * Creates the DisplayPassPostProcess
  111207. * @param name The name of the effect.
  111208. * @param options The required width/height ratio to downsize to before computing the render pass.
  111209. * @param camera The camera to apply the render pass to.
  111210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111211. * @param engine The engine which the post process will be applied. (default: current engine)
  111212. * @param reusable If the post process can be reused on the same frame. (default: false)
  111213. */
  111214. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111215. }
  111216. }
  111217. declare module BABYLON {
  111218. /** @hidden */
  111219. export var filterPixelShader: {
  111220. name: string;
  111221. shader: string;
  111222. };
  111223. }
  111224. declare module BABYLON {
  111225. /**
  111226. * Applies a kernel filter to the image
  111227. */
  111228. export class FilterPostProcess extends PostProcess {
  111229. /** The matrix to be applied to the image */
  111230. kernelMatrix: Matrix;
  111231. /**
  111232. *
  111233. * @param name The name of the effect.
  111234. * @param kernelMatrix The matrix to be applied to the image
  111235. * @param options The required width/height ratio to downsize to before computing the render pass.
  111236. * @param camera The camera to apply the render pass to.
  111237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111238. * @param engine The engine which the post process will be applied. (default: current engine)
  111239. * @param reusable If the post process can be reused on the same frame. (default: false)
  111240. */
  111241. constructor(name: string,
  111242. /** The matrix to be applied to the image */
  111243. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111244. }
  111245. }
  111246. declare module BABYLON {
  111247. /** @hidden */
  111248. export var fxaaPixelShader: {
  111249. name: string;
  111250. shader: string;
  111251. };
  111252. }
  111253. declare module BABYLON {
  111254. /** @hidden */
  111255. export var fxaaVertexShader: {
  111256. name: string;
  111257. shader: string;
  111258. };
  111259. }
  111260. declare module BABYLON {
  111261. /**
  111262. * Fxaa post process
  111263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111264. */
  111265. export class FxaaPostProcess extends PostProcess {
  111266. /** @hidden */
  111267. texelWidth: number;
  111268. /** @hidden */
  111269. texelHeight: number;
  111270. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111271. private _getDefines;
  111272. }
  111273. }
  111274. declare module BABYLON {
  111275. /** @hidden */
  111276. export var grainPixelShader: {
  111277. name: string;
  111278. shader: string;
  111279. };
  111280. }
  111281. declare module BABYLON {
  111282. /**
  111283. * The GrainPostProcess adds noise to the image at mid luminance levels
  111284. */
  111285. export class GrainPostProcess extends PostProcess {
  111286. /**
  111287. * The intensity of the grain added (default: 30)
  111288. */
  111289. intensity: number;
  111290. /**
  111291. * If the grain should be randomized on every frame
  111292. */
  111293. animated: boolean;
  111294. /**
  111295. * Creates a new instance of @see GrainPostProcess
  111296. * @param name The name of the effect.
  111297. * @param options The required width/height ratio to downsize to before computing the render pass.
  111298. * @param camera The camera to apply the render pass to.
  111299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111300. * @param engine The engine which the post process will be applied. (default: current engine)
  111301. * @param reusable If the post process can be reused on the same frame. (default: false)
  111302. * @param textureType Type of textures used when performing the post process. (default: 0)
  111303. * @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)
  111304. */
  111305. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111306. }
  111307. }
  111308. declare module BABYLON {
  111309. /** @hidden */
  111310. export var highlightsPixelShader: {
  111311. name: string;
  111312. shader: string;
  111313. };
  111314. }
  111315. declare module BABYLON {
  111316. /**
  111317. * Extracts highlights from the image
  111318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111319. */
  111320. export class HighlightsPostProcess extends PostProcess {
  111321. /**
  111322. * Extracts highlights from the image
  111323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111324. * @param name The name of the effect.
  111325. * @param options The required width/height ratio to downsize to before computing the render pass.
  111326. * @param camera The camera to apply the render pass to.
  111327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111328. * @param engine The engine which the post process will be applied. (default: current engine)
  111329. * @param reusable If the post process can be reused on the same frame. (default: false)
  111330. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111331. */
  111332. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111333. }
  111334. }
  111335. declare module BABYLON {
  111336. /** @hidden */
  111337. export var mrtFragmentDeclaration: {
  111338. name: string;
  111339. shader: string;
  111340. };
  111341. }
  111342. declare module BABYLON {
  111343. /** @hidden */
  111344. export var geometryPixelShader: {
  111345. name: string;
  111346. shader: string;
  111347. };
  111348. }
  111349. declare module BABYLON {
  111350. /** @hidden */
  111351. export var geometryVertexShader: {
  111352. name: string;
  111353. shader: string;
  111354. };
  111355. }
  111356. declare module BABYLON {
  111357. /**
  111358. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111359. */
  111360. export class GeometryBufferRenderer {
  111361. /**
  111362. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111363. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111364. */
  111365. static readonly POSITION_TEXTURE_TYPE: number;
  111366. /**
  111367. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111368. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111369. */
  111370. static readonly VELOCITY_TEXTURE_TYPE: number;
  111371. /**
  111372. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111373. * in order to compute objects velocities when enableVelocity is set to "true"
  111374. * @hidden
  111375. */
  111376. _previousTransformationMatrices: {
  111377. [index: number]: Matrix;
  111378. };
  111379. private _scene;
  111380. private _multiRenderTarget;
  111381. private _ratio;
  111382. private _enablePosition;
  111383. private _enableVelocity;
  111384. private _positionIndex;
  111385. private _velocityIndex;
  111386. protected _effect: Effect;
  111387. protected _cachedDefines: string;
  111388. /**
  111389. * Set the render list (meshes to be rendered) used in the G buffer.
  111390. */
  111391. renderList: Mesh[];
  111392. /**
  111393. * Gets wether or not G buffer are supported by the running hardware.
  111394. * This requires draw buffer supports
  111395. */
  111396. readonly isSupported: boolean;
  111397. /**
  111398. * Returns the index of the given texture type in the G-Buffer textures array
  111399. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111400. * @returns the index of the given texture type in the G-Buffer textures array
  111401. */
  111402. getTextureIndex(textureType: number): number;
  111403. /**
  111404. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111405. */
  111406. /**
  111407. * Sets whether or not objects positions are enabled for the G buffer.
  111408. */
  111409. enablePosition: boolean;
  111410. /**
  111411. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111412. */
  111413. /**
  111414. * Sets wether or not objects velocities are enabled for the G buffer.
  111415. */
  111416. enableVelocity: boolean;
  111417. /**
  111418. * Gets the scene associated with the buffer.
  111419. */
  111420. readonly scene: Scene;
  111421. /**
  111422. * Gets the ratio used by the buffer during its creation.
  111423. * How big is the buffer related to the main canvas.
  111424. */
  111425. readonly ratio: number;
  111426. /** @hidden */
  111427. static _SceneComponentInitialization: (scene: Scene) => void;
  111428. /**
  111429. * Creates a new G Buffer for the scene
  111430. * @param scene The scene the buffer belongs to
  111431. * @param ratio How big is the buffer related to the main canvas.
  111432. */
  111433. constructor(scene: Scene, ratio?: number);
  111434. /**
  111435. * Checks wether everything is ready to render a submesh to the G buffer.
  111436. * @param subMesh the submesh to check readiness for
  111437. * @param useInstances is the mesh drawn using instance or not
  111438. * @returns true if ready otherwise false
  111439. */
  111440. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111441. /**
  111442. * Gets the current underlying G Buffer.
  111443. * @returns the buffer
  111444. */
  111445. getGBuffer(): MultiRenderTarget;
  111446. /**
  111447. * Gets the number of samples used to render the buffer (anti aliasing).
  111448. */
  111449. /**
  111450. * Sets the number of samples used to render the buffer (anti aliasing).
  111451. */
  111452. samples: number;
  111453. /**
  111454. * Disposes the renderer and frees up associated resources.
  111455. */
  111456. dispose(): void;
  111457. protected _createRenderTargets(): void;
  111458. }
  111459. }
  111460. declare module BABYLON {
  111461. interface Scene {
  111462. /** @hidden (Backing field) */
  111463. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111464. /**
  111465. * Gets or Sets the current geometry buffer associated to the scene.
  111466. */
  111467. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111468. /**
  111469. * Enables a GeometryBufferRender and associates it with the scene
  111470. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  111471. * @returns the GeometryBufferRenderer
  111472. */
  111473. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  111474. /**
  111475. * Disables the GeometryBufferRender associated with the scene
  111476. */
  111477. disableGeometryBufferRenderer(): void;
  111478. }
  111479. /**
  111480. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  111481. * in several rendering techniques.
  111482. */
  111483. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  111484. /**
  111485. * The component name helpful to identify the component in the list of scene components.
  111486. */
  111487. readonly name: string;
  111488. /**
  111489. * The scene the component belongs to.
  111490. */
  111491. scene: Scene;
  111492. /**
  111493. * Creates a new instance of the component for the given scene
  111494. * @param scene Defines the scene to register the component in
  111495. */
  111496. constructor(scene: Scene);
  111497. /**
  111498. * Registers the component in a given scene
  111499. */
  111500. register(): void;
  111501. /**
  111502. * Rebuilds the elements related to this component in case of
  111503. * context lost for instance.
  111504. */
  111505. rebuild(): void;
  111506. /**
  111507. * Disposes the component and the associated ressources
  111508. */
  111509. dispose(): void;
  111510. private _gatherRenderTargets;
  111511. }
  111512. }
  111513. declare module BABYLON {
  111514. /** @hidden */
  111515. export var motionBlurPixelShader: {
  111516. name: string;
  111517. shader: string;
  111518. };
  111519. }
  111520. declare module BABYLON {
  111521. /**
  111522. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  111523. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  111524. * As an example, all you have to do is to create the post-process:
  111525. * var mb = new BABYLON.MotionBlurPostProcess(
  111526. * 'mb', // The name of the effect.
  111527. * scene, // The scene containing the objects to blur according to their velocity.
  111528. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  111529. * camera // The camera to apply the render pass to.
  111530. * );
  111531. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  111532. */
  111533. export class MotionBlurPostProcess extends PostProcess {
  111534. /**
  111535. * Defines how much the image is blurred by the movement. Default value is equal to 1
  111536. */
  111537. motionStrength: number;
  111538. /**
  111539. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  111540. */
  111541. /**
  111542. * Sets the number of iterations to be used for motion blur quality
  111543. */
  111544. motionBlurSamples: number;
  111545. private _motionBlurSamples;
  111546. private _geometryBufferRenderer;
  111547. /**
  111548. * Creates a new instance MotionBlurPostProcess
  111549. * @param name The name of the effect.
  111550. * @param scene The scene containing the objects to blur according to their velocity.
  111551. * @param options The required width/height ratio to downsize to before computing the render pass.
  111552. * @param camera The camera to apply the render pass to.
  111553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111554. * @param engine The engine which the post process will be applied. (default: current engine)
  111555. * @param reusable If the post process can be reused on the same frame. (default: false)
  111556. * @param textureType Type of textures used when performing the post process. (default: 0)
  111557. * @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)
  111558. */
  111559. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111560. /**
  111561. * Disposes the post process.
  111562. * @param camera The camera to dispose the post process on.
  111563. */
  111564. dispose(camera?: Camera): void;
  111565. }
  111566. }
  111567. declare module BABYLON {
  111568. /** @hidden */
  111569. export var refractionPixelShader: {
  111570. name: string;
  111571. shader: string;
  111572. };
  111573. }
  111574. declare module BABYLON {
  111575. /**
  111576. * Post process which applies a refractin texture
  111577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  111578. */
  111579. export class RefractionPostProcess extends PostProcess {
  111580. /** the base color of the refraction (used to taint the rendering) */
  111581. color: Color3;
  111582. /** simulated refraction depth */
  111583. depth: number;
  111584. /** the coefficient of the base color (0 to remove base color tainting) */
  111585. colorLevel: number;
  111586. private _refTexture;
  111587. private _ownRefractionTexture;
  111588. /**
  111589. * Gets or sets the refraction texture
  111590. * Please note that you are responsible for disposing the texture if you set it manually
  111591. */
  111592. refractionTexture: Texture;
  111593. /**
  111594. * Initializes the RefractionPostProcess
  111595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  111596. * @param name The name of the effect.
  111597. * @param refractionTextureUrl Url of the refraction texture to use
  111598. * @param color the base color of the refraction (used to taint the rendering)
  111599. * @param depth simulated refraction depth
  111600. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  111601. * @param camera The camera to apply the render pass to.
  111602. * @param options The required width/height ratio to downsize to before computing the render pass.
  111603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111604. * @param engine The engine which the post process will be applied. (default: current engine)
  111605. * @param reusable If the post process can be reused on the same frame. (default: false)
  111606. */
  111607. constructor(name: string, refractionTextureUrl: string,
  111608. /** the base color of the refraction (used to taint the rendering) */
  111609. color: Color3,
  111610. /** simulated refraction depth */
  111611. depth: number,
  111612. /** the coefficient of the base color (0 to remove base color tainting) */
  111613. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111614. /**
  111615. * Disposes of the post process
  111616. * @param camera Camera to dispose post process on
  111617. */
  111618. dispose(camera: Camera): void;
  111619. }
  111620. }
  111621. declare module BABYLON {
  111622. /** @hidden */
  111623. export var sharpenPixelShader: {
  111624. name: string;
  111625. shader: string;
  111626. };
  111627. }
  111628. declare module BABYLON {
  111629. /**
  111630. * The SharpenPostProcess applies a sharpen kernel to every pixel
  111631. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111632. */
  111633. export class SharpenPostProcess extends PostProcess {
  111634. /**
  111635. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  111636. */
  111637. colorAmount: number;
  111638. /**
  111639. * How much sharpness should be applied (default: 0.3)
  111640. */
  111641. edgeAmount: number;
  111642. /**
  111643. * Creates a new instance ConvolutionPostProcess
  111644. * @param name The name of the effect.
  111645. * @param options The required width/height ratio to downsize to before computing the render pass.
  111646. * @param camera The camera to apply the render pass to.
  111647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111648. * @param engine The engine which the post process will be applied. (default: current engine)
  111649. * @param reusable If the post process can be reused on the same frame. (default: false)
  111650. * @param textureType Type of textures used when performing the post process. (default: 0)
  111651. * @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)
  111652. */
  111653. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111654. }
  111655. }
  111656. declare module BABYLON {
  111657. /**
  111658. * PostProcessRenderPipeline
  111659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111660. */
  111661. export class PostProcessRenderPipeline {
  111662. private engine;
  111663. private _renderEffects;
  111664. private _renderEffectsForIsolatedPass;
  111665. /**
  111666. * List of inspectable custom properties (used by the Inspector)
  111667. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111668. */
  111669. inspectableCustomProperties: IInspectable[];
  111670. /**
  111671. * @hidden
  111672. */
  111673. protected _cameras: Camera[];
  111674. /** @hidden */
  111675. _name: string;
  111676. /**
  111677. * Gets pipeline name
  111678. */
  111679. readonly name: string;
  111680. /**
  111681. * Initializes a PostProcessRenderPipeline
  111682. * @param engine engine to add the pipeline to
  111683. * @param name name of the pipeline
  111684. */
  111685. constructor(engine: Engine, name: string);
  111686. /**
  111687. * Gets the class name
  111688. * @returns "PostProcessRenderPipeline"
  111689. */
  111690. getClassName(): string;
  111691. /**
  111692. * If all the render effects in the pipeline are supported
  111693. */
  111694. readonly isSupported: boolean;
  111695. /**
  111696. * Adds an effect to the pipeline
  111697. * @param renderEffect the effect to add
  111698. */
  111699. addEffect(renderEffect: PostProcessRenderEffect): void;
  111700. /** @hidden */
  111701. _rebuild(): void;
  111702. /** @hidden */
  111703. _enableEffect(renderEffectName: string, cameras: Camera): void;
  111704. /** @hidden */
  111705. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  111706. /** @hidden */
  111707. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  111708. /** @hidden */
  111709. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  111710. /** @hidden */
  111711. _attachCameras(cameras: Camera, unique: boolean): void;
  111712. /** @hidden */
  111713. _attachCameras(cameras: Camera[], unique: boolean): void;
  111714. /** @hidden */
  111715. _detachCameras(cameras: Camera): void;
  111716. /** @hidden */
  111717. _detachCameras(cameras: Nullable<Camera[]>): void;
  111718. /** @hidden */
  111719. _update(): void;
  111720. /** @hidden */
  111721. _reset(): void;
  111722. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  111723. /**
  111724. * Disposes of the pipeline
  111725. */
  111726. dispose(): void;
  111727. }
  111728. }
  111729. declare module BABYLON {
  111730. /**
  111731. * PostProcessRenderPipelineManager class
  111732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111733. */
  111734. export class PostProcessRenderPipelineManager {
  111735. private _renderPipelines;
  111736. /**
  111737. * Initializes a PostProcessRenderPipelineManager
  111738. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111739. */
  111740. constructor();
  111741. /**
  111742. * Gets the list of supported render pipelines
  111743. */
  111744. readonly supportedPipelines: PostProcessRenderPipeline[];
  111745. /**
  111746. * Adds a pipeline to the manager
  111747. * @param renderPipeline The pipeline to add
  111748. */
  111749. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  111750. /**
  111751. * Attaches a camera to the pipeline
  111752. * @param renderPipelineName The name of the pipeline to attach to
  111753. * @param cameras the camera to attach
  111754. * @param unique if the camera can be attached multiple times to the pipeline
  111755. */
  111756. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  111757. /**
  111758. * Detaches a camera from the pipeline
  111759. * @param renderPipelineName The name of the pipeline to detach from
  111760. * @param cameras the camera to detach
  111761. */
  111762. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  111763. /**
  111764. * Enables an effect by name on a pipeline
  111765. * @param renderPipelineName the name of the pipeline to enable the effect in
  111766. * @param renderEffectName the name of the effect to enable
  111767. * @param cameras the cameras that the effect should be enabled on
  111768. */
  111769. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  111770. /**
  111771. * Disables an effect by name on a pipeline
  111772. * @param renderPipelineName the name of the pipeline to disable the effect in
  111773. * @param renderEffectName the name of the effect to disable
  111774. * @param cameras the cameras that the effect should be disabled on
  111775. */
  111776. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  111777. /**
  111778. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  111779. */
  111780. update(): void;
  111781. /** @hidden */
  111782. _rebuild(): void;
  111783. /**
  111784. * Disposes of the manager and pipelines
  111785. */
  111786. dispose(): void;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. interface Scene {
  111791. /** @hidden (Backing field) */
  111792. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111793. /**
  111794. * Gets the postprocess render pipeline manager
  111795. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111796. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111797. */
  111798. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  111799. }
  111800. /**
  111801. * Defines the Render Pipeline scene component responsible to rendering pipelines
  111802. */
  111803. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  111804. /**
  111805. * The component name helpfull to identify the component in the list of scene components.
  111806. */
  111807. readonly name: string;
  111808. /**
  111809. * The scene the component belongs to.
  111810. */
  111811. scene: Scene;
  111812. /**
  111813. * Creates a new instance of the component for the given scene
  111814. * @param scene Defines the scene to register the component in
  111815. */
  111816. constructor(scene: Scene);
  111817. /**
  111818. * Registers the component in a given scene
  111819. */
  111820. register(): void;
  111821. /**
  111822. * Rebuilds the elements related to this component in case of
  111823. * context lost for instance.
  111824. */
  111825. rebuild(): void;
  111826. /**
  111827. * Disposes the component and the associated ressources
  111828. */
  111829. dispose(): void;
  111830. private _gatherRenderTargets;
  111831. }
  111832. }
  111833. declare module BABYLON {
  111834. /**
  111835. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  111836. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  111837. */
  111838. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111839. private _scene;
  111840. private _camerasToBeAttached;
  111841. /**
  111842. * ID of the sharpen post process,
  111843. */
  111844. private readonly SharpenPostProcessId;
  111845. /**
  111846. * @ignore
  111847. * ID of the image processing post process;
  111848. */
  111849. readonly ImageProcessingPostProcessId: string;
  111850. /**
  111851. * @ignore
  111852. * ID of the Fast Approximate Anti-Aliasing post process;
  111853. */
  111854. readonly FxaaPostProcessId: string;
  111855. /**
  111856. * ID of the chromatic aberration post process,
  111857. */
  111858. private readonly ChromaticAberrationPostProcessId;
  111859. /**
  111860. * ID of the grain post process
  111861. */
  111862. private readonly GrainPostProcessId;
  111863. /**
  111864. * Sharpen post process which will apply a sharpen convolution to enhance edges
  111865. */
  111866. sharpen: SharpenPostProcess;
  111867. private _sharpenEffect;
  111868. private bloom;
  111869. /**
  111870. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  111871. */
  111872. depthOfField: DepthOfFieldEffect;
  111873. /**
  111874. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111875. */
  111876. fxaa: FxaaPostProcess;
  111877. /**
  111878. * Image post processing pass used to perform operations such as tone mapping or color grading.
  111879. */
  111880. imageProcessing: ImageProcessingPostProcess;
  111881. /**
  111882. * Chromatic aberration post process which will shift rgb colors in the image
  111883. */
  111884. chromaticAberration: ChromaticAberrationPostProcess;
  111885. private _chromaticAberrationEffect;
  111886. /**
  111887. * Grain post process which add noise to the image
  111888. */
  111889. grain: GrainPostProcess;
  111890. private _grainEffect;
  111891. /**
  111892. * Glow post process which adds a glow to emissive areas of the image
  111893. */
  111894. private _glowLayer;
  111895. /**
  111896. * Animations which can be used to tweak settings over a period of time
  111897. */
  111898. animations: Animation[];
  111899. private _imageProcessingConfigurationObserver;
  111900. private _sharpenEnabled;
  111901. private _bloomEnabled;
  111902. private _depthOfFieldEnabled;
  111903. private _depthOfFieldBlurLevel;
  111904. private _fxaaEnabled;
  111905. private _imageProcessingEnabled;
  111906. private _defaultPipelineTextureType;
  111907. private _bloomScale;
  111908. private _chromaticAberrationEnabled;
  111909. private _grainEnabled;
  111910. private _buildAllowed;
  111911. /**
  111912. * Gets active scene
  111913. */
  111914. readonly scene: Scene;
  111915. /**
  111916. * Enable or disable the sharpen process from the pipeline
  111917. */
  111918. sharpenEnabled: boolean;
  111919. private _resizeObserver;
  111920. private _hardwareScaleLevel;
  111921. private _bloomKernel;
  111922. /**
  111923. * Specifies the size of the bloom blur kernel, relative to the final output size
  111924. */
  111925. bloomKernel: number;
  111926. /**
  111927. * Specifies the weight of the bloom in the final rendering
  111928. */
  111929. private _bloomWeight;
  111930. /**
  111931. * Specifies the luma threshold for the area that will be blurred by the bloom
  111932. */
  111933. private _bloomThreshold;
  111934. private _hdr;
  111935. /**
  111936. * The strength of the bloom.
  111937. */
  111938. bloomWeight: number;
  111939. /**
  111940. * The strength of the bloom.
  111941. */
  111942. bloomThreshold: number;
  111943. /**
  111944. * The scale of the bloom, lower value will provide better performance.
  111945. */
  111946. bloomScale: number;
  111947. /**
  111948. * Enable or disable the bloom from the pipeline
  111949. */
  111950. bloomEnabled: boolean;
  111951. private _rebuildBloom;
  111952. /**
  111953. * If the depth of field is enabled.
  111954. */
  111955. depthOfFieldEnabled: boolean;
  111956. /**
  111957. * Blur level of the depth of field effect. (Higher blur will effect performance)
  111958. */
  111959. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  111960. /**
  111961. * If the anti aliasing is enabled.
  111962. */
  111963. fxaaEnabled: boolean;
  111964. private _samples;
  111965. /**
  111966. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111967. */
  111968. samples: number;
  111969. /**
  111970. * If image processing is enabled.
  111971. */
  111972. imageProcessingEnabled: boolean;
  111973. /**
  111974. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  111975. */
  111976. glowLayerEnabled: boolean;
  111977. /**
  111978. * Enable or disable the chromaticAberration process from the pipeline
  111979. */
  111980. chromaticAberrationEnabled: boolean;
  111981. /**
  111982. * Enable or disable the grain process from the pipeline
  111983. */
  111984. grainEnabled: boolean;
  111985. /**
  111986. * @constructor
  111987. * @param name - The rendering pipeline name (default: "")
  111988. * @param hdr - If high dynamic range textures should be used (default: true)
  111989. * @param scene - The scene linked to this pipeline (default: the last created scene)
  111990. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  111991. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  111992. */
  111993. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  111994. /**
  111995. * Get the class name
  111996. * @returns "DefaultRenderingPipeline"
  111997. */
  111998. getClassName(): string;
  111999. /**
  112000. * Force the compilation of the entire pipeline.
  112001. */
  112002. prepare(): void;
  112003. private _hasCleared;
  112004. private _prevPostProcess;
  112005. private _prevPrevPostProcess;
  112006. private _setAutoClearAndTextureSharing;
  112007. private _depthOfFieldSceneObserver;
  112008. private _buildPipeline;
  112009. private _disposePostProcesses;
  112010. /**
  112011. * Adds a camera to the pipeline
  112012. * @param camera the camera to be added
  112013. */
  112014. addCamera(camera: Camera): void;
  112015. /**
  112016. * Removes a camera from the pipeline
  112017. * @param camera the camera to remove
  112018. */
  112019. removeCamera(camera: Camera): void;
  112020. /**
  112021. * Dispose of the pipeline and stop all post processes
  112022. */
  112023. dispose(): void;
  112024. /**
  112025. * Serialize the rendering pipeline (Used when exporting)
  112026. * @returns the serialized object
  112027. */
  112028. serialize(): any;
  112029. /**
  112030. * Parse the serialized pipeline
  112031. * @param source Source pipeline.
  112032. * @param scene The scene to load the pipeline to.
  112033. * @param rootUrl The URL of the serialized pipeline.
  112034. * @returns An instantiated pipeline from the serialized object.
  112035. */
  112036. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112037. }
  112038. }
  112039. declare module BABYLON {
  112040. /** @hidden */
  112041. export var lensHighlightsPixelShader: {
  112042. name: string;
  112043. shader: string;
  112044. };
  112045. }
  112046. declare module BABYLON {
  112047. /** @hidden */
  112048. export var depthOfFieldPixelShader: {
  112049. name: string;
  112050. shader: string;
  112051. };
  112052. }
  112053. declare module BABYLON {
  112054. /**
  112055. * BABYLON.JS Chromatic Aberration GLSL Shader
  112056. * Author: Olivier Guyot
  112057. * Separates very slightly R, G and B colors on the edges of the screen
  112058. * Inspired by Francois Tarlier & Martins Upitis
  112059. */
  112060. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112061. /**
  112062. * @ignore
  112063. * The chromatic aberration PostProcess id in the pipeline
  112064. */
  112065. LensChromaticAberrationEffect: string;
  112066. /**
  112067. * @ignore
  112068. * The highlights enhancing PostProcess id in the pipeline
  112069. */
  112070. HighlightsEnhancingEffect: string;
  112071. /**
  112072. * @ignore
  112073. * The depth-of-field PostProcess id in the pipeline
  112074. */
  112075. LensDepthOfFieldEffect: string;
  112076. private _scene;
  112077. private _depthTexture;
  112078. private _grainTexture;
  112079. private _chromaticAberrationPostProcess;
  112080. private _highlightsPostProcess;
  112081. private _depthOfFieldPostProcess;
  112082. private _edgeBlur;
  112083. private _grainAmount;
  112084. private _chromaticAberration;
  112085. private _distortion;
  112086. private _highlightsGain;
  112087. private _highlightsThreshold;
  112088. private _dofDistance;
  112089. private _dofAperture;
  112090. private _dofDarken;
  112091. private _dofPentagon;
  112092. private _blurNoise;
  112093. /**
  112094. * @constructor
  112095. *
  112096. * Effect parameters are as follow:
  112097. * {
  112098. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112099. * edge_blur: number; // from 0 to x (1 for realism)
  112100. * distortion: number; // from 0 to x (1 for realism)
  112101. * grain_amount: number; // from 0 to 1
  112102. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112103. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112104. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112105. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112106. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112107. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112108. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112109. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112110. * }
  112111. * Note: if an effect parameter is unset, effect is disabled
  112112. *
  112113. * @param name The rendering pipeline name
  112114. * @param parameters - An object containing all parameters (see above)
  112115. * @param scene The scene linked to this pipeline
  112116. * @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)
  112117. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112118. */
  112119. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112120. /**
  112121. * Get the class name
  112122. * @returns "LensRenderingPipeline"
  112123. */
  112124. getClassName(): string;
  112125. /**
  112126. * Gets associated scene
  112127. */
  112128. readonly scene: Scene;
  112129. /**
  112130. * Gets or sets the edge blur
  112131. */
  112132. edgeBlur: number;
  112133. /**
  112134. * Gets or sets the grain amount
  112135. */
  112136. grainAmount: number;
  112137. /**
  112138. * Gets or sets the chromatic aberration amount
  112139. */
  112140. chromaticAberration: number;
  112141. /**
  112142. * Gets or sets the depth of field aperture
  112143. */
  112144. dofAperture: number;
  112145. /**
  112146. * Gets or sets the edge distortion
  112147. */
  112148. edgeDistortion: number;
  112149. /**
  112150. * Gets or sets the depth of field distortion
  112151. */
  112152. dofDistortion: number;
  112153. /**
  112154. * Gets or sets the darken out of focus amount
  112155. */
  112156. darkenOutOfFocus: number;
  112157. /**
  112158. * Gets or sets a boolean indicating if blur noise is enabled
  112159. */
  112160. blurNoise: boolean;
  112161. /**
  112162. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112163. */
  112164. pentagonBokeh: boolean;
  112165. /**
  112166. * Gets or sets the highlight grain amount
  112167. */
  112168. highlightsGain: number;
  112169. /**
  112170. * Gets or sets the highlight threshold
  112171. */
  112172. highlightsThreshold: number;
  112173. /**
  112174. * Sets the amount of blur at the edges
  112175. * @param amount blur amount
  112176. */
  112177. setEdgeBlur(amount: number): void;
  112178. /**
  112179. * Sets edge blur to 0
  112180. */
  112181. disableEdgeBlur(): void;
  112182. /**
  112183. * Sets the amout of grain
  112184. * @param amount Amount of grain
  112185. */
  112186. setGrainAmount(amount: number): void;
  112187. /**
  112188. * Set grain amount to 0
  112189. */
  112190. disableGrain(): void;
  112191. /**
  112192. * Sets the chromatic aberration amount
  112193. * @param amount amount of chromatic aberration
  112194. */
  112195. setChromaticAberration(amount: number): void;
  112196. /**
  112197. * Sets chromatic aberration amount to 0
  112198. */
  112199. disableChromaticAberration(): void;
  112200. /**
  112201. * Sets the EdgeDistortion amount
  112202. * @param amount amount of EdgeDistortion
  112203. */
  112204. setEdgeDistortion(amount: number): void;
  112205. /**
  112206. * Sets edge distortion to 0
  112207. */
  112208. disableEdgeDistortion(): void;
  112209. /**
  112210. * Sets the FocusDistance amount
  112211. * @param amount amount of FocusDistance
  112212. */
  112213. setFocusDistance(amount: number): void;
  112214. /**
  112215. * Disables depth of field
  112216. */
  112217. disableDepthOfField(): void;
  112218. /**
  112219. * Sets the Aperture amount
  112220. * @param amount amount of Aperture
  112221. */
  112222. setAperture(amount: number): void;
  112223. /**
  112224. * Sets the DarkenOutOfFocus amount
  112225. * @param amount amount of DarkenOutOfFocus
  112226. */
  112227. setDarkenOutOfFocus(amount: number): void;
  112228. private _pentagonBokehIsEnabled;
  112229. /**
  112230. * Creates a pentagon bokeh effect
  112231. */
  112232. enablePentagonBokeh(): void;
  112233. /**
  112234. * Disables the pentagon bokeh effect
  112235. */
  112236. disablePentagonBokeh(): void;
  112237. /**
  112238. * Enables noise blur
  112239. */
  112240. enableNoiseBlur(): void;
  112241. /**
  112242. * Disables noise blur
  112243. */
  112244. disableNoiseBlur(): void;
  112245. /**
  112246. * Sets the HighlightsGain amount
  112247. * @param amount amount of HighlightsGain
  112248. */
  112249. setHighlightsGain(amount: number): void;
  112250. /**
  112251. * Sets the HighlightsThreshold amount
  112252. * @param amount amount of HighlightsThreshold
  112253. */
  112254. setHighlightsThreshold(amount: number): void;
  112255. /**
  112256. * Disables highlights
  112257. */
  112258. disableHighlights(): void;
  112259. /**
  112260. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112261. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112262. */
  112263. dispose(disableDepthRender?: boolean): void;
  112264. private _createChromaticAberrationPostProcess;
  112265. private _createHighlightsPostProcess;
  112266. private _createDepthOfFieldPostProcess;
  112267. private _createGrainTexture;
  112268. }
  112269. }
  112270. declare module BABYLON {
  112271. /** @hidden */
  112272. export var ssao2PixelShader: {
  112273. name: string;
  112274. shader: string;
  112275. };
  112276. }
  112277. declare module BABYLON {
  112278. /** @hidden */
  112279. export var ssaoCombinePixelShader: {
  112280. name: string;
  112281. shader: string;
  112282. };
  112283. }
  112284. declare module BABYLON {
  112285. /**
  112286. * Render pipeline to produce ssao effect
  112287. */
  112288. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112289. /**
  112290. * @ignore
  112291. * The PassPostProcess id in the pipeline that contains the original scene color
  112292. */
  112293. SSAOOriginalSceneColorEffect: string;
  112294. /**
  112295. * @ignore
  112296. * The SSAO PostProcess id in the pipeline
  112297. */
  112298. SSAORenderEffect: string;
  112299. /**
  112300. * @ignore
  112301. * The horizontal blur PostProcess id in the pipeline
  112302. */
  112303. SSAOBlurHRenderEffect: string;
  112304. /**
  112305. * @ignore
  112306. * The vertical blur PostProcess id in the pipeline
  112307. */
  112308. SSAOBlurVRenderEffect: string;
  112309. /**
  112310. * @ignore
  112311. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112312. */
  112313. SSAOCombineRenderEffect: string;
  112314. /**
  112315. * The output strength of the SSAO post-process. Default value is 1.0.
  112316. */
  112317. totalStrength: number;
  112318. /**
  112319. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112320. */
  112321. maxZ: number;
  112322. /**
  112323. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112324. */
  112325. minZAspect: number;
  112326. private _samples;
  112327. /**
  112328. * Number of samples used for the SSAO calculations. Default value is 8
  112329. */
  112330. samples: number;
  112331. private _textureSamples;
  112332. /**
  112333. * Number of samples to use for antialiasing
  112334. */
  112335. textureSamples: number;
  112336. /**
  112337. * Ratio object used for SSAO ratio and blur ratio
  112338. */
  112339. private _ratio;
  112340. /**
  112341. * Dynamically generated sphere sampler.
  112342. */
  112343. private _sampleSphere;
  112344. /**
  112345. * Blur filter offsets
  112346. */
  112347. private _samplerOffsets;
  112348. private _expensiveBlur;
  112349. /**
  112350. * If bilateral blur should be used
  112351. */
  112352. expensiveBlur: boolean;
  112353. /**
  112354. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112355. */
  112356. radius: number;
  112357. /**
  112358. * The base color of the SSAO post-process
  112359. * The final result is "base + ssao" between [0, 1]
  112360. */
  112361. base: number;
  112362. /**
  112363. * Support test.
  112364. */
  112365. static readonly IsSupported: boolean;
  112366. private _scene;
  112367. private _depthTexture;
  112368. private _normalTexture;
  112369. private _randomTexture;
  112370. private _originalColorPostProcess;
  112371. private _ssaoPostProcess;
  112372. private _blurHPostProcess;
  112373. private _blurVPostProcess;
  112374. private _ssaoCombinePostProcess;
  112375. private _firstUpdate;
  112376. /**
  112377. * Gets active scene
  112378. */
  112379. readonly scene: Scene;
  112380. /**
  112381. * @constructor
  112382. * @param name The rendering pipeline name
  112383. * @param scene The scene linked to this pipeline
  112384. * @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 }
  112385. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112386. */
  112387. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112388. /**
  112389. * Get the class name
  112390. * @returns "SSAO2RenderingPipeline"
  112391. */
  112392. getClassName(): string;
  112393. /**
  112394. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112395. */
  112396. dispose(disableGeometryBufferRenderer?: boolean): void;
  112397. private _createBlurPostProcess;
  112398. /** @hidden */
  112399. _rebuild(): void;
  112400. private _bits;
  112401. private _radicalInverse_VdC;
  112402. private _hammersley;
  112403. private _hemisphereSample_uniform;
  112404. private _generateHemisphere;
  112405. private _createSSAOPostProcess;
  112406. private _createSSAOCombinePostProcess;
  112407. private _createRandomTexture;
  112408. /**
  112409. * Serialize the rendering pipeline (Used when exporting)
  112410. * @returns the serialized object
  112411. */
  112412. serialize(): any;
  112413. /**
  112414. * Parse the serialized pipeline
  112415. * @param source Source pipeline.
  112416. * @param scene The scene to load the pipeline to.
  112417. * @param rootUrl The URL of the serialized pipeline.
  112418. * @returns An instantiated pipeline from the serialized object.
  112419. */
  112420. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112421. }
  112422. }
  112423. declare module BABYLON {
  112424. /** @hidden */
  112425. export var ssaoPixelShader: {
  112426. name: string;
  112427. shader: string;
  112428. };
  112429. }
  112430. declare module BABYLON {
  112431. /**
  112432. * Render pipeline to produce ssao effect
  112433. */
  112434. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  112435. /**
  112436. * @ignore
  112437. * The PassPostProcess id in the pipeline that contains the original scene color
  112438. */
  112439. SSAOOriginalSceneColorEffect: string;
  112440. /**
  112441. * @ignore
  112442. * The SSAO PostProcess id in the pipeline
  112443. */
  112444. SSAORenderEffect: string;
  112445. /**
  112446. * @ignore
  112447. * The horizontal blur PostProcess id in the pipeline
  112448. */
  112449. SSAOBlurHRenderEffect: string;
  112450. /**
  112451. * @ignore
  112452. * The vertical blur PostProcess id in the pipeline
  112453. */
  112454. SSAOBlurVRenderEffect: string;
  112455. /**
  112456. * @ignore
  112457. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112458. */
  112459. SSAOCombineRenderEffect: string;
  112460. /**
  112461. * The output strength of the SSAO post-process. Default value is 1.0.
  112462. */
  112463. totalStrength: number;
  112464. /**
  112465. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  112466. */
  112467. radius: number;
  112468. /**
  112469. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  112470. * Must not be equal to fallOff and superior to fallOff.
  112471. * Default value is 0.0075
  112472. */
  112473. area: number;
  112474. /**
  112475. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  112476. * Must not be equal to area and inferior to area.
  112477. * Default value is 0.000001
  112478. */
  112479. fallOff: number;
  112480. /**
  112481. * The base color of the SSAO post-process
  112482. * The final result is "base + ssao" between [0, 1]
  112483. */
  112484. base: number;
  112485. private _scene;
  112486. private _depthTexture;
  112487. private _randomTexture;
  112488. private _originalColorPostProcess;
  112489. private _ssaoPostProcess;
  112490. private _blurHPostProcess;
  112491. private _blurVPostProcess;
  112492. private _ssaoCombinePostProcess;
  112493. private _firstUpdate;
  112494. /**
  112495. * Gets active scene
  112496. */
  112497. readonly scene: Scene;
  112498. /**
  112499. * @constructor
  112500. * @param name - The rendering pipeline name
  112501. * @param scene - The scene linked to this pipeline
  112502. * @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 }
  112503. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  112504. */
  112505. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112506. /**
  112507. * Get the class name
  112508. * @returns "SSAORenderingPipeline"
  112509. */
  112510. getClassName(): string;
  112511. /**
  112512. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112513. */
  112514. dispose(disableDepthRender?: boolean): void;
  112515. private _createBlurPostProcess;
  112516. /** @hidden */
  112517. _rebuild(): void;
  112518. private _createSSAOPostProcess;
  112519. private _createSSAOCombinePostProcess;
  112520. private _createRandomTexture;
  112521. }
  112522. }
  112523. declare module BABYLON {
  112524. /** @hidden */
  112525. export var standardPixelShader: {
  112526. name: string;
  112527. shader: string;
  112528. };
  112529. }
  112530. declare module BABYLON {
  112531. /**
  112532. * Standard rendering pipeline
  112533. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112534. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  112535. */
  112536. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112537. /**
  112538. * Public members
  112539. */
  112540. /**
  112541. * Post-process which contains the original scene color before the pipeline applies all the effects
  112542. */
  112543. originalPostProcess: Nullable<PostProcess>;
  112544. /**
  112545. * Post-process used to down scale an image x4
  112546. */
  112547. downSampleX4PostProcess: Nullable<PostProcess>;
  112548. /**
  112549. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  112550. */
  112551. brightPassPostProcess: Nullable<PostProcess>;
  112552. /**
  112553. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  112554. */
  112555. blurHPostProcesses: PostProcess[];
  112556. /**
  112557. * Post-process array storing all the vertical blur post-processes used by the pipeline
  112558. */
  112559. blurVPostProcesses: PostProcess[];
  112560. /**
  112561. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  112562. */
  112563. textureAdderPostProcess: Nullable<PostProcess>;
  112564. /**
  112565. * Post-process used to create volumetric lighting effect
  112566. */
  112567. volumetricLightPostProcess: Nullable<PostProcess>;
  112568. /**
  112569. * Post-process used to smooth the previous volumetric light post-process on the X axis
  112570. */
  112571. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  112572. /**
  112573. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  112574. */
  112575. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  112576. /**
  112577. * Post-process used to merge the volumetric light effect and the real scene color
  112578. */
  112579. volumetricLightMergePostProces: Nullable<PostProcess>;
  112580. /**
  112581. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  112582. */
  112583. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  112584. /**
  112585. * Base post-process used to calculate the average luminance of the final image for HDR
  112586. */
  112587. luminancePostProcess: Nullable<PostProcess>;
  112588. /**
  112589. * Post-processes used to create down sample post-processes in order to get
  112590. * the average luminance of the final image for HDR
  112591. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  112592. */
  112593. luminanceDownSamplePostProcesses: PostProcess[];
  112594. /**
  112595. * Post-process used to create a HDR effect (light adaptation)
  112596. */
  112597. hdrPostProcess: Nullable<PostProcess>;
  112598. /**
  112599. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  112600. */
  112601. textureAdderFinalPostProcess: Nullable<PostProcess>;
  112602. /**
  112603. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  112604. */
  112605. lensFlareFinalPostProcess: Nullable<PostProcess>;
  112606. /**
  112607. * Post-process used to merge the final HDR post-process and the real scene color
  112608. */
  112609. hdrFinalPostProcess: Nullable<PostProcess>;
  112610. /**
  112611. * Post-process used to create a lens flare effect
  112612. */
  112613. lensFlarePostProcess: Nullable<PostProcess>;
  112614. /**
  112615. * Post-process that merges the result of the lens flare post-process and the real scene color
  112616. */
  112617. lensFlareComposePostProcess: Nullable<PostProcess>;
  112618. /**
  112619. * Post-process used to create a motion blur effect
  112620. */
  112621. motionBlurPostProcess: Nullable<PostProcess>;
  112622. /**
  112623. * Post-process used to create a depth of field effect
  112624. */
  112625. depthOfFieldPostProcess: Nullable<PostProcess>;
  112626. /**
  112627. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112628. */
  112629. fxaaPostProcess: Nullable<FxaaPostProcess>;
  112630. /**
  112631. * Represents the brightness threshold in order to configure the illuminated surfaces
  112632. */
  112633. brightThreshold: number;
  112634. /**
  112635. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  112636. */
  112637. blurWidth: number;
  112638. /**
  112639. * Sets if the blur for highlighted surfaces must be only horizontal
  112640. */
  112641. horizontalBlur: boolean;
  112642. /**
  112643. * Gets the overall exposure used by the pipeline
  112644. */
  112645. /**
  112646. * Sets the overall exposure used by the pipeline
  112647. */
  112648. exposure: number;
  112649. /**
  112650. * Texture used typically to simulate "dirty" on camera lens
  112651. */
  112652. lensTexture: Nullable<Texture>;
  112653. /**
  112654. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  112655. */
  112656. volumetricLightCoefficient: number;
  112657. /**
  112658. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  112659. */
  112660. volumetricLightPower: number;
  112661. /**
  112662. * Used the set the blur intensity to smooth the volumetric lights
  112663. */
  112664. volumetricLightBlurScale: number;
  112665. /**
  112666. * Light (spot or directional) used to generate the volumetric lights rays
  112667. * The source light must have a shadow generate so the pipeline can get its
  112668. * depth map
  112669. */
  112670. sourceLight: Nullable<SpotLight | DirectionalLight>;
  112671. /**
  112672. * For eye adaptation, represents the minimum luminance the eye can see
  112673. */
  112674. hdrMinimumLuminance: number;
  112675. /**
  112676. * For eye adaptation, represents the decrease luminance speed
  112677. */
  112678. hdrDecreaseRate: number;
  112679. /**
  112680. * For eye adaptation, represents the increase luminance speed
  112681. */
  112682. hdrIncreaseRate: number;
  112683. /**
  112684. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  112685. */
  112686. /**
  112687. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  112688. */
  112689. hdrAutoExposure: boolean;
  112690. /**
  112691. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  112692. */
  112693. lensColorTexture: Nullable<Texture>;
  112694. /**
  112695. * The overall strengh for the lens flare effect
  112696. */
  112697. lensFlareStrength: number;
  112698. /**
  112699. * Dispersion coefficient for lens flare ghosts
  112700. */
  112701. lensFlareGhostDispersal: number;
  112702. /**
  112703. * Main lens flare halo width
  112704. */
  112705. lensFlareHaloWidth: number;
  112706. /**
  112707. * Based on the lens distortion effect, defines how much the lens flare result
  112708. * is distorted
  112709. */
  112710. lensFlareDistortionStrength: number;
  112711. /**
  112712. * Lens star texture must be used to simulate rays on the flares and is available
  112713. * in the documentation
  112714. */
  112715. lensStarTexture: Nullable<Texture>;
  112716. /**
  112717. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  112718. * flare effect by taking account of the dirt texture
  112719. */
  112720. lensFlareDirtTexture: Nullable<Texture>;
  112721. /**
  112722. * Represents the focal length for the depth of field effect
  112723. */
  112724. depthOfFieldDistance: number;
  112725. /**
  112726. * Represents the blur intensity for the blurred part of the depth of field effect
  112727. */
  112728. depthOfFieldBlurWidth: number;
  112729. /**
  112730. * For motion blur, defines how much the image is blurred by the movement
  112731. */
  112732. motionStrength: number;
  112733. /**
  112734. * List of animations for the pipeline (IAnimatable implementation)
  112735. */
  112736. animations: Animation[];
  112737. /**
  112738. * Private members
  112739. */
  112740. private _scene;
  112741. private _currentDepthOfFieldSource;
  112742. private _basePostProcess;
  112743. private _fixedExposure;
  112744. private _currentExposure;
  112745. private _hdrAutoExposure;
  112746. private _hdrCurrentLuminance;
  112747. private _floatTextureType;
  112748. private _ratio;
  112749. private _bloomEnabled;
  112750. private _depthOfFieldEnabled;
  112751. private _vlsEnabled;
  112752. private _lensFlareEnabled;
  112753. private _hdrEnabled;
  112754. private _motionBlurEnabled;
  112755. private _fxaaEnabled;
  112756. private _motionBlurSamples;
  112757. private _volumetricLightStepsCount;
  112758. private _samples;
  112759. /**
  112760. * @ignore
  112761. * Specifies if the bloom pipeline is enabled
  112762. */
  112763. BloomEnabled: boolean;
  112764. /**
  112765. * @ignore
  112766. * Specifies if the depth of field pipeline is enabed
  112767. */
  112768. DepthOfFieldEnabled: boolean;
  112769. /**
  112770. * @ignore
  112771. * Specifies if the lens flare pipeline is enabed
  112772. */
  112773. LensFlareEnabled: boolean;
  112774. /**
  112775. * @ignore
  112776. * Specifies if the HDR pipeline is enabled
  112777. */
  112778. HDREnabled: boolean;
  112779. /**
  112780. * @ignore
  112781. * Specifies if the volumetric lights scattering effect is enabled
  112782. */
  112783. VLSEnabled: boolean;
  112784. /**
  112785. * @ignore
  112786. * Specifies if the motion blur effect is enabled
  112787. */
  112788. MotionBlurEnabled: boolean;
  112789. /**
  112790. * Specifies if anti-aliasing is enabled
  112791. */
  112792. fxaaEnabled: boolean;
  112793. /**
  112794. * Specifies the number of steps used to calculate the volumetric lights
  112795. * Typically in interval [50, 200]
  112796. */
  112797. volumetricLightStepsCount: number;
  112798. /**
  112799. * Specifies the number of samples used for the motion blur effect
  112800. * Typically in interval [16, 64]
  112801. */
  112802. motionBlurSamples: number;
  112803. /**
  112804. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112805. */
  112806. samples: number;
  112807. /**
  112808. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  112809. * @constructor
  112810. * @param name The rendering pipeline name
  112811. * @param scene The scene linked to this pipeline
  112812. * @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)
  112813. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  112814. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112815. */
  112816. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  112817. private _buildPipeline;
  112818. private _createDownSampleX4PostProcess;
  112819. private _createBrightPassPostProcess;
  112820. private _createBlurPostProcesses;
  112821. private _createTextureAdderPostProcess;
  112822. private _createVolumetricLightPostProcess;
  112823. private _createLuminancePostProcesses;
  112824. private _createHdrPostProcess;
  112825. private _createLensFlarePostProcess;
  112826. private _createDepthOfFieldPostProcess;
  112827. private _createMotionBlurPostProcess;
  112828. private _getDepthTexture;
  112829. private _disposePostProcesses;
  112830. /**
  112831. * Dispose of the pipeline and stop all post processes
  112832. */
  112833. dispose(): void;
  112834. /**
  112835. * Serialize the rendering pipeline (Used when exporting)
  112836. * @returns the serialized object
  112837. */
  112838. serialize(): any;
  112839. /**
  112840. * Parse the serialized pipeline
  112841. * @param source Source pipeline.
  112842. * @param scene The scene to load the pipeline to.
  112843. * @param rootUrl The URL of the serialized pipeline.
  112844. * @returns An instantiated pipeline from the serialized object.
  112845. */
  112846. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  112847. /**
  112848. * Luminance steps
  112849. */
  112850. static LuminanceSteps: number;
  112851. }
  112852. }
  112853. declare module BABYLON {
  112854. /** @hidden */
  112855. export var tonemapPixelShader: {
  112856. name: string;
  112857. shader: string;
  112858. };
  112859. }
  112860. declare module BABYLON {
  112861. /** Defines operator used for tonemapping */
  112862. export enum TonemappingOperator {
  112863. /** Hable */
  112864. Hable = 0,
  112865. /** Reinhard */
  112866. Reinhard = 1,
  112867. /** HejiDawson */
  112868. HejiDawson = 2,
  112869. /** Photographic */
  112870. Photographic = 3
  112871. }
  112872. /**
  112873. * Defines a post process to apply tone mapping
  112874. */
  112875. export class TonemapPostProcess extends PostProcess {
  112876. private _operator;
  112877. /** Defines the required exposure adjustement */
  112878. exposureAdjustment: number;
  112879. /**
  112880. * Creates a new TonemapPostProcess
  112881. * @param name defines the name of the postprocess
  112882. * @param _operator defines the operator to use
  112883. * @param exposureAdjustment defines the required exposure adjustement
  112884. * @param camera defines the camera to use (can be null)
  112885. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  112886. * @param engine defines the hosting engine (can be ignore if camera is set)
  112887. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112888. */
  112889. constructor(name: string, _operator: TonemappingOperator,
  112890. /** Defines the required exposure adjustement */
  112891. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  112892. }
  112893. }
  112894. declare module BABYLON {
  112895. /** @hidden */
  112896. export var depthVertexShader: {
  112897. name: string;
  112898. shader: string;
  112899. };
  112900. }
  112901. declare module BABYLON {
  112902. /** @hidden */
  112903. export var volumetricLightScatteringPixelShader: {
  112904. name: string;
  112905. shader: string;
  112906. };
  112907. }
  112908. declare module BABYLON {
  112909. /** @hidden */
  112910. export var volumetricLightScatteringPassPixelShader: {
  112911. name: string;
  112912. shader: string;
  112913. };
  112914. }
  112915. declare module BABYLON {
  112916. /**
  112917. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  112918. */
  112919. export class VolumetricLightScatteringPostProcess extends PostProcess {
  112920. private _volumetricLightScatteringPass;
  112921. private _volumetricLightScatteringRTT;
  112922. private _viewPort;
  112923. private _screenCoordinates;
  112924. private _cachedDefines;
  112925. /**
  112926. * If not undefined, the mesh position is computed from the attached node position
  112927. */
  112928. attachedNode: {
  112929. position: Vector3;
  112930. };
  112931. /**
  112932. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  112933. */
  112934. customMeshPosition: Vector3;
  112935. /**
  112936. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  112937. */
  112938. useCustomMeshPosition: boolean;
  112939. /**
  112940. * If the post-process should inverse the light scattering direction
  112941. */
  112942. invert: boolean;
  112943. /**
  112944. * The internal mesh used by the post-process
  112945. */
  112946. mesh: Mesh;
  112947. /**
  112948. * @hidden
  112949. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  112950. */
  112951. useDiffuseColor: boolean;
  112952. /**
  112953. * Array containing the excluded meshes not rendered in the internal pass
  112954. */
  112955. excludedMeshes: AbstractMesh[];
  112956. /**
  112957. * Controls the overall intensity of the post-process
  112958. */
  112959. exposure: number;
  112960. /**
  112961. * Dissipates each sample's contribution in range [0, 1]
  112962. */
  112963. decay: number;
  112964. /**
  112965. * Controls the overall intensity of each sample
  112966. */
  112967. weight: number;
  112968. /**
  112969. * Controls the density of each sample
  112970. */
  112971. density: number;
  112972. /**
  112973. * @constructor
  112974. * @param name The post-process name
  112975. * @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)
  112976. * @param camera The camera that the post-process will be attached to
  112977. * @param mesh The mesh used to create the light scattering
  112978. * @param samples The post-process quality, default 100
  112979. * @param samplingModeThe post-process filtering mode
  112980. * @param engine The babylon engine
  112981. * @param reusable If the post-process is reusable
  112982. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  112983. */
  112984. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  112985. /**
  112986. * Returns the string "VolumetricLightScatteringPostProcess"
  112987. * @returns "VolumetricLightScatteringPostProcess"
  112988. */
  112989. getClassName(): string;
  112990. private _isReady;
  112991. /**
  112992. * Sets the new light position for light scattering effect
  112993. * @param position The new custom light position
  112994. */
  112995. setCustomMeshPosition(position: Vector3): void;
  112996. /**
  112997. * Returns the light position for light scattering effect
  112998. * @return Vector3 The custom light position
  112999. */
  113000. getCustomMeshPosition(): Vector3;
  113001. /**
  113002. * Disposes the internal assets and detaches the post-process from the camera
  113003. */
  113004. dispose(camera: Camera): void;
  113005. /**
  113006. * Returns the render target texture used by the post-process
  113007. * @return the render target texture used by the post-process
  113008. */
  113009. getPass(): RenderTargetTexture;
  113010. private _meshExcluded;
  113011. private _createPass;
  113012. private _updateMeshScreenCoordinates;
  113013. /**
  113014. * Creates a default mesh for the Volumeric Light Scattering post-process
  113015. * @param name The mesh name
  113016. * @param scene The scene where to create the mesh
  113017. * @return the default mesh
  113018. */
  113019. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113020. }
  113021. }
  113022. declare module BABYLON {
  113023. interface Scene {
  113024. /** @hidden (Backing field) */
  113025. _boundingBoxRenderer: BoundingBoxRenderer;
  113026. /** @hidden (Backing field) */
  113027. _forceShowBoundingBoxes: boolean;
  113028. /**
  113029. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113030. */
  113031. forceShowBoundingBoxes: boolean;
  113032. /**
  113033. * Gets the bounding box renderer associated with the scene
  113034. * @returns a BoundingBoxRenderer
  113035. */
  113036. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113037. }
  113038. interface AbstractMesh {
  113039. /** @hidden (Backing field) */
  113040. _showBoundingBox: boolean;
  113041. /**
  113042. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113043. */
  113044. showBoundingBox: boolean;
  113045. }
  113046. /**
  113047. * Component responsible of rendering the bounding box of the meshes in a scene.
  113048. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113049. */
  113050. export class BoundingBoxRenderer implements ISceneComponent {
  113051. /**
  113052. * The component name helpfull to identify the component in the list of scene components.
  113053. */
  113054. readonly name: string;
  113055. /**
  113056. * The scene the component belongs to.
  113057. */
  113058. scene: Scene;
  113059. /**
  113060. * Color of the bounding box lines placed in front of an object
  113061. */
  113062. frontColor: Color3;
  113063. /**
  113064. * Color of the bounding box lines placed behind an object
  113065. */
  113066. backColor: Color3;
  113067. /**
  113068. * Defines if the renderer should show the back lines or not
  113069. */
  113070. showBackLines: boolean;
  113071. /**
  113072. * @hidden
  113073. */
  113074. renderList: SmartArray<BoundingBox>;
  113075. private _colorShader;
  113076. private _vertexBuffers;
  113077. private _indexBuffer;
  113078. /**
  113079. * Instantiates a new bounding box renderer in a scene.
  113080. * @param scene the scene the renderer renders in
  113081. */
  113082. constructor(scene: Scene);
  113083. /**
  113084. * Registers the component in a given scene
  113085. */
  113086. register(): void;
  113087. private _evaluateSubMesh;
  113088. private _activeMesh;
  113089. private _prepareRessources;
  113090. private _createIndexBuffer;
  113091. /**
  113092. * Rebuilds the elements related to this component in case of
  113093. * context lost for instance.
  113094. */
  113095. rebuild(): void;
  113096. /**
  113097. * @hidden
  113098. */
  113099. reset(): void;
  113100. /**
  113101. * Render the bounding boxes of a specific rendering group
  113102. * @param renderingGroupId defines the rendering group to render
  113103. */
  113104. render(renderingGroupId: number): void;
  113105. /**
  113106. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113107. * @param mesh Define the mesh to render the occlusion bounding box for
  113108. */
  113109. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113110. /**
  113111. * Dispose and release the resources attached to this renderer.
  113112. */
  113113. dispose(): void;
  113114. }
  113115. }
  113116. declare module BABYLON {
  113117. /** @hidden */
  113118. export var depthPixelShader: {
  113119. name: string;
  113120. shader: string;
  113121. };
  113122. }
  113123. declare module BABYLON {
  113124. /**
  113125. * This represents a depth renderer in Babylon.
  113126. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113127. */
  113128. export class DepthRenderer {
  113129. private _scene;
  113130. private _depthMap;
  113131. private _effect;
  113132. private _cachedDefines;
  113133. private _camera;
  113134. /**
  113135. * Specifiess that the depth renderer will only be used within
  113136. * the camera it is created for.
  113137. * This can help forcing its rendering during the camera processing.
  113138. */
  113139. useOnlyInActiveCamera: boolean;
  113140. /** @hidden */
  113141. static _SceneComponentInitialization: (scene: Scene) => void;
  113142. /**
  113143. * Instantiates a depth renderer
  113144. * @param scene The scene the renderer belongs to
  113145. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113146. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113147. */
  113148. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113149. /**
  113150. * Creates the depth rendering effect and checks if the effect is ready.
  113151. * @param subMesh The submesh to be used to render the depth map of
  113152. * @param useInstances If multiple world instances should be used
  113153. * @returns if the depth renderer is ready to render the depth map
  113154. */
  113155. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113156. /**
  113157. * Gets the texture which the depth map will be written to.
  113158. * @returns The depth map texture
  113159. */
  113160. getDepthMap(): RenderTargetTexture;
  113161. /**
  113162. * Disposes of the depth renderer.
  113163. */
  113164. dispose(): void;
  113165. }
  113166. }
  113167. declare module BABYLON {
  113168. interface Scene {
  113169. /** @hidden (Backing field) */
  113170. _depthRenderer: {
  113171. [id: string]: DepthRenderer;
  113172. };
  113173. /**
  113174. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113175. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113176. * @returns the created depth renderer
  113177. */
  113178. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113179. /**
  113180. * Disables a depth renderer for a given camera
  113181. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113182. */
  113183. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113184. }
  113185. /**
  113186. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113187. * in several rendering techniques.
  113188. */
  113189. export class DepthRendererSceneComponent implements ISceneComponent {
  113190. /**
  113191. * The component name helpfull to identify the component in the list of scene components.
  113192. */
  113193. readonly name: string;
  113194. /**
  113195. * The scene the component belongs to.
  113196. */
  113197. scene: Scene;
  113198. /**
  113199. * Creates a new instance of the component for the given scene
  113200. * @param scene Defines the scene to register the component in
  113201. */
  113202. constructor(scene: Scene);
  113203. /**
  113204. * Registers the component in a given scene
  113205. */
  113206. register(): void;
  113207. /**
  113208. * Rebuilds the elements related to this component in case of
  113209. * context lost for instance.
  113210. */
  113211. rebuild(): void;
  113212. /**
  113213. * Disposes the component and the associated ressources
  113214. */
  113215. dispose(): void;
  113216. private _gatherRenderTargets;
  113217. private _gatherActiveCameraRenderTargets;
  113218. }
  113219. }
  113220. declare module BABYLON {
  113221. /** @hidden */
  113222. export var outlinePixelShader: {
  113223. name: string;
  113224. shader: string;
  113225. };
  113226. }
  113227. declare module BABYLON {
  113228. /** @hidden */
  113229. export var outlineVertexShader: {
  113230. name: string;
  113231. shader: string;
  113232. };
  113233. }
  113234. declare module BABYLON {
  113235. interface Scene {
  113236. /** @hidden */
  113237. _outlineRenderer: OutlineRenderer;
  113238. /**
  113239. * Gets the outline renderer associated with the scene
  113240. * @returns a OutlineRenderer
  113241. */
  113242. getOutlineRenderer(): OutlineRenderer;
  113243. }
  113244. interface AbstractMesh {
  113245. /** @hidden (Backing field) */
  113246. _renderOutline: boolean;
  113247. /**
  113248. * Gets or sets a boolean indicating if the outline must be rendered as well
  113249. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113250. */
  113251. renderOutline: boolean;
  113252. /** @hidden (Backing field) */
  113253. _renderOverlay: boolean;
  113254. /**
  113255. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113256. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113257. */
  113258. renderOverlay: boolean;
  113259. }
  113260. /**
  113261. * This class is responsible to draw bothe outline/overlay of meshes.
  113262. * It should not be used directly but through the available method on mesh.
  113263. */
  113264. export class OutlineRenderer implements ISceneComponent {
  113265. /**
  113266. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113267. */
  113268. private static _StencilReference;
  113269. /**
  113270. * The name of the component. Each component must have a unique name.
  113271. */
  113272. name: string;
  113273. /**
  113274. * The scene the component belongs to.
  113275. */
  113276. scene: Scene;
  113277. /**
  113278. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113279. */
  113280. zOffset: number;
  113281. private _engine;
  113282. private _effect;
  113283. private _cachedDefines;
  113284. private _savedDepthWrite;
  113285. /**
  113286. * Instantiates a new outline renderer. (There could be only one per scene).
  113287. * @param scene Defines the scene it belongs to
  113288. */
  113289. constructor(scene: Scene);
  113290. /**
  113291. * Register the component to one instance of a scene.
  113292. */
  113293. register(): void;
  113294. /**
  113295. * Rebuilds the elements related to this component in case of
  113296. * context lost for instance.
  113297. */
  113298. rebuild(): void;
  113299. /**
  113300. * Disposes the component and the associated ressources.
  113301. */
  113302. dispose(): void;
  113303. /**
  113304. * Renders the outline in the canvas.
  113305. * @param subMesh Defines the sumesh to render
  113306. * @param batch Defines the batch of meshes in case of instances
  113307. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113308. */
  113309. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113310. /**
  113311. * Returns whether or not the outline renderer is ready for a given submesh.
  113312. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113313. * @param subMesh Defines the submesh to check readyness for
  113314. * @param useInstances Defines wheter wee are trying to render instances or not
  113315. * @returns true if ready otherwise false
  113316. */
  113317. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113318. private _beforeRenderingMesh;
  113319. private _afterRenderingMesh;
  113320. }
  113321. }
  113322. declare module BABYLON {
  113323. /**
  113324. * Defines the list of states available for a task inside a AssetsManager
  113325. */
  113326. export enum AssetTaskState {
  113327. /**
  113328. * Initialization
  113329. */
  113330. INIT = 0,
  113331. /**
  113332. * Running
  113333. */
  113334. RUNNING = 1,
  113335. /**
  113336. * Done
  113337. */
  113338. DONE = 2,
  113339. /**
  113340. * Error
  113341. */
  113342. ERROR = 3
  113343. }
  113344. /**
  113345. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113346. */
  113347. export abstract class AbstractAssetTask {
  113348. /**
  113349. * Task name
  113350. */ name: string;
  113351. /**
  113352. * Callback called when the task is successful
  113353. */
  113354. onSuccess: (task: any) => void;
  113355. /**
  113356. * Callback called when the task is not successful
  113357. */
  113358. onError: (task: any, message?: string, exception?: any) => void;
  113359. /**
  113360. * Creates a new AssetsManager
  113361. * @param name defines the name of the task
  113362. */
  113363. constructor(
  113364. /**
  113365. * Task name
  113366. */ name: string);
  113367. private _isCompleted;
  113368. private _taskState;
  113369. private _errorObject;
  113370. /**
  113371. * Get if the task is completed
  113372. */
  113373. readonly isCompleted: boolean;
  113374. /**
  113375. * Gets the current state of the task
  113376. */
  113377. readonly taskState: AssetTaskState;
  113378. /**
  113379. * Gets the current error object (if task is in error)
  113380. */
  113381. readonly errorObject: {
  113382. message?: string;
  113383. exception?: any;
  113384. };
  113385. /**
  113386. * Internal only
  113387. * @hidden
  113388. */
  113389. _setErrorObject(message?: string, exception?: any): void;
  113390. /**
  113391. * Execute the current task
  113392. * @param scene defines the scene where you want your assets to be loaded
  113393. * @param onSuccess is a callback called when the task is successfully executed
  113394. * @param onError is a callback called if an error occurs
  113395. */
  113396. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113397. /**
  113398. * Execute the current task
  113399. * @param scene defines the scene where you want your assets to be loaded
  113400. * @param onSuccess is a callback called when the task is successfully executed
  113401. * @param onError is a callback called if an error occurs
  113402. */
  113403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113404. /**
  113405. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113406. * This can be used with failed tasks that have the reason for failure fixed.
  113407. */
  113408. reset(): void;
  113409. private onErrorCallback;
  113410. private onDoneCallback;
  113411. }
  113412. /**
  113413. * Define the interface used by progress events raised during assets loading
  113414. */
  113415. export interface IAssetsProgressEvent {
  113416. /**
  113417. * Defines the number of remaining tasks to process
  113418. */
  113419. remainingCount: number;
  113420. /**
  113421. * Defines the total number of tasks
  113422. */
  113423. totalCount: number;
  113424. /**
  113425. * Defines the task that was just processed
  113426. */
  113427. task: AbstractAssetTask;
  113428. }
  113429. /**
  113430. * Class used to share progress information about assets loading
  113431. */
  113432. export class AssetsProgressEvent implements IAssetsProgressEvent {
  113433. /**
  113434. * Defines the number of remaining tasks to process
  113435. */
  113436. remainingCount: number;
  113437. /**
  113438. * Defines the total number of tasks
  113439. */
  113440. totalCount: number;
  113441. /**
  113442. * Defines the task that was just processed
  113443. */
  113444. task: AbstractAssetTask;
  113445. /**
  113446. * Creates a AssetsProgressEvent
  113447. * @param remainingCount defines the number of remaining tasks to process
  113448. * @param totalCount defines the total number of tasks
  113449. * @param task defines the task that was just processed
  113450. */
  113451. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  113452. }
  113453. /**
  113454. * Define a task used by AssetsManager to load meshes
  113455. */
  113456. export class MeshAssetTask extends AbstractAssetTask {
  113457. /**
  113458. * Defines the name of the task
  113459. */
  113460. name: string;
  113461. /**
  113462. * Defines the list of mesh's names you want to load
  113463. */
  113464. meshesNames: any;
  113465. /**
  113466. * Defines the root url to use as a base to load your meshes and associated resources
  113467. */
  113468. rootUrl: string;
  113469. /**
  113470. * Defines the filename of the scene to load from
  113471. */
  113472. sceneFilename: string;
  113473. /**
  113474. * Gets the list of loaded meshes
  113475. */
  113476. loadedMeshes: Array<AbstractMesh>;
  113477. /**
  113478. * Gets the list of loaded particle systems
  113479. */
  113480. loadedParticleSystems: Array<IParticleSystem>;
  113481. /**
  113482. * Gets the list of loaded skeletons
  113483. */
  113484. loadedSkeletons: Array<Skeleton>;
  113485. /**
  113486. * Gets the list of loaded animation groups
  113487. */
  113488. loadedAnimationGroups: Array<AnimationGroup>;
  113489. /**
  113490. * Callback called when the task is successful
  113491. */
  113492. onSuccess: (task: MeshAssetTask) => void;
  113493. /**
  113494. * Callback called when the task is successful
  113495. */
  113496. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  113497. /**
  113498. * Creates a new MeshAssetTask
  113499. * @param name defines the name of the task
  113500. * @param meshesNames defines the list of mesh's names you want to load
  113501. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  113502. * @param sceneFilename defines the filename of the scene to load from
  113503. */
  113504. constructor(
  113505. /**
  113506. * Defines the name of the task
  113507. */
  113508. name: string,
  113509. /**
  113510. * Defines the list of mesh's names you want to load
  113511. */
  113512. meshesNames: any,
  113513. /**
  113514. * Defines the root url to use as a base to load your meshes and associated resources
  113515. */
  113516. rootUrl: string,
  113517. /**
  113518. * Defines the filename of the scene to load from
  113519. */
  113520. sceneFilename: string);
  113521. /**
  113522. * Execute the current task
  113523. * @param scene defines the scene where you want your assets to be loaded
  113524. * @param onSuccess is a callback called when the task is successfully executed
  113525. * @param onError is a callback called if an error occurs
  113526. */
  113527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113528. }
  113529. /**
  113530. * Define a task used by AssetsManager to load text content
  113531. */
  113532. export class TextFileAssetTask extends AbstractAssetTask {
  113533. /**
  113534. * Defines the name of the task
  113535. */
  113536. name: string;
  113537. /**
  113538. * Defines the location of the file to load
  113539. */
  113540. url: string;
  113541. /**
  113542. * Gets the loaded text string
  113543. */
  113544. text: string;
  113545. /**
  113546. * Callback called when the task is successful
  113547. */
  113548. onSuccess: (task: TextFileAssetTask) => void;
  113549. /**
  113550. * Callback called when the task is successful
  113551. */
  113552. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  113553. /**
  113554. * Creates a new TextFileAssetTask object
  113555. * @param name defines the name of the task
  113556. * @param url defines the location of the file to load
  113557. */
  113558. constructor(
  113559. /**
  113560. * Defines the name of the task
  113561. */
  113562. name: string,
  113563. /**
  113564. * Defines the location of the file to load
  113565. */
  113566. url: string);
  113567. /**
  113568. * Execute the current task
  113569. * @param scene defines the scene where you want your assets to be loaded
  113570. * @param onSuccess is a callback called when the task is successfully executed
  113571. * @param onError is a callback called if an error occurs
  113572. */
  113573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113574. }
  113575. /**
  113576. * Define a task used by AssetsManager to load binary data
  113577. */
  113578. export class BinaryFileAssetTask extends AbstractAssetTask {
  113579. /**
  113580. * Defines the name of the task
  113581. */
  113582. name: string;
  113583. /**
  113584. * Defines the location of the file to load
  113585. */
  113586. url: string;
  113587. /**
  113588. * Gets the lodaded data (as an array buffer)
  113589. */
  113590. data: ArrayBuffer;
  113591. /**
  113592. * Callback called when the task is successful
  113593. */
  113594. onSuccess: (task: BinaryFileAssetTask) => void;
  113595. /**
  113596. * Callback called when the task is successful
  113597. */
  113598. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  113599. /**
  113600. * Creates a new BinaryFileAssetTask object
  113601. * @param name defines the name of the new task
  113602. * @param url defines the location of the file to load
  113603. */
  113604. constructor(
  113605. /**
  113606. * Defines the name of the task
  113607. */
  113608. name: string,
  113609. /**
  113610. * Defines the location of the file to load
  113611. */
  113612. url: string);
  113613. /**
  113614. * Execute the current task
  113615. * @param scene defines the scene where you want your assets to be loaded
  113616. * @param onSuccess is a callback called when the task is successfully executed
  113617. * @param onError is a callback called if an error occurs
  113618. */
  113619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113620. }
  113621. /**
  113622. * Define a task used by AssetsManager to load images
  113623. */
  113624. export class ImageAssetTask extends AbstractAssetTask {
  113625. /**
  113626. * Defines the name of the task
  113627. */
  113628. name: string;
  113629. /**
  113630. * Defines the location of the image to load
  113631. */
  113632. url: string;
  113633. /**
  113634. * Gets the loaded images
  113635. */
  113636. image: HTMLImageElement;
  113637. /**
  113638. * Callback called when the task is successful
  113639. */
  113640. onSuccess: (task: ImageAssetTask) => void;
  113641. /**
  113642. * Callback called when the task is successful
  113643. */
  113644. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  113645. /**
  113646. * Creates a new ImageAssetTask
  113647. * @param name defines the name of the task
  113648. * @param url defines the location of the image to load
  113649. */
  113650. constructor(
  113651. /**
  113652. * Defines the name of the task
  113653. */
  113654. name: string,
  113655. /**
  113656. * Defines the location of the image to load
  113657. */
  113658. url: string);
  113659. /**
  113660. * Execute the current task
  113661. * @param scene defines the scene where you want your assets to be loaded
  113662. * @param onSuccess is a callback called when the task is successfully executed
  113663. * @param onError is a callback called if an error occurs
  113664. */
  113665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113666. }
  113667. /**
  113668. * Defines the interface used by texture loading tasks
  113669. */
  113670. export interface ITextureAssetTask<TEX extends BaseTexture> {
  113671. /**
  113672. * Gets the loaded texture
  113673. */
  113674. texture: TEX;
  113675. }
  113676. /**
  113677. * Define a task used by AssetsManager to load 2D textures
  113678. */
  113679. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  113680. /**
  113681. * Defines the name of the task
  113682. */
  113683. name: string;
  113684. /**
  113685. * Defines the location of the file to load
  113686. */
  113687. url: string;
  113688. /**
  113689. * Defines if mipmap should not be generated (default is false)
  113690. */
  113691. noMipmap?: boolean | undefined;
  113692. /**
  113693. * Defines if texture must be inverted on Y axis (default is false)
  113694. */
  113695. invertY?: boolean | undefined;
  113696. /**
  113697. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113698. */
  113699. samplingMode: number;
  113700. /**
  113701. * Gets the loaded texture
  113702. */
  113703. texture: Texture;
  113704. /**
  113705. * Callback called when the task is successful
  113706. */
  113707. onSuccess: (task: TextureAssetTask) => void;
  113708. /**
  113709. * Callback called when the task is successful
  113710. */
  113711. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  113712. /**
  113713. * Creates a new TextureAssetTask object
  113714. * @param name defines the name of the task
  113715. * @param url defines the location of the file to load
  113716. * @param noMipmap defines if mipmap should not be generated (default is false)
  113717. * @param invertY defines if texture must be inverted on Y axis (default is false)
  113718. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113719. */
  113720. constructor(
  113721. /**
  113722. * Defines the name of the task
  113723. */
  113724. name: string,
  113725. /**
  113726. * Defines the location of the file to load
  113727. */
  113728. url: string,
  113729. /**
  113730. * Defines if mipmap should not be generated (default is false)
  113731. */
  113732. noMipmap?: boolean | undefined,
  113733. /**
  113734. * Defines if texture must be inverted on Y axis (default is false)
  113735. */
  113736. invertY?: boolean | undefined,
  113737. /**
  113738. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  113739. */
  113740. samplingMode?: number);
  113741. /**
  113742. * Execute the current task
  113743. * @param scene defines the scene where you want your assets to be loaded
  113744. * @param onSuccess is a callback called when the task is successfully executed
  113745. * @param onError is a callback called if an error occurs
  113746. */
  113747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113748. }
  113749. /**
  113750. * Define a task used by AssetsManager to load cube textures
  113751. */
  113752. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  113753. /**
  113754. * Defines the name of the task
  113755. */
  113756. name: string;
  113757. /**
  113758. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113759. */
  113760. url: string;
  113761. /**
  113762. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113763. */
  113764. extensions?: string[] | undefined;
  113765. /**
  113766. * Defines if mipmaps should not be generated (default is false)
  113767. */
  113768. noMipmap?: boolean | undefined;
  113769. /**
  113770. * Defines the explicit list of files (undefined by default)
  113771. */
  113772. files?: string[] | undefined;
  113773. /**
  113774. * Gets the loaded texture
  113775. */
  113776. texture: CubeTexture;
  113777. /**
  113778. * Callback called when the task is successful
  113779. */
  113780. onSuccess: (task: CubeTextureAssetTask) => void;
  113781. /**
  113782. * Callback called when the task is successful
  113783. */
  113784. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  113785. /**
  113786. * Creates a new CubeTextureAssetTask
  113787. * @param name defines the name of the task
  113788. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113789. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113790. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113791. * @param files defines the explicit list of files (undefined by default)
  113792. */
  113793. constructor(
  113794. /**
  113795. * Defines the name of the task
  113796. */
  113797. name: string,
  113798. /**
  113799. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  113800. */
  113801. url: string,
  113802. /**
  113803. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  113804. */
  113805. extensions?: string[] | undefined,
  113806. /**
  113807. * Defines if mipmaps should not be generated (default is false)
  113808. */
  113809. noMipmap?: boolean | undefined,
  113810. /**
  113811. * Defines the explicit list of files (undefined by default)
  113812. */
  113813. files?: string[] | undefined);
  113814. /**
  113815. * Execute the current task
  113816. * @param scene defines the scene where you want your assets to be loaded
  113817. * @param onSuccess is a callback called when the task is successfully executed
  113818. * @param onError is a callback called if an error occurs
  113819. */
  113820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113821. }
  113822. /**
  113823. * Define a task used by AssetsManager to load HDR cube textures
  113824. */
  113825. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  113826. /**
  113827. * Defines the name of the task
  113828. */
  113829. name: string;
  113830. /**
  113831. * Defines the location of the file to load
  113832. */
  113833. url: string;
  113834. /**
  113835. * Defines the desired size (the more it increases the longer the generation will be)
  113836. */
  113837. size: number;
  113838. /**
  113839. * Defines if mipmaps should not be generated (default is false)
  113840. */
  113841. noMipmap: boolean;
  113842. /**
  113843. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113844. */
  113845. generateHarmonics: boolean;
  113846. /**
  113847. * 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)
  113848. */
  113849. gammaSpace: boolean;
  113850. /**
  113851. * Internal Use Only
  113852. */
  113853. reserved: boolean;
  113854. /**
  113855. * Gets the loaded texture
  113856. */
  113857. texture: HDRCubeTexture;
  113858. /**
  113859. * Callback called when the task is successful
  113860. */
  113861. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  113862. /**
  113863. * Callback called when the task is successful
  113864. */
  113865. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  113866. /**
  113867. * Creates a new HDRCubeTextureAssetTask object
  113868. * @param name defines the name of the task
  113869. * @param url defines the location of the file to load
  113870. * @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.
  113871. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113872. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113873. * @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)
  113874. * @param reserved Internal use only
  113875. */
  113876. constructor(
  113877. /**
  113878. * Defines the name of the task
  113879. */
  113880. name: string,
  113881. /**
  113882. * Defines the location of the file to load
  113883. */
  113884. url: string,
  113885. /**
  113886. * Defines the desired size (the more it increases the longer the generation will be)
  113887. */
  113888. size: number,
  113889. /**
  113890. * Defines if mipmaps should not be generated (default is false)
  113891. */
  113892. noMipmap?: boolean,
  113893. /**
  113894. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  113895. */
  113896. generateHarmonics?: boolean,
  113897. /**
  113898. * 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)
  113899. */
  113900. gammaSpace?: boolean,
  113901. /**
  113902. * Internal Use Only
  113903. */
  113904. reserved?: boolean);
  113905. /**
  113906. * Execute the current task
  113907. * @param scene defines the scene where you want your assets to be loaded
  113908. * @param onSuccess is a callback called when the task is successfully executed
  113909. * @param onError is a callback called if an error occurs
  113910. */
  113911. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113912. }
  113913. /**
  113914. * Define a task used by AssetsManager to load Equirectangular cube textures
  113915. */
  113916. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  113917. /**
  113918. * Defines the name of the task
  113919. */
  113920. name: string;
  113921. /**
  113922. * Defines the location of the file to load
  113923. */
  113924. url: string;
  113925. /**
  113926. * Defines the desired size (the more it increases the longer the generation will be)
  113927. */
  113928. size: number;
  113929. /**
  113930. * Defines if mipmaps should not be generated (default is false)
  113931. */
  113932. noMipmap: boolean;
  113933. /**
  113934. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  113935. * but the standard material would require them in Gamma space) (default is true)
  113936. */
  113937. gammaSpace: boolean;
  113938. /**
  113939. * Gets the loaded texture
  113940. */
  113941. texture: EquiRectangularCubeTexture;
  113942. /**
  113943. * Callback called when the task is successful
  113944. */
  113945. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  113946. /**
  113947. * Callback called when the task is successful
  113948. */
  113949. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  113950. /**
  113951. * Creates a new EquiRectangularCubeTextureAssetTask object
  113952. * @param name defines the name of the task
  113953. * @param url defines the location of the file to load
  113954. * @param size defines the desired size (the more it increases the longer the generation will be)
  113955. * If the size is omitted this implies you are using a preprocessed cubemap.
  113956. * @param noMipmap defines if mipmaps should not be generated (default is false)
  113957. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  113958. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  113959. * (default is true)
  113960. */
  113961. constructor(
  113962. /**
  113963. * Defines the name of the task
  113964. */
  113965. name: string,
  113966. /**
  113967. * Defines the location of the file to load
  113968. */
  113969. url: string,
  113970. /**
  113971. * Defines the desired size (the more it increases the longer the generation will be)
  113972. */
  113973. size: number,
  113974. /**
  113975. * Defines if mipmaps should not be generated (default is false)
  113976. */
  113977. noMipmap?: boolean,
  113978. /**
  113979. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  113980. * but the standard material would require them in Gamma space) (default is true)
  113981. */
  113982. gammaSpace?: boolean);
  113983. /**
  113984. * Execute the current task
  113985. * @param scene defines the scene where you want your assets to be loaded
  113986. * @param onSuccess is a callback called when the task is successfully executed
  113987. * @param onError is a callback called if an error occurs
  113988. */
  113989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113990. }
  113991. /**
  113992. * This class can be used to easily import assets into a scene
  113993. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  113994. */
  113995. export class AssetsManager {
  113996. private _scene;
  113997. private _isLoading;
  113998. protected _tasks: AbstractAssetTask[];
  113999. protected _waitingTasksCount: number;
  114000. protected _totalTasksCount: number;
  114001. /**
  114002. * Callback called when all tasks are processed
  114003. */
  114004. onFinish: (tasks: AbstractAssetTask[]) => void;
  114005. /**
  114006. * Callback called when a task is successful
  114007. */
  114008. onTaskSuccess: (task: AbstractAssetTask) => void;
  114009. /**
  114010. * Callback called when a task had an error
  114011. */
  114012. onTaskError: (task: AbstractAssetTask) => void;
  114013. /**
  114014. * Callback called when a task is done (whatever the result is)
  114015. */
  114016. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114017. /**
  114018. * Observable called when all tasks are processed
  114019. */
  114020. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114021. /**
  114022. * Observable called when a task had an error
  114023. */
  114024. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114025. /**
  114026. * Observable called when all tasks were executed
  114027. */
  114028. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114029. /**
  114030. * Observable called when a task is done (whatever the result is)
  114031. */
  114032. onProgressObservable: Observable<IAssetsProgressEvent>;
  114033. /**
  114034. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114036. */
  114037. useDefaultLoadingScreen: boolean;
  114038. /**
  114039. * Creates a new AssetsManager
  114040. * @param scene defines the scene to work on
  114041. */
  114042. constructor(scene: Scene);
  114043. /**
  114044. * Add a MeshAssetTask to the list of active tasks
  114045. * @param taskName defines the name of the new task
  114046. * @param meshesNames defines the name of meshes to load
  114047. * @param rootUrl defines the root url to use to locate files
  114048. * @param sceneFilename defines the filename of the scene file
  114049. * @returns a new MeshAssetTask object
  114050. */
  114051. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114052. /**
  114053. * Add a TextFileAssetTask to the list of active tasks
  114054. * @param taskName defines the name of the new task
  114055. * @param url defines the url of the file to load
  114056. * @returns a new TextFileAssetTask object
  114057. */
  114058. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114059. /**
  114060. * Add a BinaryFileAssetTask to the list of active tasks
  114061. * @param taskName defines the name of the new task
  114062. * @param url defines the url of the file to load
  114063. * @returns a new BinaryFileAssetTask object
  114064. */
  114065. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114066. /**
  114067. * Add a ImageAssetTask to the list of active tasks
  114068. * @param taskName defines the name of the new task
  114069. * @param url defines the url of the file to load
  114070. * @returns a new ImageAssetTask object
  114071. */
  114072. addImageTask(taskName: string, url: string): ImageAssetTask;
  114073. /**
  114074. * Add a TextureAssetTask to the list of active tasks
  114075. * @param taskName defines the name of the new task
  114076. * @param url defines the url of the file to load
  114077. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114078. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114079. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114080. * @returns a new TextureAssetTask object
  114081. */
  114082. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114083. /**
  114084. * Add a CubeTextureAssetTask to the list of active tasks
  114085. * @param taskName defines the name of the new task
  114086. * @param url defines the url of the file to load
  114087. * @param extensions defines the extension to use to load the cube map (can be null)
  114088. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114089. * @param files defines the list of files to load (can be null)
  114090. * @returns a new CubeTextureAssetTask object
  114091. */
  114092. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114093. /**
  114094. *
  114095. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114096. * @param taskName defines the name of the new task
  114097. * @param url defines the url of the file to load
  114098. * @param size defines the size you want for the cubemap (can be null)
  114099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114100. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114101. * @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)
  114102. * @param reserved Internal use only
  114103. * @returns a new HDRCubeTextureAssetTask object
  114104. */
  114105. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114106. /**
  114107. *
  114108. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114109. * @param taskName defines the name of the new task
  114110. * @param url defines the url of the file to load
  114111. * @param size defines the size you want for the cubemap (can be null)
  114112. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114113. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114114. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114115. * @returns a new EquiRectangularCubeTextureAssetTask object
  114116. */
  114117. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114118. /**
  114119. * Remove a task from the assets manager.
  114120. * @param task the task to remove
  114121. */
  114122. removeTask(task: AbstractAssetTask): void;
  114123. private _decreaseWaitingTasksCount;
  114124. private _runTask;
  114125. /**
  114126. * Reset the AssetsManager and remove all tasks
  114127. * @return the current instance of the AssetsManager
  114128. */
  114129. reset(): AssetsManager;
  114130. /**
  114131. * Start the loading process
  114132. * @return the current instance of the AssetsManager
  114133. */
  114134. load(): AssetsManager;
  114135. /**
  114136. * Start the loading process as an async operation
  114137. * @return a promise returning the list of failed tasks
  114138. */
  114139. loadAsync(): Promise<void>;
  114140. }
  114141. }
  114142. declare module BABYLON {
  114143. /**
  114144. * Wrapper class for promise with external resolve and reject.
  114145. */
  114146. export class Deferred<T> {
  114147. /**
  114148. * The promise associated with this deferred object.
  114149. */
  114150. readonly promise: Promise<T>;
  114151. private _resolve;
  114152. private _reject;
  114153. /**
  114154. * The resolve method of the promise associated with this deferred object.
  114155. */
  114156. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114157. /**
  114158. * The reject method of the promise associated with this deferred object.
  114159. */
  114160. readonly reject: (reason?: any) => void;
  114161. /**
  114162. * Constructor for this deferred object.
  114163. */
  114164. constructor();
  114165. }
  114166. }
  114167. declare module BABYLON {
  114168. /**
  114169. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114170. */
  114171. export class MeshExploder {
  114172. private _centerMesh;
  114173. private _meshes;
  114174. private _meshesOrigins;
  114175. private _toCenterVectors;
  114176. private _scaledDirection;
  114177. private _newPosition;
  114178. private _centerPosition;
  114179. /**
  114180. * Explodes meshes from a center mesh.
  114181. * @param meshes The meshes to explode.
  114182. * @param centerMesh The mesh to be center of explosion.
  114183. */
  114184. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114185. private _setCenterMesh;
  114186. /**
  114187. * Get class name
  114188. * @returns "MeshExploder"
  114189. */
  114190. getClassName(): string;
  114191. /**
  114192. * "Exploded meshes"
  114193. * @returns Array of meshes with the centerMesh at index 0.
  114194. */
  114195. getMeshes(): Array<Mesh>;
  114196. /**
  114197. * Explodes meshes giving a specific direction
  114198. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114199. */
  114200. explode(direction?: number): void;
  114201. }
  114202. }
  114203. declare module BABYLON {
  114204. /**
  114205. * Class used to help managing file picking and drag'n'drop
  114206. */
  114207. export class FilesInput {
  114208. /**
  114209. * List of files ready to be loaded
  114210. */
  114211. static readonly FilesToLoad: {
  114212. [key: string]: File;
  114213. };
  114214. /**
  114215. * Callback called when a file is processed
  114216. */
  114217. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114218. private _engine;
  114219. private _currentScene;
  114220. private _sceneLoadedCallback;
  114221. private _progressCallback;
  114222. private _additionalRenderLoopLogicCallback;
  114223. private _textureLoadingCallback;
  114224. private _startingProcessingFilesCallback;
  114225. private _onReloadCallback;
  114226. private _errorCallback;
  114227. private _elementToMonitor;
  114228. private _sceneFileToLoad;
  114229. private _filesToLoad;
  114230. /**
  114231. * Creates a new FilesInput
  114232. * @param engine defines the rendering engine
  114233. * @param scene defines the hosting scene
  114234. * @param sceneLoadedCallback callback called when scene is loaded
  114235. * @param progressCallback callback called to track progress
  114236. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114237. * @param textureLoadingCallback callback called when a texture is loading
  114238. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114239. * @param onReloadCallback callback called when a reload is requested
  114240. * @param errorCallback callback call if an error occurs
  114241. */
  114242. 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);
  114243. private _dragEnterHandler;
  114244. private _dragOverHandler;
  114245. private _dropHandler;
  114246. /**
  114247. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114248. * @param elementToMonitor defines the DOM element to track
  114249. */
  114250. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114251. /**
  114252. * Release all associated resources
  114253. */
  114254. dispose(): void;
  114255. private renderFunction;
  114256. private drag;
  114257. private drop;
  114258. private _traverseFolder;
  114259. private _processFiles;
  114260. /**
  114261. * Load files from a drop event
  114262. * @param event defines the drop event to use as source
  114263. */
  114264. loadFiles(event: any): void;
  114265. private _processReload;
  114266. /**
  114267. * Reload the current scene from the loaded files
  114268. */
  114269. reload(): void;
  114270. }
  114271. }
  114272. declare module BABYLON {
  114273. /**
  114274. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114276. */
  114277. export class SceneOptimization {
  114278. /**
  114279. * Defines the priority of this optimization (0 by default which means first in the list)
  114280. */
  114281. priority: number;
  114282. /**
  114283. * Gets a string describing the action executed by the current optimization
  114284. * @returns description string
  114285. */
  114286. getDescription(): string;
  114287. /**
  114288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114289. * @param scene defines the current scene where to apply this optimization
  114290. * @param optimizer defines the current optimizer
  114291. * @returns true if everything that can be done was applied
  114292. */
  114293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114294. /**
  114295. * Creates the SceneOptimization object
  114296. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114297. * @param desc defines the description associated with the optimization
  114298. */
  114299. constructor(
  114300. /**
  114301. * Defines the priority of this optimization (0 by default which means first in the list)
  114302. */
  114303. priority?: number);
  114304. }
  114305. /**
  114306. * Defines an optimization used to reduce the size of render target textures
  114307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114308. */
  114309. export class TextureOptimization extends SceneOptimization {
  114310. /**
  114311. * Defines the priority of this optimization (0 by default which means first in the list)
  114312. */
  114313. priority: number;
  114314. /**
  114315. * 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
  114316. */
  114317. maximumSize: number;
  114318. /**
  114319. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114320. */
  114321. step: number;
  114322. /**
  114323. * Gets a string describing the action executed by the current optimization
  114324. * @returns description string
  114325. */
  114326. getDescription(): string;
  114327. /**
  114328. * Creates the TextureOptimization object
  114329. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114330. * @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
  114331. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114332. */
  114333. constructor(
  114334. /**
  114335. * Defines the priority of this optimization (0 by default which means first in the list)
  114336. */
  114337. priority?: number,
  114338. /**
  114339. * 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
  114340. */
  114341. maximumSize?: number,
  114342. /**
  114343. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114344. */
  114345. step?: number);
  114346. /**
  114347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114348. * @param scene defines the current scene where to apply this optimization
  114349. * @param optimizer defines the current optimizer
  114350. * @returns true if everything that can be done was applied
  114351. */
  114352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114353. }
  114354. /**
  114355. * Defines an optimization used to increase or decrease the rendering resolution
  114356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114357. */
  114358. export class HardwareScalingOptimization extends SceneOptimization {
  114359. /**
  114360. * Defines the priority of this optimization (0 by default which means first in the list)
  114361. */
  114362. priority: number;
  114363. /**
  114364. * Defines the maximum scale to use (2 by default)
  114365. */
  114366. maximumScale: number;
  114367. /**
  114368. * Defines the step to use between two passes (0.5 by default)
  114369. */
  114370. step: number;
  114371. private _currentScale;
  114372. private _directionOffset;
  114373. /**
  114374. * Gets a string describing the action executed by the current optimization
  114375. * @return description string
  114376. */
  114377. getDescription(): string;
  114378. /**
  114379. * Creates the HardwareScalingOptimization object
  114380. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114381. * @param maximumScale defines the maximum scale to use (2 by default)
  114382. * @param step defines the step to use between two passes (0.5 by default)
  114383. */
  114384. constructor(
  114385. /**
  114386. * Defines the priority of this optimization (0 by default which means first in the list)
  114387. */
  114388. priority?: number,
  114389. /**
  114390. * Defines the maximum scale to use (2 by default)
  114391. */
  114392. maximumScale?: number,
  114393. /**
  114394. * Defines the step to use between two passes (0.5 by default)
  114395. */
  114396. step?: number);
  114397. /**
  114398. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114399. * @param scene defines the current scene where to apply this optimization
  114400. * @param optimizer defines the current optimizer
  114401. * @returns true if everything that can be done was applied
  114402. */
  114403. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114404. }
  114405. /**
  114406. * Defines an optimization used to remove shadows
  114407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114408. */
  114409. export class ShadowsOptimization extends SceneOptimization {
  114410. /**
  114411. * Gets a string describing the action executed by the current optimization
  114412. * @return description string
  114413. */
  114414. getDescription(): string;
  114415. /**
  114416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114417. * @param scene defines the current scene where to apply this optimization
  114418. * @param optimizer defines the current optimizer
  114419. * @returns true if everything that can be done was applied
  114420. */
  114421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114422. }
  114423. /**
  114424. * Defines an optimization used to turn post-processes off
  114425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114426. */
  114427. export class PostProcessesOptimization extends SceneOptimization {
  114428. /**
  114429. * Gets a string describing the action executed by the current optimization
  114430. * @return description string
  114431. */
  114432. getDescription(): string;
  114433. /**
  114434. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114435. * @param scene defines the current scene where to apply this optimization
  114436. * @param optimizer defines the current optimizer
  114437. * @returns true if everything that can be done was applied
  114438. */
  114439. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114440. }
  114441. /**
  114442. * Defines an optimization used to turn lens flares off
  114443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114444. */
  114445. export class LensFlaresOptimization extends SceneOptimization {
  114446. /**
  114447. * Gets a string describing the action executed by the current optimization
  114448. * @return description string
  114449. */
  114450. getDescription(): string;
  114451. /**
  114452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114453. * @param scene defines the current scene where to apply this optimization
  114454. * @param optimizer defines the current optimizer
  114455. * @returns true if everything that can be done was applied
  114456. */
  114457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114458. }
  114459. /**
  114460. * Defines an optimization based on user defined callback.
  114461. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114462. */
  114463. export class CustomOptimization extends SceneOptimization {
  114464. /**
  114465. * Callback called to apply the custom optimization.
  114466. */
  114467. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  114468. /**
  114469. * Callback called to get custom description
  114470. */
  114471. onGetDescription: () => string;
  114472. /**
  114473. * Gets a string describing the action executed by the current optimization
  114474. * @returns description string
  114475. */
  114476. getDescription(): string;
  114477. /**
  114478. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114479. * @param scene defines the current scene where to apply this optimization
  114480. * @param optimizer defines the current optimizer
  114481. * @returns true if everything that can be done was applied
  114482. */
  114483. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114484. }
  114485. /**
  114486. * Defines an optimization used to turn particles off
  114487. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114488. */
  114489. export class ParticlesOptimization extends SceneOptimization {
  114490. /**
  114491. * Gets a string describing the action executed by the current optimization
  114492. * @return description string
  114493. */
  114494. getDescription(): string;
  114495. /**
  114496. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114497. * @param scene defines the current scene where to apply this optimization
  114498. * @param optimizer defines the current optimizer
  114499. * @returns true if everything that can be done was applied
  114500. */
  114501. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114502. }
  114503. /**
  114504. * Defines an optimization used to turn render targets off
  114505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114506. */
  114507. export class RenderTargetsOptimization extends SceneOptimization {
  114508. /**
  114509. * Gets a string describing the action executed by the current optimization
  114510. * @return description string
  114511. */
  114512. getDescription(): string;
  114513. /**
  114514. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114515. * @param scene defines the current scene where to apply this optimization
  114516. * @param optimizer defines the current optimizer
  114517. * @returns true if everything that can be done was applied
  114518. */
  114519. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114520. }
  114521. /**
  114522. * Defines an optimization used to merge meshes with compatible materials
  114523. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114524. */
  114525. export class MergeMeshesOptimization extends SceneOptimization {
  114526. private static _UpdateSelectionTree;
  114527. /**
  114528. * Gets or sets a boolean which defines if optimization octree has to be updated
  114529. */
  114530. /**
  114531. * Gets or sets a boolean which defines if optimization octree has to be updated
  114532. */
  114533. static UpdateSelectionTree: boolean;
  114534. /**
  114535. * Gets a string describing the action executed by the current optimization
  114536. * @return description string
  114537. */
  114538. getDescription(): string;
  114539. private _canBeMerged;
  114540. /**
  114541. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114542. * @param scene defines the current scene where to apply this optimization
  114543. * @param optimizer defines the current optimizer
  114544. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  114545. * @returns true if everything that can be done was applied
  114546. */
  114547. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  114548. }
  114549. /**
  114550. * Defines a list of options used by SceneOptimizer
  114551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114552. */
  114553. export class SceneOptimizerOptions {
  114554. /**
  114555. * Defines the target frame rate to reach (60 by default)
  114556. */
  114557. targetFrameRate: number;
  114558. /**
  114559. * Defines the interval between two checkes (2000ms by default)
  114560. */
  114561. trackerDuration: number;
  114562. /**
  114563. * Gets the list of optimizations to apply
  114564. */
  114565. optimizations: SceneOptimization[];
  114566. /**
  114567. * Creates a new list of options used by SceneOptimizer
  114568. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  114569. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  114570. */
  114571. constructor(
  114572. /**
  114573. * Defines the target frame rate to reach (60 by default)
  114574. */
  114575. targetFrameRate?: number,
  114576. /**
  114577. * Defines the interval between two checkes (2000ms by default)
  114578. */
  114579. trackerDuration?: number);
  114580. /**
  114581. * Add a new optimization
  114582. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  114583. * @returns the current SceneOptimizerOptions
  114584. */
  114585. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  114586. /**
  114587. * Add a new custom optimization
  114588. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  114589. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  114590. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114591. * @returns the current SceneOptimizerOptions
  114592. */
  114593. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  114594. /**
  114595. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  114596. * @param targetFrameRate defines the target frame rate (60 by default)
  114597. * @returns a SceneOptimizerOptions object
  114598. */
  114599. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114600. /**
  114601. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  114602. * @param targetFrameRate defines the target frame rate (60 by default)
  114603. * @returns a SceneOptimizerOptions object
  114604. */
  114605. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114606. /**
  114607. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  114608. * @param targetFrameRate defines the target frame rate (60 by default)
  114609. * @returns a SceneOptimizerOptions object
  114610. */
  114611. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  114612. }
  114613. /**
  114614. * Class used to run optimizations in order to reach a target frame rate
  114615. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114616. */
  114617. export class SceneOptimizer implements IDisposable {
  114618. private _isRunning;
  114619. private _options;
  114620. private _scene;
  114621. private _currentPriorityLevel;
  114622. private _targetFrameRate;
  114623. private _trackerDuration;
  114624. private _currentFrameRate;
  114625. private _sceneDisposeObserver;
  114626. private _improvementMode;
  114627. /**
  114628. * Defines an observable called when the optimizer reaches the target frame rate
  114629. */
  114630. onSuccessObservable: Observable<SceneOptimizer>;
  114631. /**
  114632. * Defines an observable called when the optimizer enables an optimization
  114633. */
  114634. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  114635. /**
  114636. * Defines an observable called when the optimizer is not able to reach the target frame rate
  114637. */
  114638. onFailureObservable: Observable<SceneOptimizer>;
  114639. /**
  114640. * Gets a boolean indicating if the optimizer is in improvement mode
  114641. */
  114642. readonly isInImprovementMode: boolean;
  114643. /**
  114644. * Gets the current priority level (0 at start)
  114645. */
  114646. readonly currentPriorityLevel: number;
  114647. /**
  114648. * Gets the current frame rate checked by the SceneOptimizer
  114649. */
  114650. readonly currentFrameRate: number;
  114651. /**
  114652. * Gets or sets the current target frame rate (60 by default)
  114653. */
  114654. /**
  114655. * Gets or sets the current target frame rate (60 by default)
  114656. */
  114657. targetFrameRate: number;
  114658. /**
  114659. * Gets or sets the current interval between two checks (every 2000ms by default)
  114660. */
  114661. /**
  114662. * Gets or sets the current interval between two checks (every 2000ms by default)
  114663. */
  114664. trackerDuration: number;
  114665. /**
  114666. * Gets the list of active optimizations
  114667. */
  114668. readonly optimizations: SceneOptimization[];
  114669. /**
  114670. * Creates a new SceneOptimizer
  114671. * @param scene defines the scene to work on
  114672. * @param options defines the options to use with the SceneOptimizer
  114673. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  114674. * @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)
  114675. */
  114676. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  114677. /**
  114678. * Stops the current optimizer
  114679. */
  114680. stop(): void;
  114681. /**
  114682. * Reset the optimizer to initial step (current priority level = 0)
  114683. */
  114684. reset(): void;
  114685. /**
  114686. * Start the optimizer. By default it will try to reach a specific framerate
  114687. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  114688. */
  114689. start(): void;
  114690. private _checkCurrentState;
  114691. /**
  114692. * Release all resources
  114693. */
  114694. dispose(): void;
  114695. /**
  114696. * Helper function to create a SceneOptimizer with one single line of code
  114697. * @param scene defines the scene to work on
  114698. * @param options defines the options to use with the SceneOptimizer
  114699. * @param onSuccess defines a callback to call on success
  114700. * @param onFailure defines a callback to call on failure
  114701. * @returns the new SceneOptimizer object
  114702. */
  114703. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  114704. }
  114705. }
  114706. declare module BABYLON {
  114707. /**
  114708. * Class used to serialize a scene into a string
  114709. */
  114710. export class SceneSerializer {
  114711. /**
  114712. * Clear cache used by a previous serialization
  114713. */
  114714. static ClearCache(): void;
  114715. /**
  114716. * Serialize a scene into a JSON compatible object
  114717. * @param scene defines the scene to serialize
  114718. * @returns a JSON compatible object
  114719. */
  114720. static Serialize(scene: Scene): any;
  114721. /**
  114722. * Serialize a mesh into a JSON compatible object
  114723. * @param toSerialize defines the mesh to serialize
  114724. * @param withParents defines if parents must be serialized as well
  114725. * @param withChildren defines if children must be serialized as well
  114726. * @returns a JSON compatible object
  114727. */
  114728. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  114729. }
  114730. }
  114731. declare module BABYLON {
  114732. /**
  114733. * Class used to host texture specific utilities
  114734. */
  114735. export class TextureTools {
  114736. /**
  114737. * Uses the GPU to create a copy texture rescaled at a given size
  114738. * @param texture Texture to copy from
  114739. * @param width defines the desired width
  114740. * @param height defines the desired height
  114741. * @param useBilinearMode defines if bilinear mode has to be used
  114742. * @return the generated texture
  114743. */
  114744. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  114745. }
  114746. }
  114747. declare module BABYLON {
  114748. /**
  114749. * This represents the different options avilable for the video capture.
  114750. */
  114751. export interface VideoRecorderOptions {
  114752. /** Defines the mime type of the video */
  114753. mimeType: string;
  114754. /** Defines the video the video should be recorded at */
  114755. fps: number;
  114756. /** Defines the chunk size for the recording data */
  114757. recordChunckSize: number;
  114758. /** The audio tracks to attach to the record */
  114759. audioTracks?: MediaStreamTrack[];
  114760. }
  114761. /**
  114762. * This can helps recording videos from BabylonJS.
  114763. * This is based on the available WebRTC functionalities of the browser.
  114764. *
  114765. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  114766. */
  114767. export class VideoRecorder {
  114768. private static readonly _defaultOptions;
  114769. /**
  114770. * Returns wehther or not the VideoRecorder is available in your browser.
  114771. * @param engine Defines the Babylon Engine to check the support for
  114772. * @returns true if supported otherwise false
  114773. */
  114774. static IsSupported(engine: Engine): boolean;
  114775. private readonly _options;
  114776. private _canvas;
  114777. private _mediaRecorder;
  114778. private _recordedChunks;
  114779. private _fileName;
  114780. private _resolve;
  114781. private _reject;
  114782. /**
  114783. * True wether a recording is already in progress.
  114784. */
  114785. readonly isRecording: boolean;
  114786. /**
  114787. * Create a new VideoCapture object which can help converting what you see in Babylon to
  114788. * a video file.
  114789. * @param engine Defines the BabylonJS Engine you wish to record
  114790. * @param options Defines options that can be used to customized the capture
  114791. */
  114792. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  114793. /**
  114794. * Stops the current recording before the default capture timeout passed in the startRecording
  114795. * functions.
  114796. */
  114797. stopRecording(): void;
  114798. /**
  114799. * Starts recording the canvas for a max duration specified in parameters.
  114800. * @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.
  114801. * @param maxDuration Defines the maximum recording time in seconds.
  114802. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  114803. * @return a promise callback at the end of the recording with the video data in Blob.
  114804. */
  114805. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  114806. /**
  114807. * Releases internal resources used during the recording.
  114808. */
  114809. dispose(): void;
  114810. private _handleDataAvailable;
  114811. private _handleError;
  114812. private _handleStop;
  114813. }
  114814. }
  114815. declare module BABYLON {
  114816. /**
  114817. * Helper class to push actions to a pool of workers.
  114818. */
  114819. export class WorkerPool implements IDisposable {
  114820. private _workerInfos;
  114821. private _pendingActions;
  114822. /**
  114823. * Constructor
  114824. * @param workers Array of workers to use for actions
  114825. */
  114826. constructor(workers: Array<Worker>);
  114827. /**
  114828. * Terminates all workers and clears any pending actions.
  114829. */
  114830. dispose(): void;
  114831. /**
  114832. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114833. * pended until a worker has completed its action.
  114834. * @param action The action to perform. Call onComplete when the action is complete.
  114835. */
  114836. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114837. private _execute;
  114838. }
  114839. }
  114840. declare module BABYLON {
  114841. /**
  114842. * Class containing a set of static utilities functions for screenshots
  114843. */
  114844. export class ScreenshotTools {
  114845. /**
  114846. * Captures a screenshot of the current rendering
  114847. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114848. * @param engine defines the rendering engine
  114849. * @param camera defines the source camera
  114850. * @param size This parameter can be set to a single number or to an object with the
  114851. * following (optional) properties: precision, width, height. If a single number is passed,
  114852. * it will be used for both width and height. If an object is passed, the screenshot size
  114853. * will be derived from the parameters. The precision property is a multiplier allowing
  114854. * rendering at a higher or lower resolution
  114855. * @param successCallback defines the callback receives a single parameter which contains the
  114856. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114857. * src parameter of an <img> to display it
  114858. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114859. * Check your browser for supported MIME types
  114860. */
  114861. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  114862. /**
  114863. * Generates an image screenshot from the specified camera.
  114864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114865. * @param engine The engine to use for rendering
  114866. * @param camera The camera to use for rendering
  114867. * @param size This parameter can be set to a single number or to an object with the
  114868. * following (optional) properties: precision, width, height. If a single number is passed,
  114869. * it will be used for both width and height. If an object is passed, the screenshot size
  114870. * will be derived from the parameters. The precision property is a multiplier allowing
  114871. * rendering at a higher or lower resolution
  114872. * @param successCallback The callback receives a single parameter which contains the
  114873. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114874. * src parameter of an <img> to display it
  114875. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114876. * Check your browser for supported MIME types
  114877. * @param samples Texture samples (default: 1)
  114878. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114879. * @param fileName A name for for the downloaded file.
  114880. */
  114881. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114882. }
  114883. }
  114884. declare module BABYLON {
  114885. /**
  114886. * A cursor which tracks a point on a path
  114887. */
  114888. export class PathCursor {
  114889. private path;
  114890. /**
  114891. * Stores path cursor callbacks for when an onchange event is triggered
  114892. */
  114893. private _onchange;
  114894. /**
  114895. * The value of the path cursor
  114896. */
  114897. value: number;
  114898. /**
  114899. * The animation array of the path cursor
  114900. */
  114901. animations: Animation[];
  114902. /**
  114903. * Initializes the path cursor
  114904. * @param path The path to track
  114905. */
  114906. constructor(path: Path2);
  114907. /**
  114908. * Gets the cursor point on the path
  114909. * @returns A point on the path cursor at the cursor location
  114910. */
  114911. getPoint(): Vector3;
  114912. /**
  114913. * Moves the cursor ahead by the step amount
  114914. * @param step The amount to move the cursor forward
  114915. * @returns This path cursor
  114916. */
  114917. moveAhead(step?: number): PathCursor;
  114918. /**
  114919. * Moves the cursor behind by the step amount
  114920. * @param step The amount to move the cursor back
  114921. * @returns This path cursor
  114922. */
  114923. moveBack(step?: number): PathCursor;
  114924. /**
  114925. * Moves the cursor by the step amount
  114926. * If the step amount is greater than one, an exception is thrown
  114927. * @param step The amount to move the cursor
  114928. * @returns This path cursor
  114929. */
  114930. move(step: number): PathCursor;
  114931. /**
  114932. * Ensures that the value is limited between zero and one
  114933. * @returns This path cursor
  114934. */
  114935. private ensureLimits;
  114936. /**
  114937. * Runs onchange callbacks on change (used by the animation engine)
  114938. * @returns This path cursor
  114939. */
  114940. private raiseOnChange;
  114941. /**
  114942. * Executes a function on change
  114943. * @param f A path cursor onchange callback
  114944. * @returns This path cursor
  114945. */
  114946. onchange(f: (cursor: PathCursor) => void): PathCursor;
  114947. }
  114948. }
  114949. declare module BABYLON {
  114950. /** @hidden */
  114951. export var blurPixelShader: {
  114952. name: string;
  114953. shader: string;
  114954. };
  114955. }
  114956. declare module BABYLON {
  114957. /** @hidden */
  114958. export var bones300Declaration: {
  114959. name: string;
  114960. shader: string;
  114961. };
  114962. }
  114963. declare module BABYLON {
  114964. /** @hidden */
  114965. export var instances300Declaration: {
  114966. name: string;
  114967. shader: string;
  114968. };
  114969. }
  114970. declare module BABYLON {
  114971. /** @hidden */
  114972. export var pointCloudVertexDeclaration: {
  114973. name: string;
  114974. shader: string;
  114975. };
  114976. }
  114977. // Mixins
  114978. interface Window {
  114979. mozIndexedDB: IDBFactory;
  114980. webkitIndexedDB: IDBFactory;
  114981. msIndexedDB: IDBFactory;
  114982. webkitURL: typeof URL;
  114983. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  114984. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  114985. WebGLRenderingContext: WebGLRenderingContext;
  114986. MSGesture: MSGesture;
  114987. CANNON: any;
  114988. AudioContext: AudioContext;
  114989. webkitAudioContext: AudioContext;
  114990. PointerEvent: any;
  114991. Math: Math;
  114992. Uint8Array: Uint8ArrayConstructor;
  114993. Float32Array: Float32ArrayConstructor;
  114994. mozURL: typeof URL;
  114995. msURL: typeof URL;
  114996. VRFrameData: any; // WebVR, from specs 1.1
  114997. DracoDecoderModule: any;
  114998. setImmediate(handler: (...args: any[]) => void): number;
  114999. }
  115000. interface HTMLCanvasElement {
  115001. requestPointerLock(): void;
  115002. msRequestPointerLock?(): void;
  115003. mozRequestPointerLock?(): void;
  115004. webkitRequestPointerLock?(): void;
  115005. /** Track wether a record is in progress */
  115006. isRecording: boolean;
  115007. /** Capture Stream method defined by some browsers */
  115008. captureStream(fps?: number): MediaStream;
  115009. }
  115010. interface CanvasRenderingContext2D {
  115011. msImageSmoothingEnabled: boolean;
  115012. }
  115013. interface MouseEvent {
  115014. mozMovementX: number;
  115015. mozMovementY: number;
  115016. webkitMovementX: number;
  115017. webkitMovementY: number;
  115018. msMovementX: number;
  115019. msMovementY: number;
  115020. }
  115021. interface Navigator {
  115022. mozGetVRDevices: (any: any) => any;
  115023. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115024. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115025. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115026. webkitGetGamepads(): Gamepad[];
  115027. msGetGamepads(): Gamepad[];
  115028. webkitGamepads(): Gamepad[];
  115029. }
  115030. interface HTMLVideoElement {
  115031. mozSrcObject: any;
  115032. }
  115033. interface Math {
  115034. fround(x: number): number;
  115035. imul(a: number, b: number): number;
  115036. }
  115037. interface WebGLProgram {
  115038. context?: WebGLRenderingContext;
  115039. vertexShader?: WebGLShader;
  115040. fragmentShader?: WebGLShader;
  115041. isParallelCompiled: boolean;
  115042. onCompiled?: () => void;
  115043. }
  115044. interface WebGLRenderingContext {
  115045. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115046. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115047. vertexAttribDivisor(index: number, divisor: number): void;
  115048. createVertexArray(): any;
  115049. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115050. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115051. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115052. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115053. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115054. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115055. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115056. // Queries
  115057. createQuery(): WebGLQuery;
  115058. deleteQuery(query: WebGLQuery): void;
  115059. beginQuery(target: number, query: WebGLQuery): void;
  115060. endQuery(target: number): void;
  115061. getQueryParameter(query: WebGLQuery, pname: number): any;
  115062. getQuery(target: number, pname: number): any;
  115063. MAX_SAMPLES: number;
  115064. RGBA8: number;
  115065. READ_FRAMEBUFFER: number;
  115066. DRAW_FRAMEBUFFER: number;
  115067. UNIFORM_BUFFER: number;
  115068. HALF_FLOAT_OES: number;
  115069. RGBA16F: number;
  115070. RGBA32F: number;
  115071. R32F: number;
  115072. RG32F: number;
  115073. RGB32F: number;
  115074. R16F: number;
  115075. RG16F: number;
  115076. RGB16F: number;
  115077. RED: number;
  115078. RG: number;
  115079. R8: number;
  115080. RG8: number;
  115081. UNSIGNED_INT_24_8: number;
  115082. DEPTH24_STENCIL8: number;
  115083. /* Multiple Render Targets */
  115084. drawBuffers(buffers: number[]): void;
  115085. readBuffer(src: number): void;
  115086. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115087. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115088. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115089. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115090. // Occlusion Query
  115091. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115092. ANY_SAMPLES_PASSED: number;
  115093. QUERY_RESULT_AVAILABLE: number;
  115094. QUERY_RESULT: number;
  115095. }
  115096. interface WebGLBuffer {
  115097. references: number;
  115098. capacity: number;
  115099. is32Bits: boolean;
  115100. }
  115101. interface WebGLProgram {
  115102. transformFeedback?: WebGLTransformFeedback | null;
  115103. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115104. }
  115105. interface EXT_disjoint_timer_query {
  115106. QUERY_COUNTER_BITS_EXT: number;
  115107. TIME_ELAPSED_EXT: number;
  115108. TIMESTAMP_EXT: number;
  115109. GPU_DISJOINT_EXT: number;
  115110. QUERY_RESULT_EXT: number;
  115111. QUERY_RESULT_AVAILABLE_EXT: number;
  115112. queryCounterEXT(query: WebGLQuery, target: number): void;
  115113. createQueryEXT(): WebGLQuery;
  115114. beginQueryEXT(target: number, query: WebGLQuery): void;
  115115. endQueryEXT(target: number): void;
  115116. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115117. deleteQueryEXT(query: WebGLQuery): void;
  115118. }
  115119. interface WebGLUniformLocation {
  115120. _currentState: any;
  115121. }
  115122. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115123. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115124. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115125. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115126. interface WebGLRenderingContext {
  115127. readonly RASTERIZER_DISCARD: number;
  115128. readonly DEPTH_COMPONENT24: number;
  115129. readonly TEXTURE_3D: number;
  115130. readonly TEXTURE_2D_ARRAY: number;
  115131. readonly TEXTURE_COMPARE_FUNC: number;
  115132. readonly TEXTURE_COMPARE_MODE: number;
  115133. readonly COMPARE_REF_TO_TEXTURE: number;
  115134. readonly TEXTURE_WRAP_R: number;
  115135. readonly HALF_FLOAT: number;
  115136. readonly RGB8: number;
  115137. readonly RED_INTEGER: number;
  115138. readonly RG_INTEGER: number;
  115139. readonly RGB_INTEGER: number;
  115140. readonly RGBA_INTEGER: number;
  115141. readonly R8_SNORM: number;
  115142. readonly RG8_SNORM: number;
  115143. readonly RGB8_SNORM: number;
  115144. readonly RGBA8_SNORM: number;
  115145. readonly R8I: number;
  115146. readonly RG8I: number;
  115147. readonly RGB8I: number;
  115148. readonly RGBA8I: number;
  115149. readonly R8UI: number;
  115150. readonly RG8UI: number;
  115151. readonly RGB8UI: number;
  115152. readonly RGBA8UI: number;
  115153. readonly R16I: number;
  115154. readonly RG16I: number;
  115155. readonly RGB16I: number;
  115156. readonly RGBA16I: number;
  115157. readonly R16UI: number;
  115158. readonly RG16UI: number;
  115159. readonly RGB16UI: number;
  115160. readonly RGBA16UI: number;
  115161. readonly R32I: number;
  115162. readonly RG32I: number;
  115163. readonly RGB32I: number;
  115164. readonly RGBA32I: number;
  115165. readonly R32UI: number;
  115166. readonly RG32UI: number;
  115167. readonly RGB32UI: number;
  115168. readonly RGBA32UI: number;
  115169. readonly RGB10_A2UI: number;
  115170. readonly R11F_G11F_B10F: number;
  115171. readonly RGB9_E5: number;
  115172. readonly RGB10_A2: number;
  115173. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115174. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115175. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115176. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115177. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115178. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115179. 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;
  115180. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115181. readonly TRANSFORM_FEEDBACK: number;
  115182. readonly INTERLEAVED_ATTRIBS: number;
  115183. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115184. createTransformFeedback(): WebGLTransformFeedback;
  115185. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115186. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115187. beginTransformFeedback(primitiveMode: number): void;
  115188. endTransformFeedback(): void;
  115189. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115190. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115191. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115192. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115193. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115194. }
  115195. interface ImageBitmap {
  115196. readonly width: number;
  115197. readonly height: number;
  115198. close(): void;
  115199. }
  115200. interface WebGLQuery extends WebGLObject {
  115201. }
  115202. declare var WebGLQuery: {
  115203. prototype: WebGLQuery;
  115204. new(): WebGLQuery;
  115205. };
  115206. interface WebGLSampler extends WebGLObject {
  115207. }
  115208. declare var WebGLSampler: {
  115209. prototype: WebGLSampler;
  115210. new(): WebGLSampler;
  115211. };
  115212. interface WebGLSync extends WebGLObject {
  115213. }
  115214. declare var WebGLSync: {
  115215. prototype: WebGLSync;
  115216. new(): WebGLSync;
  115217. };
  115218. interface WebGLTransformFeedback extends WebGLObject {
  115219. }
  115220. declare var WebGLTransformFeedback: {
  115221. prototype: WebGLTransformFeedback;
  115222. new(): WebGLTransformFeedback;
  115223. };
  115224. interface WebGLVertexArrayObject extends WebGLObject {
  115225. }
  115226. declare var WebGLVertexArrayObject: {
  115227. prototype: WebGLVertexArrayObject;
  115228. new(): WebGLVertexArrayObject;
  115229. };
  115230. // Type definitions for WebVR API
  115231. // Project: https://w3c.github.io/webvr/
  115232. // Definitions by: six a <https://github.com/lostfictions>
  115233. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115234. interface VRDisplay extends EventTarget {
  115235. /**
  115236. * Dictionary of capabilities describing the VRDisplay.
  115237. */
  115238. readonly capabilities: VRDisplayCapabilities;
  115239. /**
  115240. * z-depth defining the far plane of the eye view frustum
  115241. * enables mapping of values in the render target depth
  115242. * attachment to scene coordinates. Initially set to 10000.0.
  115243. */
  115244. depthFar: number;
  115245. /**
  115246. * z-depth defining the near plane of the eye view frustum
  115247. * enables mapping of values in the render target depth
  115248. * attachment to scene coordinates. Initially set to 0.01.
  115249. */
  115250. depthNear: number;
  115251. /**
  115252. * An identifier for this distinct VRDisplay. Used as an
  115253. * association point in the Gamepad API.
  115254. */
  115255. readonly displayId: number;
  115256. /**
  115257. * A display name, a user-readable name identifying it.
  115258. */
  115259. readonly displayName: string;
  115260. readonly isConnected: boolean;
  115261. readonly isPresenting: boolean;
  115262. /**
  115263. * If this VRDisplay supports room-scale experiences, the optional
  115264. * stage attribute contains details on the room-scale parameters.
  115265. */
  115266. readonly stageParameters: VRStageParameters | null;
  115267. /**
  115268. * Passing the value returned by `requestAnimationFrame` to
  115269. * `cancelAnimationFrame` will unregister the callback.
  115270. * @param handle Define the hanle of the request to cancel
  115271. */
  115272. cancelAnimationFrame(handle: number): void;
  115273. /**
  115274. * Stops presenting to the VRDisplay.
  115275. * @returns a promise to know when it stopped
  115276. */
  115277. exitPresent(): Promise<void>;
  115278. /**
  115279. * Return the current VREyeParameters for the given eye.
  115280. * @param whichEye Define the eye we want the parameter for
  115281. * @returns the eye parameters
  115282. */
  115283. getEyeParameters(whichEye: string): VREyeParameters;
  115284. /**
  115285. * Populates the passed VRFrameData with the information required to render
  115286. * the current frame.
  115287. * @param frameData Define the data structure to populate
  115288. * @returns true if ok otherwise false
  115289. */
  115290. getFrameData(frameData: VRFrameData): boolean;
  115291. /**
  115292. * Get the layers currently being presented.
  115293. * @returns the list of VR layers
  115294. */
  115295. getLayers(): VRLayer[];
  115296. /**
  115297. * Return a VRPose containing the future predicted pose of the VRDisplay
  115298. * when the current frame will be presented. The value returned will not
  115299. * change until JavaScript has returned control to the browser.
  115300. *
  115301. * The VRPose will contain the position, orientation, velocity,
  115302. * and acceleration of each of these properties.
  115303. * @returns the pose object
  115304. */
  115305. getPose(): VRPose;
  115306. /**
  115307. * Return the current instantaneous pose of the VRDisplay, with no
  115308. * prediction applied.
  115309. * @returns the current instantaneous pose
  115310. */
  115311. getImmediatePose(): VRPose;
  115312. /**
  115313. * The callback passed to `requestAnimationFrame` will be called
  115314. * any time a new frame should be rendered. When the VRDisplay is
  115315. * presenting the callback will be called at the native refresh
  115316. * rate of the HMD. When not presenting this function acts
  115317. * identically to how window.requestAnimationFrame acts. Content should
  115318. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115319. * asynchronously from other displays and at differing refresh rates.
  115320. * @param callback Define the eaction to run next frame
  115321. * @returns the request handle it
  115322. */
  115323. requestAnimationFrame(callback: FrameRequestCallback): number;
  115324. /**
  115325. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115326. * Repeat calls while already presenting will update the VRLayers being displayed.
  115327. * @param layers Define the list of layer to present
  115328. * @returns a promise to know when the request has been fulfilled
  115329. */
  115330. requestPresent(layers: VRLayer[]): Promise<void>;
  115331. /**
  115332. * Reset the pose for this display, treating its current position and
  115333. * orientation as the "origin/zero" values. VRPose.position,
  115334. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115335. * updated when calling resetPose(). This should be called in only
  115336. * sitting-space experiences.
  115337. */
  115338. resetPose(): void;
  115339. /**
  115340. * The VRLayer provided to the VRDisplay will be captured and presented
  115341. * in the HMD. Calling this function has the same effect on the source
  115342. * canvas as any other operation that uses its source image, and canvases
  115343. * created without preserveDrawingBuffer set to true will be cleared.
  115344. * @param pose Define the pose to submit
  115345. */
  115346. submitFrame(pose?: VRPose): void;
  115347. }
  115348. declare var VRDisplay: {
  115349. prototype: VRDisplay;
  115350. new(): VRDisplay;
  115351. };
  115352. interface VRLayer {
  115353. leftBounds?: number[] | Float32Array | null;
  115354. rightBounds?: number[] | Float32Array | null;
  115355. source?: HTMLCanvasElement | null;
  115356. }
  115357. interface VRDisplayCapabilities {
  115358. readonly canPresent: boolean;
  115359. readonly hasExternalDisplay: boolean;
  115360. readonly hasOrientation: boolean;
  115361. readonly hasPosition: boolean;
  115362. readonly maxLayers: number;
  115363. }
  115364. interface VREyeParameters {
  115365. /** @deprecated */
  115366. readonly fieldOfView: VRFieldOfView;
  115367. readonly offset: Float32Array;
  115368. readonly renderHeight: number;
  115369. readonly renderWidth: number;
  115370. }
  115371. interface VRFieldOfView {
  115372. readonly downDegrees: number;
  115373. readonly leftDegrees: number;
  115374. readonly rightDegrees: number;
  115375. readonly upDegrees: number;
  115376. }
  115377. interface VRFrameData {
  115378. readonly leftProjectionMatrix: Float32Array;
  115379. readonly leftViewMatrix: Float32Array;
  115380. readonly pose: VRPose;
  115381. readonly rightProjectionMatrix: Float32Array;
  115382. readonly rightViewMatrix: Float32Array;
  115383. readonly timestamp: number;
  115384. }
  115385. interface VRPose {
  115386. readonly angularAcceleration: Float32Array | null;
  115387. readonly angularVelocity: Float32Array | null;
  115388. readonly linearAcceleration: Float32Array | null;
  115389. readonly linearVelocity: Float32Array | null;
  115390. readonly orientation: Float32Array | null;
  115391. readonly position: Float32Array | null;
  115392. readonly timestamp: number;
  115393. }
  115394. interface VRStageParameters {
  115395. sittingToStandingTransform?: Float32Array;
  115396. sizeX?: number;
  115397. sizeY?: number;
  115398. }
  115399. interface Navigator {
  115400. getVRDisplays(): Promise<VRDisplay[]>;
  115401. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115402. }
  115403. interface Window {
  115404. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115405. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115406. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115407. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115408. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115409. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115410. }
  115411. interface Gamepad {
  115412. readonly displayId: number;
  115413. }
  115414. interface XRDevice {
  115415. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115416. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115417. }
  115418. interface XRSession {
  115419. getInputSources(): Array<any>;
  115420. baseLayer: XRWebGLLayer;
  115421. requestFrameOfReference(type: string): Promise<void>;
  115422. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115423. end(): Promise<void>;
  115424. requestAnimationFrame: Function;
  115425. addEventListener: Function;
  115426. }
  115427. interface XRSessionCreationOptions {
  115428. outputContext?: WebGLRenderingContext | null;
  115429. immersive?: boolean;
  115430. environmentIntegration?: boolean;
  115431. }
  115432. interface XRLayer {
  115433. getViewport: Function;
  115434. framebufferWidth: number;
  115435. framebufferHeight: number;
  115436. }
  115437. interface XRView {
  115438. projectionMatrix: Float32Array;
  115439. }
  115440. interface XRFrame {
  115441. getDevicePose: Function;
  115442. getInputPose: Function;
  115443. views: Array<XRView>;
  115444. baseLayer: XRLayer;
  115445. }
  115446. interface XRFrameOfReference {
  115447. }
  115448. interface XRWebGLLayer extends XRLayer {
  115449. framebuffer: WebGLFramebuffer;
  115450. }
  115451. declare var XRWebGLLayer: {
  115452. prototype: XRWebGLLayer;
  115453. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  115454. };